aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/gl520sm.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-11-04 17:45:41 -0500
committerMark M. Hoffman <mhoffman@lightlink.com>2008-02-07 20:39:42 -0500
commite86a776093cffef993841ab7dbb4b1611ebf9686 (patch)
tree68566463e2d6e5c4f5ef3765199d0b18ebd331aa /drivers/hwmon/gl520sm.c
parent86d47f127d740b891da29daff5799d91b6bd2e17 (diff)
hwmon: (gl520sm) Add individual alarm and beep files
libsensors 3.0 needs these. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers/hwmon/gl520sm.c')
-rw-r--r--drivers/hwmon/gl520sm.c91
1 files changed, 89 insertions, 2 deletions
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c
index 40bfdc702dc3..03ecdc334764 100644
--- a/drivers/hwmon/gl520sm.c
+++ b/drivers/hwmon/gl520sm.c
@@ -532,33 +532,108 @@ static DEVICE_ATTR(beep_enable, S_IRUGO | S_IWUSR,
532static DEVICE_ATTR(beep_mask, S_IRUGO | S_IWUSR, 532static DEVICE_ATTR(beep_mask, S_IRUGO | S_IWUSR,
533 get_beep_mask, set_beep_mask); 533 get_beep_mask, set_beep_mask);
534 534
535static ssize_t get_alarm(struct device *dev, struct device_attribute *attr,
536 char *buf)
537{
538 int bit_nr = to_sensor_dev_attr(attr)->index;
539 struct gl520_data *data = gl520_update_device(dev);
540
541 return sprintf(buf, "%d\n", (data->alarms >> bit_nr) & 1);
542}
543
544static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, get_alarm, NULL, 0);
545static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, get_alarm, NULL, 1);
546static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, get_alarm, NULL, 2);
547static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, get_alarm, NULL, 3);
548static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, get_alarm, NULL, 4);
549static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, get_alarm, NULL, 5);
550static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, get_alarm, NULL, 6);
551static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, get_alarm, NULL, 7);
552static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, get_alarm, NULL, 7);
553
554static ssize_t get_beep(struct device *dev, struct device_attribute *attr,
555 char *buf)
556{
557 int bitnr = to_sensor_dev_attr(attr)->index;
558 struct gl520_data *data = gl520_update_device(dev);
559
560 return sprintf(buf, "%d\n", (data->beep_mask >> bitnr) & 1);
561}
562
563static ssize_t set_beep(struct device *dev, struct device_attribute *attr,
564 const char *buf, size_t count)
565{
566 struct i2c_client *client = to_i2c_client(dev);
567 struct gl520_data *data = i2c_get_clientdata(client);
568 int bitnr = to_sensor_dev_attr(attr)->index;
569 unsigned long bit;
570
571 bit = simple_strtoul(buf, NULL, 10);
572 if (bit & ~1)
573 return -EINVAL;
574
575 mutex_lock(&data->update_lock);
576 data->beep_mask = gl520_read_value(client, GL520_REG_BEEP_MASK);
577 if (bit)
578 data->beep_mask |= (1 << bitnr);
579 else
580 data->beep_mask &= ~(1 << bitnr);
581 gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask);
582 mutex_unlock(&data->update_lock);
583 return count;
584}
585
586static SENSOR_DEVICE_ATTR(in0_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 0);
587static SENSOR_DEVICE_ATTR(in1_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 1);
588static SENSOR_DEVICE_ATTR(in2_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 2);
589static SENSOR_DEVICE_ATTR(in3_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 3);
590static SENSOR_DEVICE_ATTR(temp1_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 4);
591static SENSOR_DEVICE_ATTR(fan1_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 5);
592static SENSOR_DEVICE_ATTR(fan2_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 6);
593static SENSOR_DEVICE_ATTR(temp2_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 7);
594static SENSOR_DEVICE_ATTR(in4_beep, S_IRUGO | S_IWUSR, get_beep, set_beep, 7);
595
535static struct attribute *gl520_attributes[] = { 596static struct attribute *gl520_attributes[] = {
536 &dev_attr_cpu0_vid.attr, 597 &dev_attr_cpu0_vid.attr,
537 598
538 &sensor_dev_attr_in0_input.dev_attr.attr, 599 &sensor_dev_attr_in0_input.dev_attr.attr,
539 &sensor_dev_attr_in0_min.dev_attr.attr, 600 &sensor_dev_attr_in0_min.dev_attr.attr,
540 &sensor_dev_attr_in0_max.dev_attr.attr, 601 &sensor_dev_attr_in0_max.dev_attr.attr,
602 &sensor_dev_attr_in0_alarm.dev_attr.attr,
603 &sensor_dev_attr_in0_beep.dev_attr.attr,
541 &sensor_dev_attr_in1_input.dev_attr.attr, 604 &sensor_dev_attr_in1_input.dev_attr.attr,
542 &sensor_dev_attr_in1_min.dev_attr.attr, 605 &sensor_dev_attr_in1_min.dev_attr.attr,
543 &sensor_dev_attr_in1_max.dev_attr.attr, 606 &sensor_dev_attr_in1_max.dev_attr.attr,
607 &sensor_dev_attr_in1_alarm.dev_attr.attr,
608 &sensor_dev_attr_in1_beep.dev_attr.attr,
544 &sensor_dev_attr_in2_input.dev_attr.attr, 609 &sensor_dev_attr_in2_input.dev_attr.attr,
545 &sensor_dev_attr_in2_min.dev_attr.attr, 610 &sensor_dev_attr_in2_min.dev_attr.attr,
546 &sensor_dev_attr_in2_max.dev_attr.attr, 611 &sensor_dev_attr_in2_max.dev_attr.attr,
612 &sensor_dev_attr_in2_alarm.dev_attr.attr,
613 &sensor_dev_attr_in2_beep.dev_attr.attr,
547 &sensor_dev_attr_in3_input.dev_attr.attr, 614 &sensor_dev_attr_in3_input.dev_attr.attr,
548 &sensor_dev_attr_in3_min.dev_attr.attr, 615 &sensor_dev_attr_in3_min.dev_attr.attr,
549 &sensor_dev_attr_in3_max.dev_attr.attr, 616 &sensor_dev_attr_in3_max.dev_attr.attr,
617 &sensor_dev_attr_in3_alarm.dev_attr.attr,
618 &sensor_dev_attr_in3_beep.dev_attr.attr,
550 619
551 &sensor_dev_attr_fan1_input.dev_attr.attr, 620 &sensor_dev_attr_fan1_input.dev_attr.attr,
552 &sensor_dev_attr_fan1_min.dev_attr.attr, 621 &sensor_dev_attr_fan1_min.dev_attr.attr,
553 &sensor_dev_attr_fan1_div.dev_attr.attr, 622 &sensor_dev_attr_fan1_div.dev_attr.attr,
623 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
624 &sensor_dev_attr_fan1_beep.dev_attr.attr,
554 &dev_attr_fan1_off.attr, 625 &dev_attr_fan1_off.attr,
555 &sensor_dev_attr_fan2_input.dev_attr.attr, 626 &sensor_dev_attr_fan2_input.dev_attr.attr,
556 &sensor_dev_attr_fan2_min.dev_attr.attr, 627 &sensor_dev_attr_fan2_min.dev_attr.attr,
557 &sensor_dev_attr_fan2_div.dev_attr.attr, 628 &sensor_dev_attr_fan2_div.dev_attr.attr,
629 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
630 &sensor_dev_attr_fan2_beep.dev_attr.attr,
558 631
559 &sensor_dev_attr_temp1_input.dev_attr.attr, 632 &sensor_dev_attr_temp1_input.dev_attr.attr,
560 &sensor_dev_attr_temp1_max.dev_attr.attr, 633 &sensor_dev_attr_temp1_max.dev_attr.attr,
561 &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, 634 &sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
635 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
636 &sensor_dev_attr_temp1_beep.dev_attr.attr,
562 637
563 &dev_attr_alarms.attr, 638 &dev_attr_alarms.attr,
564 &dev_attr_beep_enable.attr, 639 &dev_attr_beep_enable.attr,
@@ -574,10 +649,14 @@ static struct attribute *gl520_attributes_opt[] = {
574 &sensor_dev_attr_in4_input.dev_attr.attr, 649 &sensor_dev_attr_in4_input.dev_attr.attr,
575 &sensor_dev_attr_in4_min.dev_attr.attr, 650 &sensor_dev_attr_in4_min.dev_attr.attr,
576 &sensor_dev_attr_in4_max.dev_attr.attr, 651 &sensor_dev_attr_in4_max.dev_attr.attr,
652 &sensor_dev_attr_in4_alarm.dev_attr.attr,
653 &sensor_dev_attr_in4_beep.dev_attr.attr,
577 654
578 &sensor_dev_attr_temp2_input.dev_attr.attr, 655 &sensor_dev_attr_temp2_input.dev_attr.attr,
579 &sensor_dev_attr_temp2_max.dev_attr.attr, 656 &sensor_dev_attr_temp2_max.dev_attr.attr,
580 &sensor_dev_attr_temp2_max_hyst.dev_attr.attr, 657 &sensor_dev_attr_temp2_max_hyst.dev_attr.attr,
658 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
659 &sensor_dev_attr_temp2_beep.dev_attr.attr,
581 NULL 660 NULL
582}; 661};
583 662
@@ -653,7 +732,11 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
653 || (err = device_create_file(&client->dev, 732 || (err = device_create_file(&client->dev,
654 &sensor_dev_attr_temp2_max.dev_attr)) 733 &sensor_dev_attr_temp2_max.dev_attr))
655 || (err = device_create_file(&client->dev, 734 || (err = device_create_file(&client->dev,
656 &sensor_dev_attr_temp2_max_hyst.dev_attr))) 735 &sensor_dev_attr_temp2_max_hyst.dev_attr))
736 || (err = device_create_file(&client->dev,
737 &sensor_dev_attr_temp2_alarm.dev_attr))
738 || (err = device_create_file(&client->dev,
739 &sensor_dev_attr_temp2_beep.dev_attr)))
657 goto exit_remove_files; 740 goto exit_remove_files;
658 } else { 741 } else {
659 if ((err = device_create_file(&client->dev, 742 if ((err = device_create_file(&client->dev,
@@ -661,7 +744,11 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
661 || (err = device_create_file(&client->dev, 744 || (err = device_create_file(&client->dev,
662 &sensor_dev_attr_in4_min.dev_attr)) 745 &sensor_dev_attr_in4_min.dev_attr))
663 || (err = device_create_file(&client->dev, 746 || (err = device_create_file(&client->dev,
664 &sensor_dev_attr_in4_max.dev_attr))) 747 &sensor_dev_attr_in4_max.dev_attr))
748 || (err = device_create_file(&client->dev,
749 &sensor_dev_attr_in4_alarm.dev_attr))
750 || (err = device_create_file(&client->dev,
751 &sensor_dev_attr_in4_beep.dev_attr)))
665 goto exit_remove_files; 752 goto exit_remove_files;
666 } 753 }
667 754