hwmon: (gl518sm) Don't create sysfs files
PATCH 2/5 hwmon: (gl518sm) Don't create sysfs files
The early revisions of the GL518SM do not report voltage values for the first 3 voltage channels. We should not create sysfs attributes for these missing features.
--- drivers/hwmon/gl518sm.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/hwmon/gl518sm.c +19 -4
@@ -336,9 +336,6 @@ static DEVICE_ATTR(beep_mask, S_IWUSR|S_ show_beep_mask, set_beep_mask);static struct attribute *gl518_attributes[] = { - &dev_attr_in0_input.attr, - &dev_attr_in1_input.attr, - &dev_attr_in2_input.attr, &dev_attr_in3_input.attr, &dev_attr_in0_min.attr, &dev_attr_in1_min.attr,
@@ -371,6 +368,17 @@ static const struct attribute_group gl51 .attrs = gl518_attributes, }; +static struct attribute *gl518_attributes_r80[] = { + &dev_attr_in0_input.attr, + &dev_attr_in1_input.attr, + &dev_attr_in2_input.attr, +NULL +}; + +static const struct attribute_group gl518_group_r80 = { + .attrs = gl518_attributes_r80, +}; +/* * Real code */
@@ -445,12 +453,15 @@ static int gl518_detect(struct i2c_adapt/* Initialize the GL518SM chip */ data->alarm_mask =0xff ; - data->voltage_in[0]Úta->voltage_in[1]Úta->voltage_in[2]=0;gl518_init_client (client);/* Register sysfs hooks */ if ((err =sysfs_create_group (&client->dev.kobj, &gl518_group))) goto exit_detach; +if (data->type = gl518sm_r80) +if ((err =sysfs_create_group (&client->dev.kobj, + &gl518_group_r80))) + goto exit_remove_files; data->hwmon_dev =hwmon_device_register (&client->dev);if (IS_ERR (data->hwmon_dev)) {
@@ -462,6 +473,8 @@ static int gl518_detect(struct i2c_adapt exit_remove_files:sysfs_remove_group (&client->dev.kobj, &gl518_group); +if (data->type = gl518sm_r80) +sysfs_remove_group (&client->dev.kobj, &gl518_group_r80); exit_detach:i2c_detach_client (client); exit_free:
@@ -496,6 +509,8 @@ static int gl518_detach_client(struct i2hwmon_device_unregister (data->hwmon_dev);sysfs_remove_group (&client->dev.kobj, &gl518_group); +if (data->type = gl518sm_r80) +sysfs_remove_group (&client->dev.kobj, &gl518_group_r80);if ((err =i2c_detach_client (client)))return err;
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 2/5] hwmon: (gl518sm) Don't create
Hi Jean:
Quoted 8 lines · Jean Delvare
The early revisions of the GL518SM do not report voltage values for the first 3 voltage channels. We should not create sysfs attributes for these missing features.
Signed-off-by Jean Delvare <[email protected]>--- drivers/hwmon/gl518sm.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
Applied to hwmon-2.6.git/testing, thanks. One minor comment though...
drivers/hwmon/gl518sm.c static int gl518_detach_client(struct i2 · line 516
Quoted 9 lines
drivers/hwmon/gl518sm.c +2
-0@@ -496,6 +509,8 @@ static int gl518_detach_client(struct i2hwmon_device_unregister (data->hwmon_dev);sysfs_remove_group (&client->dev.kobj, &gl518_group); +if (data->type = gl518sm_r80) +sysfs_remove_group (&client->dev.kobj, &gl518_group_r80);if ((err =i2c_detach_client (client)))return err;
Don't forget: you can do sysfs_remove_group() unconditionally.
Signature · 8 lines
Mark M. Hoffman [email protected] _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 2/5] hwmon: (gl518sm) Don't create sysfs
In reply to Jean DelvareHi Mark,
Quoted 19 lines · Mark M. Hoffman
Quoted 8 lines · Jean Delvare
The early revisions of the GL518SM do not report voltage values for the first 3 voltage channels. We should not create sysfs attributes for these missing features.
Signed-off-by Jean Delvare <[email protected]>--- drivers/hwmon/gl518sm.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)Applied to hwmon-2.6.git/testing, thanks. One minor comment though...
Quoted 7 lines
drivers/hwmon/gl518sm.c +2
-0@@ -496,6 +509,8 @@ static int gl518_detach_client(struct i2hwmon_device_unregister (data->hwmon_dev);sysfs_remove_group (&client->dev.kobj, &gl518_group); +if (data->type = gl518sm_r80) +sysfs_remove_group (&client->dev.kobj, &gl518_group_r80);
Quoted 4 lines
drivers/hwmon/gl518sm.c static int gl518_detach_client(struct i2 · line 516
Quoted 2 lines
drivers/hwmon/gl518sm.c +0
-0if ((err =i2c_detach_client (client)))return err;Don't forget: you can do
sysfs_remove_group()unconditionally.
Thanks for the review. I know that I could call sysfs_remove_group() unconditionally, and actually I do when it makes the code more simple (e.g. in error paths). However, in this case the condition is simple and it seems more efficient to skip the call to sysfs_remove_group() when we know it won't do anything.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors