hwmon: (adcxx) Simplify show_name function
Guenter Roeck
maintainerPATCH 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
@@ -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
Guenter Roeck
maintainerping
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.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/adcxx.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/hwmon/adcxx.c +1
-4@@ -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
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.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/adcxx.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/hwmon/adcxx.c +0
-0
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