On Thu, May 18, 2023 at 01:07:18PM -0700, greearb@xxxxxxxxxxxxxxx wrote: > From: Ben Greear <greearb@xxxxxxxxxxxxxxx> > > Allow sensors tool to read radio's temperature, example: > > mt7921_phy17-pci-1800 > Adapter: PCI adapter > temp1: +72.0°C > > Signed-off-by: Ben Greear <greearb@xxxxxxxxxxxxxxx> > --- > .../net/wireless/mediatek/mt76/mt7921/init.c | 53 +++++++++++++++++++ > .../net/wireless/mediatek/mt76/mt7921/mcu.c | 17 ++++++ > .../wireless/mediatek/mt76/mt7921/mt7921.h | 1 + > 3 files changed, 71 insertions(+) > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c > index c15ce1a19000..18f0f2dfbbcf 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c > @@ -2,6 +2,9 @@ > /* Copyright (C) 2020 MediaTek Inc. */ > > #include <linux/etherdevice.h> > +#include <linux/hwmon.h> > +#include <linux/hwmon-sysfs.h> > +#include <linux/thermal.h> > #include <linux/firmware.h> > #include "mt7921.h" > #include "../mt76_connac2_mac.h" > @@ -58,6 +61,50 @@ static const struct ieee80211_iface_combination if_comb_chanctx[] = { > } > }; > > +static ssize_t mt7921_thermal_temp_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct mt7921_phy *phy = dev_get_drvdata(dev); > + int i = to_sensor_dev_attr(attr)->index; > + int temperature; > + > + switch (i) { > + case 0: > + temperature = mt7921_mcu_get_temperature(phy); > + if (temperature < 0) > + return temperature; > + /* display in millidegree celcius */ Hi Ben, a minor nit from my side: s/celcius/Celsius/ > + return sprintf(buf, "%u\n", temperature * 1000); > + default: > + return -EINVAL; > + } > +} ...