diff options
| author | Guenter Roeck <guenter.roeck@ericsson.com> | 2010-09-17 11:24:14 -0400 |
|---|---|---|
| committer | Jean Delvare <khali@linux-fr.org> | 2010-09-17 11:24:14 -0400 |
| commit | a51b9944a1aaca34c9061d3973663fee54e9d1c1 (patch) | |
| tree | a0bca6cc212f3f0a73f1177a6a7e442f28a03059 | |
| parent | 022b75a3df2b5aeeb70c5d51bc1fe55722fdd759 (diff) | |
hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval
The attribute reflects an interval, not a rate.
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Acked-by: Ira W. Snyder <iws@ovro.caltech.edu>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
| -rw-r--r-- | Documentation/hwmon/sysfs-interface | 7 | ||||
| -rw-r--r-- | drivers/hwmon/adm1031.c | 43 |
2 files changed, 27 insertions, 23 deletions
diff --git a/Documentation/hwmon/sysfs-interface b/Documentation/hwmon/sysfs-interface index ff45d1f837c8..48ceabedf55d 100644 --- a/Documentation/hwmon/sysfs-interface +++ b/Documentation/hwmon/sysfs-interface | |||
| @@ -91,12 +91,11 @@ name The chip name. | |||
| 91 | I2C devices get this attribute created automatically. | 91 | I2C devices get this attribute created automatically. |
| 92 | RO | 92 | RO |
| 93 | 93 | ||
| 94 | update_rate The rate at which the chip will update readings. | 94 | update_interval The interval at which the chip will update readings. |
| 95 | Unit: millisecond | 95 | Unit: millisecond |
| 96 | RW | 96 | RW |
| 97 | Some devices have a variable update rate. This attribute | 97 | Some devices have a variable update rate or interval. |
| 98 | can be used to change the update rate to the desired | 98 | This attribute can be used to change it to the desired value. |
| 99 | frequency. | ||
| 100 | 99 | ||
| 101 | 100 | ||
| 102 | ************ | 101 | ************ |
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 15c1a9616af3..0683e6be662c 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
| @@ -79,7 +79,7 @@ struct adm1031_data { | |||
| 79 | int chip_type; | 79 | int chip_type; |
| 80 | char valid; /* !=0 if following fields are valid */ | 80 | char valid; /* !=0 if following fields are valid */ |
| 81 | unsigned long last_updated; /* In jiffies */ | 81 | unsigned long last_updated; /* In jiffies */ |
| 82 | unsigned int update_rate; /* In milliseconds */ | 82 | unsigned int update_interval; /* In milliseconds */ |
| 83 | /* The chan_select_table contains the possible configurations for | 83 | /* The chan_select_table contains the possible configurations for |
| 84 | * auto fan control. | 84 | * auto fan control. |
| 85 | */ | 85 | */ |
| @@ -743,23 +743,23 @@ static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 12); | |||
| 743 | static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 13); | 743 | static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 13); |
| 744 | static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 14); | 744 | static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 14); |
| 745 | 745 | ||
| 746 | /* Update Rate */ | 746 | /* Update Interval */ |
| 747 | static const unsigned int update_rates[] = { | 747 | static const unsigned int update_intervals[] = { |
| 748 | 16000, 8000, 4000, 2000, 1000, 500, 250, 125, | 748 | 16000, 8000, 4000, 2000, 1000, 500, 250, 125, |
| 749 | }; | 749 | }; |
| 750 | 750 | ||
| 751 | static ssize_t show_update_rate(struct device *dev, | 751 | static ssize_t show_update_interval(struct device *dev, |
| 752 | struct device_attribute *attr, char *buf) | 752 | struct device_attribute *attr, char *buf) |
| 753 | { | 753 | { |
| 754 | struct i2c_client *client = to_i2c_client(dev); | 754 | struct i2c_client *client = to_i2c_client(dev); |
| 755 | struct adm1031_data *data = i2c_get_clientdata(client); | 755 | struct adm1031_data *data = i2c_get_clientdata(client); |
| 756 | 756 | ||
| 757 | return sprintf(buf, "%u\n", data->update_rate); | 757 | return sprintf(buf, "%u\n", data->update_interval); |
| 758 | } | 758 | } |
| 759 | 759 | ||
| 760 | static ssize_t set_update_rate(struct device *dev, | 760 | static ssize_t set_update_interval(struct device *dev, |
| 761 | struct device_attribute *attr, | 761 | struct device_attribute *attr, |
| 762 | const char *buf, size_t count) | 762 | const char *buf, size_t count) |
| 763 | { | 763 | { |
| 764 | struct i2c_client *client = to_i2c_client(dev); | 764 | struct i2c_client *client = to_i2c_client(dev); |
| 765 | struct adm1031_data *data = i2c_get_clientdata(client); | 765 | struct adm1031_data *data = i2c_get_clientdata(client); |
| @@ -771,12 +771,15 @@ static ssize_t set_update_rate(struct device *dev, | |||
| 771 | if (err) | 771 | if (err) |
| 772 | return err; | 772 | return err; |
| 773 | 773 | ||
| 774 | /* find the nearest update rate from the table */ | 774 | /* |
| 775 | for (i = 0; i < ARRAY_SIZE(update_rates) - 1; i++) { | 775 | * Find the nearest update interval from the table. |
| 776 | if (val >= update_rates[i]) | 776 | * Use it to determine the matching update rate. |
| 777 | */ | ||
| 778 | for (i = 0; i < ARRAY_SIZE(update_intervals) - 1; i++) { | ||
| 779 | if (val >= update_intervals[i]) | ||
| 777 | break; | 780 | break; |
| 778 | } | 781 | } |
| 779 | /* if not found, we point to the last entry (lowest update rate) */ | 782 | /* if not found, we point to the last entry (lowest update interval) */ |
| 780 | 783 | ||
| 781 | /* set the new update rate while preserving other settings */ | 784 | /* set the new update rate while preserving other settings */ |
| 782 | reg = adm1031_read_value(client, ADM1031_REG_FAN_FILTER); | 785 | reg = adm1031_read_value(client, ADM1031_REG_FAN_FILTER); |
| @@ -785,14 +788,14 @@ static ssize_t set_update_rate(struct device *dev, | |||
| 785 | adm1031_write_value(client, ADM1031_REG_FAN_FILTER, reg); | 788 | adm1031_write_value(client, ADM1031_REG_FAN_FILTER, reg); |
| 786 | 789 | ||
| 787 | mutex_lock(&data->update_lock); | 790 | mutex_lock(&data->update_lock); |
| 788 | data->update_rate = update_rates[i]; | 791 | data->update_interval = update_intervals[i]; |
| 789 | mutex_unlock(&data->update_lock); | 792 | mutex_unlock(&data->update_lock); |
| 790 | 793 | ||
| 791 | return count; | 794 | return count; |
| 792 | } | 795 | } |
| 793 | 796 | ||
| 794 | static DEVICE_ATTR(update_rate, S_IRUGO | S_IWUSR, show_update_rate, | 797 | static DEVICE_ATTR(update_interval, S_IRUGO | S_IWUSR, show_update_interval, |
| 795 | set_update_rate); | 798 | set_update_interval); |
| 796 | 799 | ||
| 797 | static struct attribute *adm1031_attributes[] = { | 800 | static struct attribute *adm1031_attributes[] = { |
| 798 | &sensor_dev_attr_fan1_input.dev_attr.attr, | 801 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
| @@ -830,7 +833,7 @@ static struct attribute *adm1031_attributes[] = { | |||
| 830 | 833 | ||
| 831 | &sensor_dev_attr_auto_fan1_min_pwm.dev_attr.attr, | 834 | &sensor_dev_attr_auto_fan1_min_pwm.dev_attr.attr, |
| 832 | 835 | ||
| 833 | &dev_attr_update_rate.attr, | 836 | &dev_attr_update_interval.attr, |
| 834 | &dev_attr_alarms.attr, | 837 | &dev_attr_alarms.attr, |
| 835 | 838 | ||
| 836 | NULL | 839 | NULL |
| @@ -981,7 +984,8 @@ static void adm1031_init_client(struct i2c_client *client) | |||
| 981 | mask = ADM1031_UPDATE_RATE_MASK; | 984 | mask = ADM1031_UPDATE_RATE_MASK; |
| 982 | read_val = adm1031_read_value(client, ADM1031_REG_FAN_FILTER); | 985 | read_val = adm1031_read_value(client, ADM1031_REG_FAN_FILTER); |
| 983 | i = (read_val & mask) >> ADM1031_UPDATE_RATE_SHIFT; | 986 | i = (read_val & mask) >> ADM1031_UPDATE_RATE_SHIFT; |
| 984 | data->update_rate = update_rates[i]; | 987 | /* Save it as update interval */ |
| 988 | data->update_interval = update_intervals[i]; | ||
| 985 | } | 989 | } |
| 986 | 990 | ||
| 987 | static struct adm1031_data *adm1031_update_device(struct device *dev) | 991 | static struct adm1031_data *adm1031_update_device(struct device *dev) |
| @@ -993,7 +997,8 @@ static struct adm1031_data *adm1031_update_device(struct device *dev) | |||
| 993 | 997 | ||
| 994 | mutex_lock(&data->update_lock); | 998 | mutex_lock(&data->update_lock); |
| 995 | 999 | ||
| 996 | next_update = data->last_updated + msecs_to_jiffies(data->update_rate); | 1000 | next_update = data->last_updated |
| 1001 | + msecs_to_jiffies(data->update_interval); | ||
| 997 | if (time_after(jiffies, next_update) || !data->valid) { | 1002 | if (time_after(jiffies, next_update) || !data->valid) { |
| 998 | 1003 | ||
| 999 | dev_dbg(&client->dev, "Starting adm1031 update\n"); | 1004 | dev_dbg(&client->dev, "Starting adm1031 update\n"); |
