diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-09-17 13:25:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-09-17 13:25:47 -0400 |
commit | 509344b8b4d365b7ff3bce97198d83a57b7c3f31 (patch) | |
tree | b9362ca16a3670a67dcc05fdaf0162aa2e470c5f /drivers | |
parent | 80214df8db6d0ba8172f70122705ef29077fd918 (diff) | |
parent | bc482bf0ce918b39a1fa60b9341f1add9318d833 (diff) |
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging
* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
hwmon: (lm95241) Replace rate sysfs attribute with update_interval
hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval
hwmon: (w83627ehf) Use proper exit sequence
hwmon: (emc1403) Remove unnecessary hwmon_device_unregister
hwmon: (f75375s) Do not overwrite values read from registers
hwmon: (f75375s) Shift control mode to the correct bit position
hwmon: New subsystem maintainers
hwmon: (lis3lv02d) Prevent NULL pointer dereference
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/adm1031.c | 43 | ||||
-rw-r--r-- | drivers/hwmon/emc1403.c | 1 | ||||
-rw-r--r-- | drivers/hwmon/f75375s.c | 6 | ||||
-rw-r--r-- | drivers/hwmon/lis3lv02d_i2c.c | 4 | ||||
-rw-r--r-- | drivers/hwmon/lis3lv02d_spi.c | 4 | ||||
-rw-r--r-- | drivers/hwmon/lm95241.c | 21 | ||||
-rw-r--r-- | drivers/hwmon/w83627ehf.c | 1 |
7 files changed, 43 insertions, 37 deletions
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"); |
diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c index 5b58b20dead1..8dee3f38fdfb 100644 --- a/drivers/hwmon/emc1403.c +++ b/drivers/hwmon/emc1403.c | |||
@@ -308,7 +308,6 @@ static int emc1403_probe(struct i2c_client *client, | |||
308 | res = sysfs_create_group(&client->dev.kobj, &m_thermal_gr); | 308 | res = sysfs_create_group(&client->dev.kobj, &m_thermal_gr); |
309 | if (res) { | 309 | if (res) { |
310 | dev_warn(&client->dev, "create group failed\n"); | 310 | dev_warn(&client->dev, "create group failed\n"); |
311 | hwmon_device_unregister(data->hwmon_dev); | ||
312 | goto thermal_error1; | 311 | goto thermal_error1; |
313 | } | 312 | } |
314 | data->hwmon_dev = hwmon_device_register(&client->dev); | 313 | data->hwmon_dev = hwmon_device_register(&client->dev); |
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c index 0f58ecc5334d..9638d58f99fd 100644 --- a/drivers/hwmon/f75375s.c +++ b/drivers/hwmon/f75375s.c | |||
@@ -79,7 +79,7 @@ enum chips { f75373, f75375 }; | |||
79 | #define F75375_REG_PWM2_DROP_DUTY 0x6C | 79 | #define F75375_REG_PWM2_DROP_DUTY 0x6C |
80 | 80 | ||
81 | #define FAN_CTRL_LINEAR(nr) (4 + nr) | 81 | #define FAN_CTRL_LINEAR(nr) (4 + nr) |
82 | #define FAN_CTRL_MODE(nr) (5 + ((nr) * 2)) | 82 | #define FAN_CTRL_MODE(nr) (4 + ((nr) * 2)) |
83 | 83 | ||
84 | /* | 84 | /* |
85 | * Data structures and manipulation thereof | 85 | * Data structures and manipulation thereof |
@@ -298,7 +298,7 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val) | |||
298 | return -EINVAL; | 298 | return -EINVAL; |
299 | 299 | ||
300 | fanmode = f75375_read8(client, F75375_REG_FAN_TIMER); | 300 | fanmode = f75375_read8(client, F75375_REG_FAN_TIMER); |
301 | fanmode = ~(3 << FAN_CTRL_MODE(nr)); | 301 | fanmode &= ~(3 << FAN_CTRL_MODE(nr)); |
302 | 302 | ||
303 | switch (val) { | 303 | switch (val) { |
304 | case 0: /* Full speed */ | 304 | case 0: /* Full speed */ |
@@ -350,7 +350,7 @@ static ssize_t set_pwm_mode(struct device *dev, struct device_attribute *attr, | |||
350 | 350 | ||
351 | mutex_lock(&data->update_lock); | 351 | mutex_lock(&data->update_lock); |
352 | conf = f75375_read8(client, F75375_REG_CONFIG1); | 352 | conf = f75375_read8(client, F75375_REG_CONFIG1); |
353 | conf = ~(1 << FAN_CTRL_LINEAR(nr)); | 353 | conf &= ~(1 << FAN_CTRL_LINEAR(nr)); |
354 | 354 | ||
355 | if (val == 0) | 355 | if (val == 0) |
356 | conf |= (1 << FAN_CTRL_LINEAR(nr)) ; | 356 | conf |= (1 << FAN_CTRL_LINEAR(nr)) ; |
diff --git a/drivers/hwmon/lis3lv02d_i2c.c b/drivers/hwmon/lis3lv02d_i2c.c index dc1f5402c1d7..8e5933b72d19 100644 --- a/drivers/hwmon/lis3lv02d_i2c.c +++ b/drivers/hwmon/lis3lv02d_i2c.c | |||
@@ -121,7 +121,7 @@ static int lis3lv02d_i2c_suspend(struct i2c_client *client, pm_message_t mesg) | |||
121 | { | 121 | { |
122 | struct lis3lv02d *lis3 = i2c_get_clientdata(client); | 122 | struct lis3lv02d *lis3 = i2c_get_clientdata(client); |
123 | 123 | ||
124 | if (!lis3->pdata->wakeup_flags) | 124 | if (!lis3->pdata || !lis3->pdata->wakeup_flags) |
125 | lis3lv02d_poweroff(lis3); | 125 | lis3lv02d_poweroff(lis3); |
126 | return 0; | 126 | return 0; |
127 | } | 127 | } |
@@ -130,7 +130,7 @@ static int lis3lv02d_i2c_resume(struct i2c_client *client) | |||
130 | { | 130 | { |
131 | struct lis3lv02d *lis3 = i2c_get_clientdata(client); | 131 | struct lis3lv02d *lis3 = i2c_get_clientdata(client); |
132 | 132 | ||
133 | if (!lis3->pdata->wakeup_flags) | 133 | if (!lis3->pdata || !lis3->pdata->wakeup_flags) |
134 | lis3lv02d_poweron(lis3); | 134 | lis3lv02d_poweron(lis3); |
135 | return 0; | 135 | return 0; |
136 | } | 136 | } |
diff --git a/drivers/hwmon/lis3lv02d_spi.c b/drivers/hwmon/lis3lv02d_spi.c index 82b16808a274..b9be5e3a22b3 100644 --- a/drivers/hwmon/lis3lv02d_spi.c +++ b/drivers/hwmon/lis3lv02d_spi.c | |||
@@ -92,7 +92,7 @@ static int lis3lv02d_spi_suspend(struct spi_device *spi, pm_message_t mesg) | |||
92 | { | 92 | { |
93 | struct lis3lv02d *lis3 = spi_get_drvdata(spi); | 93 | struct lis3lv02d *lis3 = spi_get_drvdata(spi); |
94 | 94 | ||
95 | if (!lis3->pdata->wakeup_flags) | 95 | if (!lis3->pdata || !lis3->pdata->wakeup_flags) |
96 | lis3lv02d_poweroff(&lis3_dev); | 96 | lis3lv02d_poweroff(&lis3_dev); |
97 | 97 | ||
98 | return 0; | 98 | return 0; |
@@ -102,7 +102,7 @@ static int lis3lv02d_spi_resume(struct spi_device *spi) | |||
102 | { | 102 | { |
103 | struct lis3lv02d *lis3 = spi_get_drvdata(spi); | 103 | struct lis3lv02d *lis3 = spi_get_drvdata(spi); |
104 | 104 | ||
105 | if (!lis3->pdata->wakeup_flags) | 105 | if (!lis3->pdata || !lis3->pdata->wakeup_flags) |
106 | lis3lv02d_poweron(lis3); | 106 | lis3lv02d_poweron(lis3); |
107 | 107 | ||
108 | return 0; | 108 | return 0; |
diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c index 94741d42112d..464340f25496 100644 --- a/drivers/hwmon/lm95241.c +++ b/drivers/hwmon/lm95241.c | |||
@@ -91,7 +91,7 @@ static struct lm95241_data *lm95241_update_device(struct device *dev); | |||
91 | struct lm95241_data { | 91 | struct lm95241_data { |
92 | struct device *hwmon_dev; | 92 | struct device *hwmon_dev; |
93 | struct mutex update_lock; | 93 | struct mutex update_lock; |
94 | unsigned long last_updated, rate; /* in jiffies */ | 94 | unsigned long last_updated, interval; /* in jiffies */ |
95 | char valid; /* zero until following fields are valid */ | 95 | char valid; /* zero until following fields are valid */ |
96 | /* registers values */ | 96 | /* registers values */ |
97 | u8 local_h, local_l; /* local */ | 97 | u8 local_h, local_l; /* local */ |
@@ -114,23 +114,23 @@ show_temp(local); | |||
114 | show_temp(remote1); | 114 | show_temp(remote1); |
115 | show_temp(remote2); | 115 | show_temp(remote2); |
116 | 116 | ||
117 | static ssize_t show_rate(struct device *dev, struct device_attribute *attr, | 117 | static ssize_t show_interval(struct device *dev, struct device_attribute *attr, |
118 | char *buf) | 118 | char *buf) |
119 | { | 119 | { |
120 | struct lm95241_data *data = lm95241_update_device(dev); | 120 | struct lm95241_data *data = lm95241_update_device(dev); |
121 | 121 | ||
122 | snprintf(buf, PAGE_SIZE - 1, "%lu\n", 1000 * data->rate / HZ); | 122 | snprintf(buf, PAGE_SIZE - 1, "%lu\n", 1000 * data->interval / HZ); |
123 | return strlen(buf); | 123 | return strlen(buf); |
124 | } | 124 | } |
125 | 125 | ||
126 | static ssize_t set_rate(struct device *dev, struct device_attribute *attr, | 126 | static ssize_t set_interval(struct device *dev, struct device_attribute *attr, |
127 | const char *buf, size_t count) | 127 | const char *buf, size_t count) |
128 | { | 128 | { |
129 | struct i2c_client *client = to_i2c_client(dev); | 129 | struct i2c_client *client = to_i2c_client(dev); |
130 | struct lm95241_data *data = i2c_get_clientdata(client); | 130 | struct lm95241_data *data = i2c_get_clientdata(client); |
131 | 131 | ||
132 | strict_strtol(buf, 10, &data->rate); | 132 | strict_strtol(buf, 10, &data->interval); |
133 | data->rate = data->rate * HZ / 1000; | 133 | data->interval = data->interval * HZ / 1000; |
134 | 134 | ||
135 | return count; | 135 | return count; |
136 | } | 136 | } |
@@ -286,7 +286,8 @@ static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_min1, set_min1); | |||
286 | static DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_min2, set_min2); | 286 | static DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_min2, set_min2); |
287 | static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_max1, set_max1); | 287 | static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_max1, set_max1); |
288 | static DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_max2, set_max2); | 288 | static DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_max2, set_max2); |
289 | static DEVICE_ATTR(rate, S_IWUSR | S_IRUGO, show_rate, set_rate); | 289 | static DEVICE_ATTR(update_interval, S_IWUSR | S_IRUGO, show_interval, |
290 | set_interval); | ||
290 | 291 | ||
291 | static struct attribute *lm95241_attributes[] = { | 292 | static struct attribute *lm95241_attributes[] = { |
292 | &dev_attr_temp1_input.attr, | 293 | &dev_attr_temp1_input.attr, |
@@ -298,7 +299,7 @@ static struct attribute *lm95241_attributes[] = { | |||
298 | &dev_attr_temp3_min.attr, | 299 | &dev_attr_temp3_min.attr, |
299 | &dev_attr_temp2_max.attr, | 300 | &dev_attr_temp2_max.attr, |
300 | &dev_attr_temp3_max.attr, | 301 | &dev_attr_temp3_max.attr, |
301 | &dev_attr_rate.attr, | 302 | &dev_attr_update_interval.attr, |
302 | NULL | 303 | NULL |
303 | }; | 304 | }; |
304 | 305 | ||
@@ -376,7 +377,7 @@ static void lm95241_init_client(struct i2c_client *client) | |||
376 | { | 377 | { |
377 | struct lm95241_data *data = i2c_get_clientdata(client); | 378 | struct lm95241_data *data = i2c_get_clientdata(client); |
378 | 379 | ||
379 | data->rate = HZ; /* 1 sec default */ | 380 | data->interval = HZ; /* 1 sec default */ |
380 | data->valid = 0; | 381 | data->valid = 0; |
381 | data->config = CFG_CR0076; | 382 | data->config = CFG_CR0076; |
382 | data->model = 0; | 383 | data->model = 0; |
@@ -410,7 +411,7 @@ static struct lm95241_data *lm95241_update_device(struct device *dev) | |||
410 | 411 | ||
411 | mutex_lock(&data->update_lock); | 412 | mutex_lock(&data->update_lock); |
412 | 413 | ||
413 | if (time_after(jiffies, data->last_updated + data->rate) || | 414 | if (time_after(jiffies, data->last_updated + data->interval) || |
414 | !data->valid) { | 415 | !data->valid) { |
415 | dev_dbg(&client->dev, "Updating lm95241 data.\n"); | 416 | dev_dbg(&client->dev, "Updating lm95241 data.\n"); |
416 | data->local_h = | 417 | data->local_h = |
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index e96e69dd36fb..072c58008a63 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -127,6 +127,7 @@ superio_enter(int ioreg) | |||
127 | static inline void | 127 | static inline void |
128 | superio_exit(int ioreg) | 128 | superio_exit(int ioreg) |
129 | { | 129 | { |
130 | outb(0xaa, ioreg); | ||
130 | outb(0x02, ioreg); | 131 | outb(0x02, ioreg); |
131 | outb(0x02, ioreg + 1); | 132 | outb(0x02, ioreg + 1); |
132 | } | 133 | } |