summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm63.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2014-04-04 18:01:33 +0200
committerJean Delvare <jdelvare@suse.de>2014-04-04 18:01:33 +0200
commitb76552b310645fddd76dad5e87d0e8eb3d15e4de (patch)
tree5b3cc60dcbdf289f8a09835cdbf06fdda3f7a9f9 /drivers/hwmon/lm63.c
parenthwmon: (lm63) Introduce 'dev' variable to point to client->dev (diff)
downloadlinux-b76552b310645fddd76dad5e87d0e8eb3d15e4de.tar.xz
linux-b76552b310645fddd76dad5e87d0e8eb3d15e4de.zip
hwmon: (lm63) Create all sysfs groups in one call
We can create all sysfs groups in one call by using sysfs_create_groups instead of using sysfs_create_group individually for each group. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Jean Delvare <jdelvare@suse.de>
Diffstat (limited to '')
-rw-r--r--drivers/hwmon/lm63.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index 55b7d98cb742..7dc4873b343f 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -157,6 +157,7 @@ enum chips { lm63, lm64, lm96163 };
struct lm63_data {
struct device *hwmon_dev;
struct mutex update_lock;
+ const struct attribute_group *groups[5];
char valid; /* zero until following fields are valid */
char lut_valid; /* zero until lut fields are valid */
unsigned long last_updated; /* in jiffies */
@@ -1116,6 +1117,7 @@ static int lm63_probe(struct i2c_client *client,
{
struct device *dev = &client->dev;
struct lm63_data *data;
+ int groups = 0;
int err;
data = devm_kzalloc(dev, sizeof(struct lm63_data), GFP_KERNEL);
@@ -1135,24 +1137,19 @@ static int lm63_probe(struct i2c_client *client,
lm63_init_client(client);
/* Register sysfs hooks */
- err = sysfs_create_group(&dev->kobj, &lm63_group);
- if (err)
- return err;
- if (data->config & 0x04) { /* tachometer enabled */
- err = sysfs_create_group(&dev->kobj, &lm63_group_fan1);
- if (err)
- goto exit_remove_files;
- }
- if (data->kind == lm96163) {
- err = sysfs_create_group(&dev->kobj, &lm63_group_temp2_type);
- if (err)
- goto exit_remove_files;
+ data->groups[groups++] = &lm63_group;
+ if (data->config & 0x04) /* tachometer enabled */
+ data->groups[groups++] = &lm63_group_fan1;
- err = sysfs_create_group(&dev->kobj, &lm63_group_extra_lut);
- if (err)
- goto exit_remove_files;
+ if (data->kind == lm96163) {
+ data->groups[groups++] = &lm63_group_temp2_type;
+ data->groups[groups++] = &lm63_group_extra_lut;
}
+ err = sysfs_create_groups(&dev->kobj, data->groups);
+ if (err)
+ return err;
+
data->hwmon_dev = hwmon_device_register(dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
@@ -1162,12 +1159,7 @@ static int lm63_probe(struct i2c_client *client,
return 0;
exit_remove_files:
- sysfs_remove_group(&dev->kobj, &lm63_group);
- sysfs_remove_group(&dev->kobj, &lm63_group_fan1);
- if (data->kind == lm96163) {
- sysfs_remove_group(&dev->kobj, &lm63_group_temp2_type);
- sysfs_remove_group(&dev->kobj, &lm63_group_extra_lut);
- }
+ sysfs_remove_groups(&dev->kobj, data->groups);
return err;
}
@@ -1176,13 +1168,7 @@ static int lm63_remove(struct i2c_client *client)
struct lm63_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev);
- sysfs_remove_group(&client->dev.kobj, &lm63_group);
- sysfs_remove_group(&client->dev.kobj, &lm63_group_fan1);
- if (data->kind == lm96163) {
- sysfs_remove_group(&client->dev.kobj, &lm63_group_temp2_type);
- sysfs_remove_group(&client->dev.kobj, &lm63_group_extra_lut);
- }
-
+ sysfs_remove_groups(&client->dev.kobj, data->groups);
return 0;
}