diff options
author | Guenter Roeck <linux@roeck-us.net> | 2014-02-16 16:23:25 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2014-03-03 11:01:05 -0500 |
commit | 1075305de47d8ebf909acd3d52cade78b9e8f160 (patch) | |
tree | ed0600bed361f523fd5cabdceef0f40e77d776fc /drivers/hwmon | |
parent | 4fa6cbb1b88b647a37776a50ee31e68c30732345 (diff) |
hwmon: (coretemp) Use sysfs_create_group to create sysfs attributes
Instead of creating each attribute individually, use sysfs_create_group
to create all attributes for one core with a single call.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/coretemp.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index bbb0b0d463f7..3f87db26433d 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c | |||
@@ -94,6 +94,8 @@ struct temp_data { | |||
94 | bool valid; | 94 | bool valid; |
95 | struct sensor_device_attribute sd_attrs[TOTAL_ATTRS]; | 95 | struct sensor_device_attribute sd_attrs[TOTAL_ATTRS]; |
96 | char attr_name[TOTAL_ATTRS][CORETEMP_NAME_LENGTH]; | 96 | char attr_name[TOTAL_ATTRS][CORETEMP_NAME_LENGTH]; |
97 | struct attribute *attrs[TOTAL_ATTRS + 1]; | ||
98 | struct attribute_group attr_group; | ||
97 | struct mutex update_lock; | 99 | struct mutex update_lock; |
98 | }; | 100 | }; |
99 | 101 | ||
@@ -406,7 +408,7 @@ static int create_name_attr(struct platform_data *pdata, | |||
406 | static int create_core_attrs(struct temp_data *tdata, struct device *dev, | 408 | static int create_core_attrs(struct temp_data *tdata, struct device *dev, |
407 | int attr_no) | 409 | int attr_no) |
408 | { | 410 | { |
409 | int err, i; | 411 | int i; |
410 | static ssize_t (*const rd_ptr[TOTAL_ATTRS]) (struct device *dev, | 412 | static ssize_t (*const rd_ptr[TOTAL_ATTRS]) (struct device *dev, |
411 | struct device_attribute *devattr, char *buf) = { | 413 | struct device_attribute *devattr, char *buf) = { |
412 | show_label, show_crit_alarm, show_temp, show_tjmax, | 414 | show_label, show_crit_alarm, show_temp, show_tjmax, |
@@ -424,16 +426,10 @@ static int create_core_attrs(struct temp_data *tdata, struct device *dev, | |||
424 | tdata->sd_attrs[i].dev_attr.attr.mode = S_IRUGO; | 426 | tdata->sd_attrs[i].dev_attr.attr.mode = S_IRUGO; |
425 | tdata->sd_attrs[i].dev_attr.show = rd_ptr[i]; | 427 | tdata->sd_attrs[i].dev_attr.show = rd_ptr[i]; |
426 | tdata->sd_attrs[i].index = attr_no; | 428 | tdata->sd_attrs[i].index = attr_no; |
427 | err = device_create_file(dev, &tdata->sd_attrs[i].dev_attr); | 429 | tdata->attrs[i] = &tdata->sd_attrs[i].dev_attr.attr; |
428 | if (err) | ||
429 | goto exit_free; | ||
430 | } | 430 | } |
431 | return 0; | 431 | tdata->attr_group.attrs = tdata->attrs; |
432 | 432 | return sysfs_create_group(&dev->kobj, &tdata->attr_group); | |
433 | exit_free: | ||
434 | while (--i >= 0) | ||
435 | device_remove_file(dev, &tdata->sd_attrs[i].dev_attr); | ||
436 | return err; | ||
437 | } | 433 | } |
438 | 434 | ||
439 | 435 | ||
@@ -575,12 +571,10 @@ static void coretemp_add_core(unsigned int cpu, int pkg_flag) | |||
575 | static void coretemp_remove_core(struct platform_data *pdata, | 571 | static void coretemp_remove_core(struct platform_data *pdata, |
576 | struct device *dev, int indx) | 572 | struct device *dev, int indx) |
577 | { | 573 | { |
578 | int i; | ||
579 | struct temp_data *tdata = pdata->core_data[indx]; | 574 | struct temp_data *tdata = pdata->core_data[indx]; |
580 | 575 | ||
581 | /* Remove the sysfs attributes */ | 576 | /* Remove the sysfs attributes */ |
582 | for (i = 0; i < tdata->attr_size; i++) | 577 | sysfs_remove_group(&dev->kobj, &tdata->attr_group); |
583 | device_remove_file(dev, &tdata->sd_attrs[i].dev_attr); | ||
584 | 578 | ||
585 | kfree(pdata->core_data[indx]); | 579 | kfree(pdata->core_data[indx]); |
586 | pdata->core_data[indx] = NULL; | 580 | pdata->core_data[indx] = NULL; |