Search Linux Wireless

Re: [PATCH v2] wifi: mt76: mt7921: Support temp sensor.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 19, 2023 at 09:36:11AM -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>

Hi Ben,

me again.

...

> @@ -58,6 +61,53 @@ 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)
> +{
> +	switch (to_sensor_dev_attr(attr)->index) {
> +	case 0:
> +		struct mt7921_phy *phy = dev_get_drvdata(dev);
> +		struct mt7921_dev *mdev = phy->dev;
> +		int temperature;
> +
> +		mt7921_mutex_acquire(mdev);
> +		temperature = mt7921_mcu_get_temperature(phy);
> +		mt7921_mutex_release(mdev);
> +
> +		if (temperature < 0)
> +			return temperature;
> +		/* display in millidegree Celcius */

nit: s/Celcius/Celsius/
     Did I get that wrong last time?
     If so, sorry.

> +		return sprintf(buf, "%u\n", temperature * 1000);

clang-16 does not seem to like this:

drivers/net/wireless/mediatek/mt76/mt7921/init.c:63:3: error: expected expression
                struct mt7921_phy *phy = dev_get_drvdata(dev);
                ^
drivers/net/wireless/mediatek/mt76/mt7921/init.c:64:29: error: use of undeclared identifier 'phy'
                struct mt7921_dev *mdev = phy->dev;
                                          ^
drivers/net/wireless/mediatek/mt76/mt7921/init.c:68:44: error: use of undeclared identifier 'phy'
                temperature = mt7921_mcu_get_temperature(phy);
                                                         ^
drivers/net/wireless/mediatek/mt76/mt7921/init.c:64:22: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement]
                struct mt7921_dev *mdev = phy->dev;
                                   ^
1 warning and 3 errors generated.


I think a fix is:

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
index af9b1d5e520b..9655dbd5cfc8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
@@ -59,7 +59,7 @@ static ssize_t mt7921_thermal_temp_show(struct device *dev,
 					char *buf)
 {
 	switch (to_sensor_dev_attr(attr)->index) {
-	case 0:
+	case 0: {
 		struct mt7921_phy *phy = dev_get_drvdata(dev);
 		struct mt7921_dev *mdev = phy->dev;
 		int temperature;
@@ -72,6 +72,7 @@ static ssize_t mt7921_thermal_temp_show(struct device *dev,
 			return temperature;
 		/* display in millidegree Celcius */
 		return sprintf(buf, "%u\n", temperature * 1000);
+	}
 	default:
 		return -EINVAL;
 	}

> +	default:
> +		return -EINVAL;
> +	}
> +}
> +static SENSOR_DEVICE_ATTR_RO(temp1_input, mt7921_thermal_temp, 0);

...



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux