aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm92.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm92.c')
-rw-r--r--drivers/hwmon/lm92.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index 197f77226dc4..30b536333f14 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -288,6 +288,23 @@ static int max6635_check(struct i2c_client *client)
288 return 1; 288 return 1;
289} 289}
290 290
291static struct attribute *lm92_attributes[] = {
292 &dev_attr_temp1_input.attr,
293 &dev_attr_temp1_crit.attr,
294 &dev_attr_temp1_crit_hyst.attr,
295 &dev_attr_temp1_min.attr,
296 &dev_attr_temp1_min_hyst.attr,
297 &dev_attr_temp1_max.attr,
298 &dev_attr_temp1_max_hyst.attr,
299 &dev_attr_alarms.attr,
300
301 NULL
302};
303
304static const struct attribute_group lm92_group = {
305 .attrs = lm92_attributes,
306};
307
291/* The following function does more than just detection. If detection 308/* The following function does more than just detection. If detection
292 succeeds, it also registers the new chip. */ 309 succeeds, it also registers the new chip. */
293static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) 310static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -359,23 +376,19 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
359 lm92_init_client(new_client); 376 lm92_init_client(new_client);
360 377
361 /* Register sysfs hooks */ 378 /* Register sysfs hooks */
379 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm92_group)))
380 goto exit_detach;
381
362 data->class_dev = hwmon_device_register(&new_client->dev); 382 data->class_dev = hwmon_device_register(&new_client->dev);
363 if (IS_ERR(data->class_dev)) { 383 if (IS_ERR(data->class_dev)) {
364 err = PTR_ERR(data->class_dev); 384 err = PTR_ERR(data->class_dev);
365 goto exit_detach; 385 goto exit_remove;
366 } 386 }
367 387
368 device_create_file(&new_client->dev, &dev_attr_temp1_input);
369 device_create_file(&new_client->dev, &dev_attr_temp1_crit);
370 device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst);
371 device_create_file(&new_client->dev, &dev_attr_temp1_min);
372 device_create_file(&new_client->dev, &dev_attr_temp1_min_hyst);
373 device_create_file(&new_client->dev, &dev_attr_temp1_max);
374 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
375 device_create_file(&new_client->dev, &dev_attr_alarms);
376
377 return 0; 388 return 0;
378 389
390exit_remove:
391 sysfs_remove_group(&new_client->dev.kobj, &lm92_group);
379exit_detach: 392exit_detach:
380 i2c_detach_client(new_client); 393 i2c_detach_client(new_client);
381exit_free: 394exit_free:
@@ -397,6 +410,7 @@ static int lm92_detach_client(struct i2c_client *client)
397 int err; 410 int err;
398 411
399 hwmon_device_unregister(data->class_dev); 412 hwmon_device_unregister(data->class_dev);
413 sysfs_remove_group(&client->dev.kobj, &lm92_group);
400 414
401 if ((err = i2c_detach_client(client))) 415 if ((err = i2c_detach_client(client)))
402 return err; 416 return err;