aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm63.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2006-09-24 15:16:40 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-28 18:31:18 -0400
commit0e39e01c908fdc498fff0d788fd7b955ab75ebb6 (patch)
tree2e117466ec9a60f3dac6d678e95af97454aa6c8c /drivers/hwmon/lm63.c
parent681c6f7a6702f208d48b501c8829dbc03a2ca238 (diff)
hwmon: Fix unchecked return status, batch 4
hwmon: Fix unchecked return status, batch 4 Fix up some hwmon drivers so that they no longer ignore return status from device_create_file(). Note: f71805f actually checked the status from device_create_file already. However it did not remove the files on device destruction. It was also an opportunity to use sysfs_create/remove_group instead of hand-made loops. This makes the changes much more important but I think the result is worth it. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/lm63.c')
-rw-r--r--drivers/hwmon/lm63.c89
1 files changed, 52 insertions, 37 deletions
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index 00a50bea7cbd..d69f3cf07122 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -46,6 +46,7 @@
46#include <linux/hwmon.h> 46#include <linux/hwmon.h>
47#include <linux/err.h> 47#include <linux/err.h>
48#include <linux/mutex.h> 48#include <linux/mutex.h>
49#include <linux/sysfs.h>
49 50
50/* 51/*
51 * Addresses to scan 52 * Addresses to scan
@@ -370,6 +371,42 @@ static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);
370/* Raw alarm file for compatibility */ 371/* Raw alarm file for compatibility */
371static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 372static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
372 373
374static struct attribute *lm63_attributes[] = {
375 &dev_attr_pwm1.attr,
376 &dev_attr_pwm1_enable.attr,
377 &sensor_dev_attr_temp1_input.dev_attr.attr,
378 &sensor_dev_attr_temp2_input.dev_attr.attr,
379 &sensor_dev_attr_temp2_min.dev_attr.attr,
380 &sensor_dev_attr_temp1_max.dev_attr.attr,
381 &sensor_dev_attr_temp2_max.dev_attr.attr,
382 &sensor_dev_attr_temp2_crit.dev_attr.attr,
383 &dev_attr_temp2_crit_hyst.attr,
384
385 &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr,
386 &sensor_dev_attr_temp2_input_fault.dev_attr.attr,
387 &sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
388 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
389 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
390 &dev_attr_alarms.attr,
391 NULL
392};
393
394static const struct attribute_group lm63_group = {
395 .attrs = lm63_attributes,
396};
397
398static struct attribute *lm63_attributes_fan1[] = {
399 &sensor_dev_attr_fan1_input.dev_attr.attr,
400 &sensor_dev_attr_fan1_min.dev_attr.attr,
401
402 &sensor_dev_attr_fan1_min_alarm.dev_attr.attr,
403 NULL
404};
405
406static const struct attribute_group lm63_group_fan1 = {
407 .attrs = lm63_attributes_fan1,
408};
409
373/* 410/*
374 * Real code 411 * Real code
375 */ 412 */
@@ -456,50 +493,26 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
456 lm63_init_client(new_client); 493 lm63_init_client(new_client);
457 494
458 /* Register sysfs hooks */ 495 /* Register sysfs hooks */
459 data->class_dev = hwmon_device_register(&new_client->dev); 496 if ((err = sysfs_create_group(&new_client->dev.kobj,
460 if (IS_ERR(data->class_dev)) { 497 &lm63_group)))
461 err = PTR_ERR(data->class_dev);
462 goto exit_detach; 498 goto exit_detach;
499 if (data->config & 0x04) { /* tachometer enabled */
500 if ((err = sysfs_create_group(&new_client->dev.kobj,
501 &lm63_group_fan1)))
502 goto exit_remove_files;
463 } 503 }
464 504
465 if (data->config & 0x04) { /* tachometer enabled */ 505 data->class_dev = hwmon_device_register(&new_client->dev);
466 device_create_file(&new_client->dev, 506 if (IS_ERR(data->class_dev)) {
467 &sensor_dev_attr_fan1_input.dev_attr); 507 err = PTR_ERR(data->class_dev);
468 device_create_file(&new_client->dev, 508 goto exit_remove_files;
469 &sensor_dev_attr_fan1_min.dev_attr);
470 device_create_file(&new_client->dev,
471 &sensor_dev_attr_fan1_min_alarm.dev_attr);
472 } 509 }
473 device_create_file(&new_client->dev, &dev_attr_pwm1);
474 device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
475 device_create_file(&new_client->dev,
476 &sensor_dev_attr_temp1_input.dev_attr);
477 device_create_file(&new_client->dev,
478 &sensor_dev_attr_temp2_input.dev_attr);
479 device_create_file(&new_client->dev,
480 &sensor_dev_attr_temp2_min.dev_attr);
481 device_create_file(&new_client->dev,
482 &sensor_dev_attr_temp1_max.dev_attr);
483 device_create_file(&new_client->dev,
484 &sensor_dev_attr_temp2_max.dev_attr);
485 device_create_file(&new_client->dev,
486 &sensor_dev_attr_temp2_crit.dev_attr);
487 device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst);
488
489 device_create_file(&new_client->dev,
490 &sensor_dev_attr_temp2_input_fault.dev_attr);
491 device_create_file(&new_client->dev,
492 &sensor_dev_attr_temp2_min_alarm.dev_attr);
493 device_create_file(&new_client->dev,
494 &sensor_dev_attr_temp1_max_alarm.dev_attr);
495 device_create_file(&new_client->dev,
496 &sensor_dev_attr_temp2_max_alarm.dev_attr);
497 device_create_file(&new_client->dev,
498 &sensor_dev_attr_temp2_crit_alarm.dev_attr);
499 device_create_file(&new_client->dev, &dev_attr_alarms);
500 510
501 return 0; 511 return 0;
502 512
513exit_remove_files:
514 sysfs_remove_group(&new_client->dev.kobj, &lm63_group);
515 sysfs_remove_group(&new_client->dev.kobj, &lm63_group_fan1);
503exit_detach: 516exit_detach:
504 i2c_detach_client(new_client); 517 i2c_detach_client(new_client);
505exit_free: 518exit_free:
@@ -549,6 +562,8 @@ static int lm63_detach_client(struct i2c_client *client)
549 int err; 562 int err;
550 563
551 hwmon_device_unregister(data->class_dev); 564 hwmon_device_unregister(data->class_dev);
565 sysfs_remove_group(&client->dev.kobj, &lm63_group);
566 sysfs_remove_group(&client->dev.kobj, &lm63_group_fan1);
552 567
553 if ((err = i2c_detach_client(client))) 568 if ((err = i2c_detach_client(client)))
554 return err; 569 return err;