diff options
Diffstat (limited to 'drivers/hwmon/sis5595.c')
-rw-r--r-- | drivers/hwmon/sis5595.c | 101 |
1 files changed, 71 insertions, 30 deletions
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 3783af4195bd..95a4b5d9eaf2 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c | |||
@@ -61,6 +61,7 @@ | |||
61 | #include <linux/init.h> | 61 | #include <linux/init.h> |
62 | #include <linux/jiffies.h> | 62 | #include <linux/jiffies.h> |
63 | #include <linux/mutex.h> | 63 | #include <linux/mutex.h> |
64 | #include <linux/sysfs.h> | ||
64 | #include <asm/io.h> | 65 | #include <asm/io.h> |
65 | 66 | ||
66 | 67 | ||
@@ -473,6 +474,50 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch | |||
473 | return sprintf(buf, "%d\n", data->alarms); | 474 | return sprintf(buf, "%d\n", data->alarms); |
474 | } | 475 | } |
475 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 476 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
477 | |||
478 | static struct attribute *sis5595_attributes[] = { | ||
479 | &dev_attr_in0_input.attr, | ||
480 | &dev_attr_in0_min.attr, | ||
481 | &dev_attr_in0_max.attr, | ||
482 | &dev_attr_in1_input.attr, | ||
483 | &dev_attr_in1_min.attr, | ||
484 | &dev_attr_in1_max.attr, | ||
485 | &dev_attr_in2_input.attr, | ||
486 | &dev_attr_in2_min.attr, | ||
487 | &dev_attr_in2_max.attr, | ||
488 | &dev_attr_in3_input.attr, | ||
489 | &dev_attr_in3_min.attr, | ||
490 | &dev_attr_in3_max.attr, | ||
491 | |||
492 | &dev_attr_fan1_input.attr, | ||
493 | &dev_attr_fan1_min.attr, | ||
494 | &dev_attr_fan1_div.attr, | ||
495 | &dev_attr_fan2_input.attr, | ||
496 | &dev_attr_fan2_min.attr, | ||
497 | &dev_attr_fan2_div.attr, | ||
498 | |||
499 | &dev_attr_alarms.attr, | ||
500 | NULL | ||
501 | }; | ||
502 | |||
503 | static const struct attribute_group sis5595_group = { | ||
504 | .attrs = sis5595_attributes, | ||
505 | }; | ||
506 | |||
507 | static struct attribute *sis5595_attributes_opt[] = { | ||
508 | &dev_attr_in4_input.attr, | ||
509 | &dev_attr_in4_min.attr, | ||
510 | &dev_attr_in4_max.attr, | ||
511 | |||
512 | &dev_attr_temp1_input.attr, | ||
513 | &dev_attr_temp1_max.attr, | ||
514 | &dev_attr_temp1_max_hyst.attr, | ||
515 | NULL | ||
516 | }; | ||
517 | |||
518 | static const struct attribute_group sis5595_group_opt = { | ||
519 | .attrs = sis5595_attributes_opt, | ||
520 | }; | ||
476 | 521 | ||
477 | /* This is called when the module is loaded */ | 522 | /* This is called when the module is loaded */ |
478 | static int sis5595_detect(struct i2c_adapter *adapter) | 523 | static int sis5595_detect(struct i2c_adapter *adapter) |
@@ -566,43 +611,37 @@ static int sis5595_detect(struct i2c_adapter *adapter) | |||
566 | } | 611 | } |
567 | 612 | ||
568 | /* Register sysfs hooks */ | 613 | /* Register sysfs hooks */ |
614 | if ((err = sysfs_create_group(&new_client->dev.kobj, &sis5595_group))) | ||
615 | goto exit_detach; | ||
616 | if (data->maxins == 4) { | ||
617 | if ((err = device_create_file(&new_client->dev, | ||
618 | &dev_attr_in4_input)) | ||
619 | || (err = device_create_file(&new_client->dev, | ||
620 | &dev_attr_in4_min)) | ||
621 | || (err = device_create_file(&new_client->dev, | ||
622 | &dev_attr_in4_max))) | ||
623 | goto exit_remove_files; | ||
624 | } else { | ||
625 | if ((err = device_create_file(&new_client->dev, | ||
626 | &dev_attr_temp1_input)) | ||
627 | || (err = device_create_file(&new_client->dev, | ||
628 | &dev_attr_temp1_max)) | ||
629 | || (err = device_create_file(&new_client->dev, | ||
630 | &dev_attr_temp1_max_hyst))) | ||
631 | goto exit_remove_files; | ||
632 | } | ||
633 | |||
569 | data->class_dev = hwmon_device_register(&new_client->dev); | 634 | data->class_dev = hwmon_device_register(&new_client->dev); |
570 | if (IS_ERR(data->class_dev)) { | 635 | if (IS_ERR(data->class_dev)) { |
571 | err = PTR_ERR(data->class_dev); | 636 | err = PTR_ERR(data->class_dev); |
572 | goto exit_detach; | 637 | goto exit_remove_files; |
573 | } | 638 | } |
574 | 639 | ||
575 | device_create_file(&new_client->dev, &dev_attr_in0_input); | ||
576 | device_create_file(&new_client->dev, &dev_attr_in0_min); | ||
577 | device_create_file(&new_client->dev, &dev_attr_in0_max); | ||
578 | device_create_file(&new_client->dev, &dev_attr_in1_input); | ||
579 | device_create_file(&new_client->dev, &dev_attr_in1_min); | ||
580 | device_create_file(&new_client->dev, &dev_attr_in1_max); | ||
581 | device_create_file(&new_client->dev, &dev_attr_in2_input); | ||
582 | device_create_file(&new_client->dev, &dev_attr_in2_min); | ||
583 | device_create_file(&new_client->dev, &dev_attr_in2_max); | ||
584 | device_create_file(&new_client->dev, &dev_attr_in3_input); | ||
585 | device_create_file(&new_client->dev, &dev_attr_in3_min); | ||
586 | device_create_file(&new_client->dev, &dev_attr_in3_max); | ||
587 | if (data->maxins == 4) { | ||
588 | device_create_file(&new_client->dev, &dev_attr_in4_input); | ||
589 | device_create_file(&new_client->dev, &dev_attr_in4_min); | ||
590 | device_create_file(&new_client->dev, &dev_attr_in4_max); | ||
591 | } | ||
592 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | ||
593 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | ||
594 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | ||
595 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | ||
596 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | ||
597 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | ||
598 | device_create_file(&new_client->dev, &dev_attr_alarms); | ||
599 | if (data->maxins == 3) { | ||
600 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | ||
601 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | ||
602 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); | ||
603 | } | ||
604 | return 0; | 640 | return 0; |
605 | 641 | ||
642 | exit_remove_files: | ||
643 | sysfs_remove_group(&new_client->dev.kobj, &sis5595_group); | ||
644 | sysfs_remove_group(&new_client->dev.kobj, &sis5595_group_opt); | ||
606 | exit_detach: | 645 | exit_detach: |
607 | i2c_detach_client(new_client); | 646 | i2c_detach_client(new_client); |
608 | exit_free: | 647 | exit_free: |
@@ -619,6 +658,8 @@ static int sis5595_detach_client(struct i2c_client *client) | |||
619 | int err; | 658 | int err; |
620 | 659 | ||
621 | hwmon_device_unregister(data->class_dev); | 660 | hwmon_device_unregister(data->class_dev); |
661 | sysfs_remove_group(&client->dev.kobj, &sis5595_group); | ||
662 | sysfs_remove_group(&client->dev.kobj, &sis5595_group_opt); | ||
622 | 663 | ||
623 | if ((err = i2c_detach_client(client))) | 664 | if ((err = i2c_detach_client(client))) |
624 | return err; | 665 | return err; |