summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2016-12-22 07:04:37 -0500
committerGuenter Roeck <linux@roeck-us.net>2017-01-02 13:19:45 -0500
commit0acf2a5f2a630754120a9951976ea5bf3f7b6d8f (patch)
treef6eaac0c69a1ae88ff71a19d8f5850f5af19f823
parent82e73f7f9538773705dfd8b019760884a695653f (diff)
hwmon: (atxp1) use permission-specific DEVICE_ATTR variants
Use DEVICE_ATTR_RW for read/write attributes. This simplifies the source code, improves readbility, and reduces the chance of inconsistencies. The conversion was done automatically using coccinelle. It was validated by compiling both the old and the new source code and comparing its text, data, and bss size. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> [groeck: Updated description] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/atxp1.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c
index f2f2f2fc755a..b7eadb54c8cb 100644
--- a/drivers/hwmon/atxp1.c
+++ b/drivers/hwmon/atxp1.c
@@ -81,8 +81,8 @@ static struct atxp1_data *atxp1_update_device(struct device *dev)
81} 81}
82 82
83/* sys file functions for cpu0_vid */ 83/* sys file functions for cpu0_vid */
84static ssize_t atxp1_showvcore(struct device *dev, 84static ssize_t cpu0_vid_show(struct device *dev,
85 struct device_attribute *attr, char *buf) 85 struct device_attribute *attr, char *buf)
86{ 86{
87 int size; 87 int size;
88 struct atxp1_data *data; 88 struct atxp1_data *data;
@@ -95,9 +95,9 @@ static ssize_t atxp1_showvcore(struct device *dev,
95 return size; 95 return size;
96} 96}
97 97
98static ssize_t atxp1_storevcore(struct device *dev, 98static ssize_t cpu0_vid_store(struct device *dev,
99 struct device_attribute *attr, 99 struct device_attribute *attr, const char *buf,
100 const char *buf, size_t count) 100 size_t count)
101{ 101{
102 struct atxp1_data *data = atxp1_update_device(dev); 102 struct atxp1_data *data = atxp1_update_device(dev);
103 struct i2c_client *client = data->client; 103 struct i2c_client *client = data->client;
@@ -154,12 +154,11 @@ static ssize_t atxp1_storevcore(struct device *dev,
154 * CPU core reference voltage 154 * CPU core reference voltage
155 * unit: millivolt 155 * unit: millivolt
156 */ 156 */
157static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore, 157static DEVICE_ATTR_RW(cpu0_vid);
158 atxp1_storevcore);
159 158
160/* sys file functions for GPIO1 */ 159/* sys file functions for GPIO1 */
161static ssize_t atxp1_showgpio1(struct device *dev, 160static ssize_t gpio1_show(struct device *dev, struct device_attribute *attr,
162 struct device_attribute *attr, char *buf) 161 char *buf)
163{ 162{
164 int size; 163 int size;
165 struct atxp1_data *data; 164 struct atxp1_data *data;
@@ -171,9 +170,8 @@ static ssize_t atxp1_showgpio1(struct device *dev,
171 return size; 170 return size;
172} 171}
173 172
174static ssize_t atxp1_storegpio1(struct device *dev, 173static ssize_t gpio1_store(struct device *dev, struct device_attribute *attr,
175 struct device_attribute *attr, const char *buf, 174 const char *buf, size_t count)
176 size_t count)
177{ 175{
178 struct atxp1_data *data = atxp1_update_device(dev); 176 struct atxp1_data *data = atxp1_update_device(dev);
179 struct i2c_client *client = data->client; 177 struct i2c_client *client = data->client;
@@ -201,11 +199,11 @@ static ssize_t atxp1_storegpio1(struct device *dev,
201 * GPIO1 data register 199 * GPIO1 data register
202 * unit: Four bit as hex (e.g. 0x0f) 200 * unit: Four bit as hex (e.g. 0x0f)
203 */ 201 */
204static DEVICE_ATTR(gpio1, S_IRUGO | S_IWUSR, atxp1_showgpio1, atxp1_storegpio1); 202static DEVICE_ATTR_RW(gpio1);
205 203
206/* sys file functions for GPIO2 */ 204/* sys file functions for GPIO2 */
207static ssize_t atxp1_showgpio2(struct device *dev, 205static ssize_t gpio2_show(struct device *dev, struct device_attribute *attr,
208 struct device_attribute *attr, char *buf) 206 char *buf)
209{ 207{
210 int size; 208 int size;
211 struct atxp1_data *data; 209 struct atxp1_data *data;
@@ -217,9 +215,8 @@ static ssize_t atxp1_showgpio2(struct device *dev,
217 return size; 215 return size;
218} 216}
219 217
220static ssize_t atxp1_storegpio2(struct device *dev, 218static ssize_t gpio2_store(struct device *dev, struct device_attribute *attr,
221 struct device_attribute *attr, 219 const char *buf, size_t count)
222 const char *buf, size_t count)
223{ 220{
224 struct atxp1_data *data = atxp1_update_device(dev); 221 struct atxp1_data *data = atxp1_update_device(dev);
225 struct i2c_client *client = data->client; 222 struct i2c_client *client = data->client;
@@ -246,7 +243,7 @@ static ssize_t atxp1_storegpio2(struct device *dev,
246 * GPIO2 data register 243 * GPIO2 data register
247 * unit: Eight bit as hex (e.g. 0xff) 244 * unit: Eight bit as hex (e.g. 0xff)
248 */ 245 */
249static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); 246static DEVICE_ATTR_RW(gpio2);
250 247
251static struct attribute *atxp1_attrs[] = { 248static struct attribute *atxp1_attrs[] = {
252 &dev_attr_gpio1.attr, 249 &dev_attr_gpio1.attr,