aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
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
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')
-rw-r--r--drivers/hwmon/smsc47m1.c78
-rw-r--r--drivers/hwmon/smsc47m192.c150
2 files changed, 145 insertions, 83 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;
diff --git a/drivers/hwmon/smsc47m192.c b/drivers/hwmon/smsc47m192.c
index bdc4570acf9a..a6833f437395 100644
--- a/drivers/hwmon/smsc47m192.c
+++ b/drivers/hwmon/smsc47m192.c
@@ -30,6 +30,7 @@
30#include <linux/hwmon-sysfs.h> 30#include <linux/hwmon-sysfs.h>
31#include <linux/hwmon-vid.h> 31#include <linux/hwmon-vid.h>
32#include <linux/err.h> 32#include <linux/err.h>
33#include <linux/sysfs.h>
33 34
34/* Addresses to scan */ 35/* Addresses to scan */
35static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; 36static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
@@ -370,6 +371,75 @@ static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 0x0200);
370static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 0x0400); 371static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 0x0400);
371static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 0x0800); 372static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 0x0800);
372 373
374static struct attribute *smsc47m192_attributes[] = {
375 &sensor_dev_attr_in0_input.dev_attr.attr,
376 &sensor_dev_attr_in0_min.dev_attr.attr,
377 &sensor_dev_attr_in0_max.dev_attr.attr,
378 &sensor_dev_attr_in0_alarm.dev_attr.attr,
379 &sensor_dev_attr_in1_input.dev_attr.attr,
380 &sensor_dev_attr_in1_min.dev_attr.attr,
381 &sensor_dev_attr_in1_max.dev_attr.attr,
382 &sensor_dev_attr_in1_alarm.dev_attr.attr,
383 &sensor_dev_attr_in2_input.dev_attr.attr,
384 &sensor_dev_attr_in2_min.dev_attr.attr,
385 &sensor_dev_attr_in2_max.dev_attr.attr,
386 &sensor_dev_attr_in2_alarm.dev_attr.attr,
387 &sensor_dev_attr_in3_input.dev_attr.attr,
388 &sensor_dev_attr_in3_min.dev_attr.attr,
389 &sensor_dev_attr_in3_max.dev_attr.attr,
390 &sensor_dev_attr_in3_alarm.dev_attr.attr,
391 &sensor_dev_attr_in5_input.dev_attr.attr,
392 &sensor_dev_attr_in5_min.dev_attr.attr,
393 &sensor_dev_attr_in5_max.dev_attr.attr,
394 &sensor_dev_attr_in5_alarm.dev_attr.attr,
395 &sensor_dev_attr_in6_input.dev_attr.attr,
396 &sensor_dev_attr_in6_min.dev_attr.attr,
397 &sensor_dev_attr_in6_max.dev_attr.attr,
398 &sensor_dev_attr_in6_alarm.dev_attr.attr,
399 &sensor_dev_attr_in7_input.dev_attr.attr,
400 &sensor_dev_attr_in7_min.dev_attr.attr,
401 &sensor_dev_attr_in7_max.dev_attr.attr,
402 &sensor_dev_attr_in7_alarm.dev_attr.attr,
403
404 &sensor_dev_attr_temp1_input.dev_attr.attr,
405 &sensor_dev_attr_temp1_max.dev_attr.attr,
406 &sensor_dev_attr_temp1_min.dev_attr.attr,
407 &sensor_dev_attr_temp1_offset.dev_attr.attr,
408 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
409 &sensor_dev_attr_temp2_input.dev_attr.attr,
410 &sensor_dev_attr_temp2_max.dev_attr.attr,
411 &sensor_dev_attr_temp2_min.dev_attr.attr,
412 &sensor_dev_attr_temp2_offset.dev_attr.attr,
413 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
414 &sensor_dev_attr_temp2_input_fault.dev_attr.attr,
415 &sensor_dev_attr_temp3_input.dev_attr.attr,
416 &sensor_dev_attr_temp3_max.dev_attr.attr,
417 &sensor_dev_attr_temp3_min.dev_attr.attr,
418 &sensor_dev_attr_temp3_offset.dev_attr.attr,
419 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
420 &sensor_dev_attr_temp3_input_fault.dev_attr.attr,
421
422 &dev_attr_cpu0_vid.attr,
423 &dev_attr_vrm.attr,
424 NULL
425};
426
427static const struct attribute_group smsc47m192_group = {
428 .attrs = smsc47m192_attributes,
429};
430
431static struct attribute *smsc47m192_attributes_in4[] = {
432 &sensor_dev_attr_in4_input.dev_attr.attr,
433 &sensor_dev_attr_in4_min.dev_attr.attr,
434 &sensor_dev_attr_in4_max.dev_attr.attr,
435 &sensor_dev_attr_in4_alarm.dev_attr.attr,
436 NULL
437};
438
439static const struct attribute_group smsc47m192_group_in4 = {
440 .attrs = smsc47m192_attributes_in4,
441};
442
373/* This function is called when: 443/* This function is called when:
374 * smsc47m192_driver is inserted (when this module is loaded), for each 444 * smsc47m192_driver is inserted (when this module is loaded), for each
375 available adapter 445 available adapter
@@ -471,80 +541,28 @@ static int smsc47m192_detect(struct i2c_adapter *adapter, int address,
471 smsc47m192_init_client(client); 541 smsc47m192_init_client(client);
472 542
473 /* Register sysfs hooks */ 543 /* Register sysfs hooks */
474 data->class_dev = hwmon_device_register(&client->dev); 544 if ((err = sysfs_create_group(&client->dev.kobj, &smsc47m192_group)))
475 if (IS_ERR(data->class_dev)) {
476 err = PTR_ERR(data->class_dev);
477 goto exit_detach; 545 goto exit_detach;
478 }
479
480 device_create_file(&client->dev, &sensor_dev_attr_in0_input.dev_attr);
481 device_create_file(&client->dev, &sensor_dev_attr_in0_min.dev_attr);
482 device_create_file(&client->dev, &sensor_dev_attr_in0_max.dev_attr);
483 device_create_file(&client->dev, &sensor_dev_attr_in0_alarm.dev_attr);
484 device_create_file(&client->dev, &sensor_dev_attr_in1_input.dev_attr);
485 device_create_file(&client->dev, &sensor_dev_attr_in1_min.dev_attr);
486 device_create_file(&client->dev, &sensor_dev_attr_in1_max.dev_attr);
487 device_create_file(&client->dev, &sensor_dev_attr_in1_alarm.dev_attr);
488 device_create_file(&client->dev, &sensor_dev_attr_in2_input.dev_attr);
489 device_create_file(&client->dev, &sensor_dev_attr_in2_min.dev_attr);
490 device_create_file(&client->dev, &sensor_dev_attr_in2_max.dev_attr);
491 device_create_file(&client->dev, &sensor_dev_attr_in2_alarm.dev_attr);
492 device_create_file(&client->dev, &sensor_dev_attr_in3_input.dev_attr);
493 device_create_file(&client->dev, &sensor_dev_attr_in3_min.dev_attr);
494 device_create_file(&client->dev, &sensor_dev_attr_in3_max.dev_attr);
495 device_create_file(&client->dev, &sensor_dev_attr_in3_alarm.dev_attr);
496 546
497 /* Pin 110 is either in4 (+12V) or VID4 */ 547 /* Pin 110 is either in4 (+12V) or VID4 */
498 config = i2c_smbus_read_byte_data(client, SMSC47M192_REG_CONFIG); 548 config = i2c_smbus_read_byte_data(client, SMSC47M192_REG_CONFIG);
499 if (!(config & 0x20)) { 549 if (!(config & 0x20)) {
500 device_create_file(&client->dev, 550 if ((err = sysfs_create_group(&client->dev.kobj,
501 &sensor_dev_attr_in4_input.dev_attr); 551 &smsc47m192_group_in4)))
502 device_create_file(&client->dev, 552 goto exit_remove_files;
503 &sensor_dev_attr_in4_min.dev_attr); 553 }
504 device_create_file(&client->dev, 554
505 &sensor_dev_attr_in4_max.dev_attr); 555 data->class_dev = hwmon_device_register(&client->dev);
506 device_create_file(&client->dev, 556 if (IS_ERR(data->class_dev)) {
507 &sensor_dev_attr_in4_alarm.dev_attr); 557 err = PTR_ERR(data->class_dev);
558 goto exit_remove_files;
508 } 559 }
509 device_create_file(&client->dev, &sensor_dev_attr_in5_input.dev_attr);
510 device_create_file(&client->dev, &sensor_dev_attr_in5_min.dev_attr);
511 device_create_file(&client->dev, &sensor_dev_attr_in5_max.dev_attr);
512 device_create_file(&client->dev, &sensor_dev_attr_in5_alarm.dev_attr);
513 device_create_file(&client->dev, &sensor_dev_attr_in6_input.dev_attr);
514 device_create_file(&client->dev, &sensor_dev_attr_in6_min.dev_attr);
515 device_create_file(&client->dev, &sensor_dev_attr_in6_max.dev_attr);
516 device_create_file(&client->dev, &sensor_dev_attr_in6_alarm.dev_attr);
517 device_create_file(&client->dev, &sensor_dev_attr_in7_input.dev_attr);
518 device_create_file(&client->dev, &sensor_dev_attr_in7_min.dev_attr);
519 device_create_file(&client->dev, &sensor_dev_attr_in7_max.dev_attr);
520 device_create_file(&client->dev, &sensor_dev_attr_in7_alarm.dev_attr);
521 device_create_file(&client->dev, &sensor_dev_attr_temp1_input.dev_attr);
522 device_create_file(&client->dev, &sensor_dev_attr_temp1_max.dev_attr);
523 device_create_file(&client->dev, &sensor_dev_attr_temp1_min.dev_attr);
524 device_create_file(&client->dev,
525 &sensor_dev_attr_temp1_offset.dev_attr);
526 device_create_file(&client->dev, &sensor_dev_attr_temp1_alarm.dev_attr);
527 device_create_file(&client->dev, &sensor_dev_attr_temp2_input.dev_attr);
528 device_create_file(&client->dev, &sensor_dev_attr_temp2_max.dev_attr);
529 device_create_file(&client->dev, &sensor_dev_attr_temp2_min.dev_attr);
530 device_create_file(&client->dev,
531 &sensor_dev_attr_temp2_offset.dev_attr);
532 device_create_file(&client->dev, &sensor_dev_attr_temp2_alarm.dev_attr);
533 device_create_file(&client->dev,
534 &sensor_dev_attr_temp2_input_fault.dev_attr);
535 device_create_file(&client->dev, &sensor_dev_attr_temp3_input.dev_attr);
536 device_create_file(&client->dev, &sensor_dev_attr_temp3_max.dev_attr);
537 device_create_file(&client->dev, &sensor_dev_attr_temp3_min.dev_attr);
538 device_create_file(&client->dev,
539 &sensor_dev_attr_temp3_offset.dev_attr);
540 device_create_file(&client->dev, &sensor_dev_attr_temp3_alarm.dev_attr);
541 device_create_file(&client->dev,
542 &sensor_dev_attr_temp3_input_fault.dev_attr);
543 device_create_file(&client->dev, &dev_attr_cpu0_vid);
544 device_create_file(&client->dev, &dev_attr_vrm);
545 560
546 return 0; 561 return 0;
547 562
563exit_remove_files:
564 sysfs_remove_group(&client->dev.kobj, &smsc47m192_group);
565 sysfs_remove_group(&client->dev.kobj, &smsc47m192_group_in4);
548exit_detach: 566exit_detach:
549 i2c_detach_client(client); 567 i2c_detach_client(client);
550exit_free: 568exit_free:
@@ -559,6 +577,8 @@ static int smsc47m192_detach_client(struct i2c_client *client)
559 int err; 577 int err;
560 578
561 hwmon_device_unregister(data->class_dev); 579 hwmon_device_unregister(data->class_dev);
580 sysfs_remove_group(&client->dev.kobj, &smsc47m192_group);
581 sysfs_remove_group(&client->dev.kobj, &smsc47m192_group_in4);
562 582
563 if ((err = i2c_detach_client(client))) 583 if ((err = i2c_detach_client(client)))
564 return err; 584 return err;