aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/sis5595.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/sis5595.c')
-rw-r--r--drivers/hwmon/sis5595.c59
1 files changed, 42 insertions, 17 deletions
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 7e2d9787babc..a276806f3d53 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -435,6 +435,22 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch
435} 435}
436static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 436static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
437 437
438static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
439 char *buf)
440{
441 struct sis5595_data *data = sis5595_update_device(dev);
442 int nr = to_sensor_dev_attr(da)->index;
443 return sprintf(buf, "%u\n", (data->alarms >> nr) & 1);
444}
445static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
446static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
447static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
448static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
449static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 15);
450static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6);
451static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7);
452static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 15);
453
438static ssize_t show_name(struct device *dev, struct device_attribute *attr, 454static ssize_t show_name(struct device *dev, struct device_attribute *attr,
439 char *buf) 455 char *buf)
440{ 456{
@@ -447,22 +463,28 @@ static struct attribute *sis5595_attributes[] = {
447 &sensor_dev_attr_in0_input.dev_attr.attr, 463 &sensor_dev_attr_in0_input.dev_attr.attr,
448 &sensor_dev_attr_in0_min.dev_attr.attr, 464 &sensor_dev_attr_in0_min.dev_attr.attr,
449 &sensor_dev_attr_in0_max.dev_attr.attr, 465 &sensor_dev_attr_in0_max.dev_attr.attr,
466 &sensor_dev_attr_in0_alarm.dev_attr.attr,
450 &sensor_dev_attr_in1_input.dev_attr.attr, 467 &sensor_dev_attr_in1_input.dev_attr.attr,
451 &sensor_dev_attr_in1_min.dev_attr.attr, 468 &sensor_dev_attr_in1_min.dev_attr.attr,
452 &sensor_dev_attr_in1_max.dev_attr.attr, 469 &sensor_dev_attr_in1_max.dev_attr.attr,
470 &sensor_dev_attr_in1_alarm.dev_attr.attr,
453 &sensor_dev_attr_in2_input.dev_attr.attr, 471 &sensor_dev_attr_in2_input.dev_attr.attr,
454 &sensor_dev_attr_in2_min.dev_attr.attr, 472 &sensor_dev_attr_in2_min.dev_attr.attr,
455 &sensor_dev_attr_in2_max.dev_attr.attr, 473 &sensor_dev_attr_in2_max.dev_attr.attr,
474 &sensor_dev_attr_in2_alarm.dev_attr.attr,
456 &sensor_dev_attr_in3_input.dev_attr.attr, 475 &sensor_dev_attr_in3_input.dev_attr.attr,
457 &sensor_dev_attr_in3_min.dev_attr.attr, 476 &sensor_dev_attr_in3_min.dev_attr.attr,
458 &sensor_dev_attr_in3_max.dev_attr.attr, 477 &sensor_dev_attr_in3_max.dev_attr.attr,
478 &sensor_dev_attr_in3_alarm.dev_attr.attr,
459 479
460 &sensor_dev_attr_fan1_input.dev_attr.attr, 480 &sensor_dev_attr_fan1_input.dev_attr.attr,
461 &sensor_dev_attr_fan1_min.dev_attr.attr, 481 &sensor_dev_attr_fan1_min.dev_attr.attr,
462 &sensor_dev_attr_fan1_div.dev_attr.attr, 482 &sensor_dev_attr_fan1_div.dev_attr.attr,
483 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
463 &sensor_dev_attr_fan2_input.dev_attr.attr, 484 &sensor_dev_attr_fan2_input.dev_attr.attr,
464 &sensor_dev_attr_fan2_min.dev_attr.attr, 485 &sensor_dev_attr_fan2_min.dev_attr.attr,
465 &sensor_dev_attr_fan2_div.dev_attr.attr, 486 &sensor_dev_attr_fan2_div.dev_attr.attr,
487 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
466 488
467 &dev_attr_alarms.attr, 489 &dev_attr_alarms.attr,
468 &dev_attr_name.attr, 490 &dev_attr_name.attr,
@@ -473,19 +495,28 @@ static const struct attribute_group sis5595_group = {
473 .attrs = sis5595_attributes, 495 .attrs = sis5595_attributes,
474}; 496};
475 497
476static struct attribute *sis5595_attributes_opt[] = { 498static struct attribute *sis5595_attributes_in4[] = {
477 &sensor_dev_attr_in4_input.dev_attr.attr, 499 &sensor_dev_attr_in4_input.dev_attr.attr,
478 &sensor_dev_attr_in4_min.dev_attr.attr, 500 &sensor_dev_attr_in4_min.dev_attr.attr,
479 &sensor_dev_attr_in4_max.dev_attr.attr, 501 &sensor_dev_attr_in4_max.dev_attr.attr,
502 &sensor_dev_attr_in4_alarm.dev_attr.attr,
503 NULL
504};
505
506static const struct attribute_group sis5595_group_in4 = {
507 .attrs = sis5595_attributes_in4,
508};
480 509
510static struct attribute *sis5595_attributes_temp1[] = {
481 &dev_attr_temp1_input.attr, 511 &dev_attr_temp1_input.attr,
482 &dev_attr_temp1_max.attr, 512 &dev_attr_temp1_max.attr,
483 &dev_attr_temp1_max_hyst.attr, 513 &dev_attr_temp1_max_hyst.attr,
514 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
484 NULL 515 NULL
485}; 516};
486 517
487static const struct attribute_group sis5595_group_opt = { 518static const struct attribute_group sis5595_group_temp1 = {
488 .attrs = sis5595_attributes_opt, 519 .attrs = sis5595_attributes_temp1,
489}; 520};
490 521
491/* This is called when the module is loaded */ 522/* This is called when the module is loaded */
@@ -540,20 +571,12 @@ static int __devinit sis5595_probe(struct platform_device *pdev)
540 if ((err = sysfs_create_group(&pdev->dev.kobj, &sis5595_group))) 571 if ((err = sysfs_create_group(&pdev->dev.kobj, &sis5595_group)))
541 goto exit_free; 572 goto exit_free;
542 if (data->maxins == 4) { 573 if (data->maxins == 4) {
543 if ((err = device_create_file(&pdev->dev, 574 if ((err = sysfs_create_group(&pdev->dev.kobj,
544 &sensor_dev_attr_in4_input.dev_attr)) 575 &sis5595_group_in4)))
545 || (err = device_create_file(&pdev->dev,
546 &sensor_dev_attr_in4_min.dev_attr))
547 || (err = device_create_file(&pdev->dev,
548 &sensor_dev_attr_in4_max.dev_attr)))
549 goto exit_remove_files; 576 goto exit_remove_files;
550 } else { 577 } else {
551 if ((err = device_create_file(&pdev->dev, 578 if ((err = sysfs_create_group(&pdev->dev.kobj,
552 &dev_attr_temp1_input)) 579 &sis5595_group_temp1)))
553 || (err = device_create_file(&pdev->dev,
554 &dev_attr_temp1_max))
555 || (err = device_create_file(&pdev->dev,
556 &dev_attr_temp1_max_hyst)))
557 goto exit_remove_files; 580 goto exit_remove_files;
558 } 581 }
559 582
@@ -567,7 +590,8 @@ static int __devinit sis5595_probe(struct platform_device *pdev)
567 590
568exit_remove_files: 591exit_remove_files:
569 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group); 592 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group);
570 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_opt); 593 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_in4);
594 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_temp1);
571exit_free: 595exit_free:
572 kfree(data); 596 kfree(data);
573exit_release: 597exit_release:
@@ -582,7 +606,8 @@ static int __devexit sis5595_remove(struct platform_device *pdev)
582 606
583 hwmon_device_unregister(data->hwmon_dev); 607 hwmon_device_unregister(data->hwmon_dev);
584 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group); 608 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group);
585 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_opt); 609 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_in4);
610 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_temp1);
586 611
587 release_region(data->addr, SIS5595_EXTENT); 612 release_region(data->addr, SIS5595_EXTENT);
588 platform_set_drvdata(pdev, NULL); 613 platform_set_drvdata(pdev, NULL);