diff options
author | Jean Delvare <khali@linux-fr.org> | 2006-09-24 15:25:12 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-28 18:31:19 -0400 |
commit | ce8c6ce1eceecfe090f6c1aa4108087b2051497b (patch) | |
tree | a119733f9fb1772f7c2436761fbbbe805b5f46fd /drivers/hwmon/smsc47m192.c | |
parent | a5ebe668add5f76ed8f01f752b37cfa164a26a30 (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/smsc47m192.c')
-rw-r--r-- | drivers/hwmon/smsc47m192.c | 150 |
1 files changed, 85 insertions, 65 deletions
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 */ |
35 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; | 36 | static 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); | |||
370 | static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 0x0400); | 371 | static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 0x0400); |
371 | static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 0x0800); | 372 | static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 0x0800); |
372 | 373 | ||
374 | static 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 | |||
427 | static const struct attribute_group smsc47m192_group = { | ||
428 | .attrs = smsc47m192_attributes, | ||
429 | }; | ||
430 | |||
431 | static 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 | |||
439 | static 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 | ||
563 | exit_remove_files: | ||
564 | sysfs_remove_group(&client->dev.kobj, &smsc47m192_group); | ||
565 | sysfs_remove_group(&client->dev.kobj, &smsc47m192_group_in4); | ||
548 | exit_detach: | 566 | exit_detach: |
549 | i2c_detach_client(client); | 567 | i2c_detach_client(client); |
550 | exit_free: | 568 | exit_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; |