aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2018-12-10 17:02:00 -0500
committerGuenter Roeck <linux@roeck-us.net>2018-12-16 18:13:33 -0500
commitb0c130fdaac18b69abcf577dfd21f84ec53c1eb9 (patch)
tree88bb8b5355fc57a5205b10e29cae93f2e3886d81
parent0594462f97058cb620ffb849b2ffb85e34cb43fe (diff)
hwmon: (adcxx) Use permission specific SENSOR[_DEVICE]_ATTR variants
Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_<PERMS> in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/adcxx.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/hwmon/adcxx.c b/drivers/hwmon/adcxx.c
index 69e0bb97e597..c8feb2295fe2 100644
--- a/drivers/hwmon/adcxx.c
+++ b/drivers/hwmon/adcxx.c
@@ -57,8 +57,8 @@ struct adcxx {
57}; 57};
58 58
59/* sysfs hook function */ 59/* sysfs hook function */
60static ssize_t adcxx_read(struct device *dev, 60static ssize_t adcxx_show(struct device *dev,
61 struct device_attribute *devattr, char *buf) 61 struct device_attribute *devattr, char *buf)
62{ 62{
63 struct spi_device *spi = to_spi_device(dev); 63 struct spi_device *spi = to_spi_device(dev);
64 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 64 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
@@ -94,15 +94,15 @@ out:
94 return status; 94 return status;
95} 95}
96 96
97static ssize_t adcxx_show_min(struct device *dev, 97static ssize_t adcxx_min_show(struct device *dev,
98 struct device_attribute *devattr, char *buf) 98 struct device_attribute *devattr, char *buf)
99{ 99{
100 /* The minimum reference is 0 for this chip family */ 100 /* The minimum reference is 0 for this chip family */
101 return sprintf(buf, "0\n"); 101 return sprintf(buf, "0\n");
102} 102}
103 103
104static ssize_t adcxx_show_max(struct device *dev, 104static ssize_t adcxx_max_show(struct device *dev,
105 struct device_attribute *devattr, char *buf) 105 struct device_attribute *devattr, char *buf)
106{ 106{
107 struct spi_device *spi = to_spi_device(dev); 107 struct spi_device *spi = to_spi_device(dev);
108 struct adcxx *adc = spi_get_drvdata(spi); 108 struct adcxx *adc = spi_get_drvdata(spi);
@@ -118,8 +118,9 @@ static ssize_t adcxx_show_max(struct device *dev,
118 return sprintf(buf, "%d\n", reference); 118 return sprintf(buf, "%d\n", reference);
119} 119}
120 120
121static ssize_t adcxx_set_max(struct device *dev, 121static ssize_t adcxx_max_store(struct device *dev,
122 struct device_attribute *devattr, const char *buf, size_t count) 122 struct device_attribute *devattr,
123 const char *buf, size_t count)
123{ 124{
124 struct spi_device *spi = to_spi_device(dev); 125 struct spi_device *spi = to_spi_device(dev);
125 struct adcxx *adc = spi_get_drvdata(spi); 126 struct adcxx *adc = spi_get_drvdata(spi);
@@ -138,25 +139,24 @@ static ssize_t adcxx_set_max(struct device *dev,
138 return count; 139 return count;
139} 140}
140 141
141static ssize_t adcxx_show_name(struct device *dev, struct device_attribute 142static ssize_t adcxx_name_show(struct device *dev,
142 *devattr, char *buf) 143 struct device_attribute *devattr, char *buf)
143{ 144{
144 return sprintf(buf, "%s\n", to_spi_device(dev)->modalias); 145 return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
145} 146}
146 147
147static struct sensor_device_attribute ad_input[] = { 148static struct sensor_device_attribute ad_input[] = {
148 SENSOR_ATTR(name, S_IRUGO, adcxx_show_name, NULL, 0), 149 SENSOR_ATTR_RO(name, adcxx_name, 0),
149 SENSOR_ATTR(in_min, S_IRUGO, adcxx_show_min, NULL, 0), 150 SENSOR_ATTR_RO(in_min, adcxx_min, 0),
150 SENSOR_ATTR(in_max, S_IWUSR | S_IRUGO, adcxx_show_max, 151 SENSOR_ATTR_RW(in_max, adcxx_max, 0),
151 adcxx_set_max, 0), 152 SENSOR_ATTR_RO(in0_input, adcxx, 0),
152 SENSOR_ATTR(in0_input, S_IRUGO, adcxx_read, NULL, 0), 153 SENSOR_ATTR_RO(in1_input, adcxx, 1),
153 SENSOR_ATTR(in1_input, S_IRUGO, adcxx_read, NULL, 1), 154 SENSOR_ATTR_RO(in2_input, adcxx, 2),
154 SENSOR_ATTR(in2_input, S_IRUGO, adcxx_read, NULL, 2), 155 SENSOR_ATTR_RO(in3_input, adcxx, 3),
155 SENSOR_ATTR(in3_input, S_IRUGO, adcxx_read, NULL, 3), 156 SENSOR_ATTR_RO(in4_input, adcxx, 4),
156 SENSOR_ATTR(in4_input, S_IRUGO, adcxx_read, NULL, 4), 157 SENSOR_ATTR_RO(in5_input, adcxx, 5),
157 SENSOR_ATTR(in5_input, S_IRUGO, adcxx_read, NULL, 5), 158 SENSOR_ATTR_RO(in6_input, adcxx, 6),
158 SENSOR_ATTR(in6_input, S_IRUGO, adcxx_read, NULL, 6), 159 SENSOR_ATTR_RO(in7_input, adcxx, 7),
159 SENSOR_ATTR(in7_input, S_IRUGO, adcxx_read, NULL, 7),
160}; 160};
161 161
162/*----------------------------------------------------------------------*/ 162/*----------------------------------------------------------------------*/