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

hwmon: (sis5595) 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
feaf8bd4 af3d387f

+18 -18
+18 -18
drivers/hwmon/sis5595.c
··· 304 304 show_in_offset(4); 305 305 306 306 /* Temperature */ 307 - static ssize_t show_temp(struct device *dev, struct device_attribute *attr, 308 - char *buf) 307 + static ssize_t temp1_input_show(struct device *dev, 308 + struct device_attribute *attr, char *buf) 309 309 { 310 310 struct sis5595_data *data = sis5595_update_device(dev); 311 311 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); 312 312 } 313 313 314 - static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, 314 + static ssize_t temp1_max_show(struct device *dev, struct device_attribute *attr, 315 315 char *buf) 316 316 { 317 317 struct sis5595_data *data = sis5595_update_device(dev); 318 318 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); 319 319 } 320 320 321 - static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, 322 - const char *buf, size_t count) 321 + static ssize_t temp1_max_store(struct device *dev, 322 + struct device_attribute *attr, const char *buf, 323 + size_t count) 323 324 { 324 325 struct sis5595_data *data = dev_get_drvdata(dev); 325 326 long val; ··· 337 336 return count; 338 337 } 339 338 340 - static ssize_t show_temp_hyst(struct device *dev, struct device_attribute *attr, 341 - char *buf) 339 + static ssize_t temp1_max_hyst_show(struct device *dev, 340 + struct device_attribute *attr, char *buf) 342 341 { 343 342 struct sis5595_data *data = sis5595_update_device(dev); 344 343 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst)); 345 344 } 346 345 347 - static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, 348 - const char *buf, size_t count) 346 + static ssize_t temp1_max_hyst_store(struct device *dev, 347 + struct device_attribute *attr, 348 + const char *buf, size_t count) 349 349 { 350 350 struct sis5595_data *data = dev_get_drvdata(dev); 351 351 long val; ··· 363 361 return count; 364 362 } 365 363 366 - static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); 367 - static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, 368 - show_temp_over, set_temp_over); 369 - static DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, 370 - show_temp_hyst, set_temp_hyst); 364 + static DEVICE_ATTR_RO(temp1_input); 365 + static DEVICE_ATTR_RW(temp1_max); 366 + static DEVICE_ATTR_RW(temp1_max_hyst); 371 367 372 368 /* 2 Fans */ 373 369 static ssize_t show_fan(struct device *dev, struct device_attribute *da, ··· 492 492 show_fan_offset(2); 493 493 494 494 /* Alarms */ 495 - static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, 495 + static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, 496 496 char *buf) 497 497 { 498 498 struct sis5595_data *data = sis5595_update_device(dev); 499 499 return sprintf(buf, "%d\n", data->alarms); 500 500 } 501 - static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 501 + static DEVICE_ATTR_RO(alarms); 502 502 503 503 static ssize_t show_alarm(struct device *dev, struct device_attribute *da, 504 504 char *buf) ··· 516 516 static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7); 517 517 static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 15); 518 518 519 - static ssize_t show_name(struct device *dev, struct device_attribute *attr, 519 + static ssize_t name_show(struct device *dev, struct device_attribute *attr, 520 520 char *buf) 521 521 { 522 522 struct sis5595_data *data = dev_get_drvdata(dev); 523 523 return sprintf(buf, "%s\n", data->name); 524 524 } 525 - static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 525 + static DEVICE_ATTR_RO(name); 526 526 527 527 static struct attribute *sis5595_attributes[] = { 528 528 &sensor_dev_attr_in0_input.dev_attr.attr,