Skip to contentSkip to conversation

hwmon: (adcxx) Simplify show_name function

PATCH In review Guenter Roeck 2 participants 3 messages Sep 11, 2012 – Sep 17, 2012 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 2/4 hwmon: (adcxx) Simplify show_name function

Display device name using to_spi_device(dev)->modalias instead of computing it from the number of ADC channels. This is cleaner and reduces code size.

---
 drivers/hwmon/adcxx.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/hwmon/adcxx.c +1 -4
index 111af7c..f4c5867 100644
@@ -141,10 +141,7 @@ static ssize_t adcxx_set_max(struct device *dev,
 static ssize_t adcxx_show_name(struct device *dev, struct device_attribute
 			      *devattr, char *buf)
 {
-	struct spi_device *spi = to_spi_device(dev);
-	struct adcxx *adc = spi_get_drvdata(spi);
-
-	return sprintf(buf, "adcxx%ds\n", adc->channels);
+	return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
 }
 
 static struct sensor_device_attribute ad_input[] = {
Signature · 7 lines
1.7.9.7


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
author maintainer
#1 lore raw

ping

Quoted 28 lines · Guenter Roeck

Display device name using to_spi_device(dev)->modalias instead of computing it from the number of ADC channels. This is cleaner and reduces code size.

---
 drivers/hwmon/adcxx.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/hwmon/adcxx.c +1 -4
index 111af7c..f4c5867 100644
@@ -141,10 +141,7 @@ static ssize_t adcxx_set_max(struct device *dev,
 static ssize_t adcxx_show_name(struct device *dev, struct device_attribute
 			      *devattr, char *buf)
 {
-	struct spi_device *spi = to_spi_device(dev);
-	struct adcxx *adc = spi_get_drvdata(spi);
-
-	return sprintf(buf, "adcxx%ds\n", adc->channels);
+	return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
 }
 
 static struct sensor_device_attribute ad_input[] = {
Signature · 1 line
1.7.9.7

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

Acked-by on v1 2/4
#2 lore raw
In reply to Guenter Roeck
Quoted 13 lines · Guenter Roeck

Display device name using to_spi_device(dev)->modalias instead of computing it from the number of ADC channels. This is cleaner and reduces code size.

---
 drivers/hwmon/adcxx.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/hwmon/adcxx.c +0 -0
index 111af7c..f4c5867 100644

drivers/hwmon/adcxx.c static ssize_t adcxx_set_max(struct device *dev, · line 144

Quoted 4 lines
drivers/hwmon/adcxx.c +0 -1
@@ -141,10 +141,7 @@ static ssize_t adcxx_set_max(struct device *dev,
 static ssize_t adcxx_show_name(struct device *dev, struct device_attribute
 			      *devattr, char *buf)
 {
-	struct spi_device *spi = to_spi_device(dev);

As many other functions in this driver have this, you could have kept it and used spi-> below. But that's a minor detail.

drivers/hwmon/adcxx.c static ssize_t adcxx_set_max(struct device *dev, · line 147

Quoted 7 lines
drivers/hwmon/adcxx.c +1 -3
-	struct adcxx *adc = spi_get_drvdata(spi);
-
-	return sprintf(buf, "adcxx%ds\n", adc->channels);
+	return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
 }
 
 static struct sensor_device_attribute ad_input[] = {
Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors