aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/smsc47m1.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2006-09-24 15:25:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-28 18:31:19 -0400
commitce8c6ce1eceecfe090f6c1aa4108087b2051497b (patch)
treea119733f9fb1772f7c2436761fbbbe805b5f46fd /drivers/hwmon/smsc47m1.c
parenta5ebe668add5f76ed8f01f752b37cfa164a26a30 (diff)
hwmon: Fix unchecked return status, SMSC chips
hwmon: Fix unchecked return status, SMSC chips Fix up 2 more hwmon drivers so that they no longer ignore return status from device_create_file(). Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/smsc47m1.c')
-rw-r--r--drivers/hwmon/smsc47m1.c78
1 files changed, 60 insertions, 18 deletions
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 9cd28f2709fc..47132fd26b1b 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -35,6 +35,7 @@
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/mutex.h> 37#include <linux/mutex.h>
38#include <linux/sysfs.h>
38#include <asm/io.h> 39#include <asm/io.h>
39 40
40/* Address is autodetected, there is no default value */ 41/* Address is autodetected, there is no default value */
@@ -347,6 +348,30 @@ fan_present(2);
347 348
348static DEVICE_ATTR(alarms, S_IRUGO, get_alarms, NULL); 349static DEVICE_ATTR(alarms, S_IRUGO, get_alarms, NULL);
349 350
351/* Almost all sysfs files may or may not be created depending on the chip
352 setup so we create them individually. It is still convenient to define a
353 group to remove them all at once. */
354static struct attribute *smsc47m1_attributes[] = {
355 &dev_attr_fan1_input.attr,
356 &dev_attr_fan1_min.attr,
357 &dev_attr_fan1_div.attr,
358 &dev_attr_fan2_input.attr,
359 &dev_attr_fan2_min.attr,
360 &dev_attr_fan2_div.attr,
361
362 &dev_attr_pwm1.attr,
363 &dev_attr_pwm1_enable.attr,
364 &dev_attr_pwm2.attr,
365 &dev_attr_pwm2_enable.attr,
366
367 &dev_attr_alarms.attr,
368 NULL
369};
370
371static const struct attribute_group smsc47m1_group = {
372 .attrs = smsc47m1_attributes,
373};
374
350static int __init smsc47m1_find(unsigned short *addr) 375static int __init smsc47m1_find(unsigned short *addr)
351{ 376{
352 u8 val; 377 u8 val;
@@ -447,46 +472,62 @@ static int smsc47m1_detect(struct i2c_adapter *adapter)
447 smsc47m1_update_device(&new_client->dev, 1); 472 smsc47m1_update_device(&new_client->dev, 1);
448 473
449 /* Register sysfs hooks */ 474 /* Register sysfs hooks */
450 data->class_dev = hwmon_device_register(&new_client->dev);
451 if (IS_ERR(data->class_dev)) {
452 err = PTR_ERR(data->class_dev);
453 goto error_detach;
454 }
455
456 if (fan1) { 475 if (fan1) {
457 device_create_file(&new_client->dev, &dev_attr_fan1_input); 476 if ((err = device_create_file(&new_client->dev,
458 device_create_file(&new_client->dev, &dev_attr_fan1_min); 477 &dev_attr_fan1_input))
459 device_create_file(&new_client->dev, &dev_attr_fan1_div); 478 || (err = device_create_file(&new_client->dev,
479 &dev_attr_fan1_min))
480 || (err = device_create_file(&new_client->dev,
481 &dev_attr_fan1_div)))
482 goto error_remove_files;
460 } else 483 } else
461 dev_dbg(&new_client->dev, "Fan 1 not enabled by hardware, " 484 dev_dbg(&new_client->dev, "Fan 1 not enabled by hardware, "
462 "skipping\n"); 485 "skipping\n");
463 486
464 if (fan2) { 487 if (fan2) {
465 device_create_file(&new_client->dev, &dev_attr_fan2_input); 488 if ((err = device_create_file(&new_client->dev,
466 device_create_file(&new_client->dev, &dev_attr_fan2_min); 489 &dev_attr_fan2_input))
467 device_create_file(&new_client->dev, &dev_attr_fan2_div); 490 || (err = device_create_file(&new_client->dev,
491 &dev_attr_fan2_min))
492 || (err = device_create_file(&new_client->dev,
493 &dev_attr_fan2_div)))
494 goto error_remove_files;
468 } else 495 } else
469 dev_dbg(&new_client->dev, "Fan 2 not enabled by hardware, " 496 dev_dbg(&new_client->dev, "Fan 2 not enabled by hardware, "
470 "skipping\n"); 497 "skipping\n");
471 498
472 if (pwm1) { 499 if (pwm1) {
473 device_create_file(&new_client->dev, &dev_attr_pwm1); 500 if ((err = device_create_file(&new_client->dev,
474 device_create_file(&new_client->dev, &dev_attr_pwm1_enable); 501 &dev_attr_pwm1))
502 || (err = device_create_file(&new_client->dev,
503 &dev_attr_pwm1_enable)))
504 goto error_remove_files;
475 } else 505 } else
476 dev_dbg(&new_client->dev, "PWM 1 not enabled by hardware, " 506 dev_dbg(&new_client->dev, "PWM 1 not enabled by hardware, "
477 "skipping\n"); 507 "skipping\n");
478 if (pwm2) { 508 if (pwm2) {
479 device_create_file(&new_client->dev, &dev_attr_pwm2); 509 if ((err = device_create_file(&new_client->dev,
480 device_create_file(&new_client->dev, &dev_attr_pwm2_enable); 510 &dev_attr_pwm2))
511 || (err = device_create_file(&new_client->dev,
512 &dev_attr_pwm2_enable)))
513 goto error_remove_files;
481 } else 514 } else
482 dev_dbg(&new_client->dev, "PWM 2 not enabled by hardware, " 515 dev_dbg(&new_client->dev, "PWM 2 not enabled by hardware, "
483 "skipping\n"); 516 "skipping\n");
484 517
485 device_create_file(&new_client->dev, &dev_attr_alarms); 518 if ((err = device_create_file(&new_client->dev, &dev_attr_alarms)))
519 goto error_remove_files;
520
521 data->class_dev = hwmon_device_register(&new_client->dev);
522 if (IS_ERR(data->class_dev)) {
523 err = PTR_ERR(data->class_dev);
524 goto error_remove_files;
525 }
486 526
487 return 0; 527 return 0;
488 528
489error_detach: 529error_remove_files:
530 sysfs_remove_group(&new_client->dev.kobj, &smsc47m1_group);
490 i2c_detach_client(new_client); 531 i2c_detach_client(new_client);
491error_free: 532error_free:
492 kfree(data); 533 kfree(data);
@@ -501,6 +542,7 @@ static int smsc47m1_detach_client(struct i2c_client *client)
501 int err; 542 int err;
502 543
503 hwmon_device_unregister(data->class_dev); 544 hwmon_device_unregister(data->class_dev);
545 sysfs_remove_group(&client->dev.kobj, &smsc47m1_group);
504 546
505 if ((err = i2c_detach_client(client))) 547 if ((err = i2c_detach_client(client)))
506 return err; 548 return err;