Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (lm78) use permission-specific DEVICE_ATTR variants

Use DEVICE_ATTR_RO for read only attributes and 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>

authored by

Julia Lawall and committed by
Guenter Roeck
eabb6f15 e33110d0

+19 -19
+19 -19
drivers/hwmon/lm78.c
··· 236 236 show_in_offset(6); 237 237 238 238 /* Temperature */ 239 - static ssize_t show_temp(struct device *dev, struct device_attribute *da, 240 - char *buf) 239 + static ssize_t temp1_input_show(struct device *dev, 240 + struct device_attribute *da, char *buf) 241 241 { 242 242 struct lm78_data *data = lm78_update_device(dev); 243 243 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); 244 244 } 245 245 246 - static ssize_t show_temp_over(struct device *dev, struct device_attribute *da, 246 + static ssize_t temp1_max_show(struct device *dev, struct device_attribute *da, 247 247 char *buf) 248 248 { 249 249 struct lm78_data *data = lm78_update_device(dev); 250 250 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); 251 251 } 252 252 253 - static ssize_t set_temp_over(struct device *dev, struct device_attribute *da, 254 - const char *buf, size_t count) 253 + static ssize_t temp1_max_store(struct device *dev, 254 + struct device_attribute *da, const char *buf, 255 + size_t count) 255 256 { 256 257 struct lm78_data *data = dev_get_drvdata(dev); 257 258 long val; ··· 269 268 return count; 270 269 } 271 270 272 - static ssize_t show_temp_hyst(struct device *dev, struct device_attribute *da, 273 - char *buf) 271 + static ssize_t temp1_max_hyst_show(struct device *dev, 272 + struct device_attribute *da, char *buf) 274 273 { 275 274 struct lm78_data *data = lm78_update_device(dev); 276 275 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst)); 277 276 } 278 277 279 - static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *da, 280 - const char *buf, size_t count) 278 + static ssize_t temp1_max_hyst_store(struct device *dev, 279 + struct device_attribute *da, 280 + const char *buf, size_t count) 281 281 { 282 282 struct lm78_data *data = dev_get_drvdata(dev); 283 283 long val; ··· 295 293 return count; 296 294 } 297 295 298 - static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); 299 - static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, 300 - show_temp_over, set_temp_over); 301 - static DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, 302 - show_temp_hyst, set_temp_hyst); 296 + static DEVICE_ATTR_RO(temp1_input); 297 + static DEVICE_ATTR_RW(temp1_max); 298 + static DEVICE_ATTR_RW(temp1_max_hyst); 303 299 304 300 /* 3 Fans */ 305 301 static ssize_t show_fan(struct device *dev, struct device_attribute *da, ··· 431 431 static SENSOR_DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2); 432 432 433 433 /* VID */ 434 - static ssize_t show_vid(struct device *dev, struct device_attribute *da, 435 - char *buf) 434 + static ssize_t cpu0_vid_show(struct device *dev, struct device_attribute *da, 435 + char *buf) 436 436 { 437 437 struct lm78_data *data = lm78_update_device(dev); 438 438 return sprintf(buf, "%d\n", vid_from_reg(data->vid, 82)); 439 439 } 440 - static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); 440 + static DEVICE_ATTR_RO(cpu0_vid); 441 441 442 442 /* Alarms */ 443 - static ssize_t show_alarms(struct device *dev, struct device_attribute *da, 443 + static ssize_t alarms_show(struct device *dev, struct device_attribute *da, 444 444 char *buf) 445 445 { 446 446 struct lm78_data *data = lm78_update_device(dev); 447 447 return sprintf(buf, "%u\n", data->alarms); 448 448 } 449 - static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 449 + static DEVICE_ATTR_RO(alarms); 450 450 451 451 static ssize_t show_alarm(struct device *dev, struct device_attribute *da, 452 452 char *buf)