diff options
Diffstat (limited to 'drivers/hwmon/lm75.c')
-rw-r--r-- | drivers/hwmon/lm75.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index fc25b90ec24a..7c65b8bb6d72 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -112,6 +112,18 @@ static int lm75_attach_adapter(struct i2c_adapter *adapter) | |||
112 | return i2c_probe(adapter, &addr_data, lm75_detect); | 112 | return i2c_probe(adapter, &addr_data, lm75_detect); |
113 | } | 113 | } |
114 | 114 | ||
115 | static struct attribute *lm75_attributes[] = { | ||
116 | &dev_attr_temp1_input.attr, | ||
117 | &dev_attr_temp1_max.attr, | ||
118 | &dev_attr_temp1_max_hyst.attr, | ||
119 | |||
120 | NULL | ||
121 | }; | ||
122 | |||
123 | static const struct attribute_group lm75_group = { | ||
124 | .attrs = lm75_attributes, | ||
125 | }; | ||
126 | |||
115 | /* This function is called by i2c_probe */ | 127 | /* This function is called by i2c_probe */ |
116 | static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | 128 | static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) |
117 | { | 129 | { |
@@ -199,18 +211,19 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | |||
199 | lm75_init_client(new_client); | 211 | lm75_init_client(new_client); |
200 | 212 | ||
201 | /* Register sysfs hooks */ | 213 | /* Register sysfs hooks */ |
214 | if ((err = sysfs_create_group(&new_client->dev.kobj, &lm75_group))) | ||
215 | goto exit_detach; | ||
216 | |||
202 | data->class_dev = hwmon_device_register(&new_client->dev); | 217 | data->class_dev = hwmon_device_register(&new_client->dev); |
203 | if (IS_ERR(data->class_dev)) { | 218 | if (IS_ERR(data->class_dev)) { |
204 | err = PTR_ERR(data->class_dev); | 219 | err = PTR_ERR(data->class_dev); |
205 | goto exit_detach; | 220 | goto exit_remove; |
206 | } | 221 | } |
207 | 222 | ||
208 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | ||
209 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); | ||
210 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | ||
211 | |||
212 | return 0; | 223 | return 0; |
213 | 224 | ||
225 | exit_remove: | ||
226 | sysfs_remove_group(&new_client->dev.kobj, &lm75_group); | ||
214 | exit_detach: | 227 | exit_detach: |
215 | i2c_detach_client(new_client); | 228 | i2c_detach_client(new_client); |
216 | exit_free: | 229 | exit_free: |
@@ -223,6 +236,7 @@ static int lm75_detach_client(struct i2c_client *client) | |||
223 | { | 236 | { |
224 | struct lm75_data *data = i2c_get_clientdata(client); | 237 | struct lm75_data *data = i2c_get_clientdata(client); |
225 | hwmon_device_unregister(data->class_dev); | 238 | hwmon_device_unregister(data->class_dev); |
239 | sysfs_remove_group(&client->dev.kobj, &lm75_group); | ||
226 | i2c_detach_client(client); | 240 | i2c_detach_client(client); |
227 | kfree(data); | 241 | kfree(data); |
228 | return 0; | 242 | return 0; |