Skip to content

Commit

Permalink
hwmon: (gl518sm) Don't create sysfs files for missing features
Browse files Browse the repository at this point in the history
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 <khali@linux-fr.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
  • Loading branch information
Jean Delvare authored and Mark M. Hoffman committed Feb 8, 2008
1 parent a5955ed commit 5314f5c
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions drivers/hwmon/gl518sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,6 @@ static DEVICE_ATTR(beep_mask, S_IWUSR|S_IRUGO,
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,
Expand Down Expand Up @@ -371,6 +368,17 @@ static const struct attribute_group gl518_group = {
.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
*/
Expand Down Expand Up @@ -445,12 +453,15 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)

/* Initialize the GL518SM chip */
data->alarm_mask = 0xff;
data->voltage_in[0]=data->voltage_in[1]=data->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)) {
Expand All @@ -462,6 +473,8 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)

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:
Expand Down Expand Up @@ -496,6 +509,8 @@ static int gl518_detach_client(struct i2c_client *client)

hwmon_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;
Expand Down

0 comments on commit 5314f5c

Please sign in to comment.