Commit 509344b8 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 80214df8 bc482bf0
...@@ -91,12 +91,11 @@ name The chip name. ...@@ -91,12 +91,11 @@ name The chip name.
I2C devices get this attribute created automatically. I2C devices get this attribute created automatically.
RO RO
update_rate The rate at which the chip will update readings. update_interval The interval at which the chip will update readings.
Unit: millisecond Unit: millisecond
RW RW
Some devices have a variable update rate. This attribute Some devices have a variable update rate or interval.
can be used to change the update rate to the desired This attribute can be used to change it to the desired value.
frequency.
************ ************
......
...@@ -2657,9 +2657,12 @@ S: Maintained ...@@ -2657,9 +2657,12 @@ S: Maintained
F: drivers/media/video/gspca/ F: drivers/media/video/gspca/
HARDWARE MONITORING HARDWARE MONITORING
M: Jean Delvare <khali@linux-fr.org>
M: Guenter Roeck <guenter.roeck@ericsson.com>
L: lm-sensors@lm-sensors.org L: lm-sensors@lm-sensors.org
W: http://www.lm-sensors.org/ W: http://www.lm-sensors.org/
S: Orphan T: quilt kernel.org/pub/linux/kernel/people/jdelvare/linux-2.6/jdelvare-hwmon/
S: Maintained
F: Documentation/hwmon/ F: Documentation/hwmon/
F: drivers/hwmon/ F: drivers/hwmon/
F: include/linux/hwmon*.h F: include/linux/hwmon*.h
......
...@@ -79,7 +79,7 @@ struct adm1031_data { ...@@ -79,7 +79,7 @@ struct adm1031_data {
int chip_type; int chip_type;
char valid; /* !=0 if following fields are valid */ char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */ unsigned long last_updated; /* In jiffies */
unsigned int update_rate; /* In milliseconds */ unsigned int update_interval; /* In milliseconds */
/* The chan_select_table contains the possible configurations for /* The chan_select_table contains the possible configurations for
* auto fan control. * auto fan control.
*/ */
...@@ -743,21 +743,21 @@ static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 12); ...@@ -743,21 +743,21 @@ static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 12);
static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 13); static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 13);
static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 14); static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 14);
/* Update Rate */ /* Update Interval */
static const unsigned int update_rates[] = { static const unsigned int update_intervals[] = {
16000, 8000, 4000, 2000, 1000, 500, 250, 125, 16000, 8000, 4000, 2000, 1000, 500, 250, 125,
}; };
static ssize_t show_update_rate(struct device *dev, static ssize_t show_update_interval(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct adm1031_data *data = i2c_get_clientdata(client); struct adm1031_data *data = i2c_get_clientdata(client);
return sprintf(buf, "%u\n", data->update_rate); return sprintf(buf, "%u\n", data->update_interval);
} }
static ssize_t set_update_rate(struct device *dev, static ssize_t set_update_interval(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
...@@ -771,12 +771,15 @@ static ssize_t set_update_rate(struct device *dev, ...@@ -771,12 +771,15 @@ static ssize_t set_update_rate(struct device *dev,
if (err) if (err)
return err; return err;
/* find the nearest update rate from the table */ /*
for (i = 0; i < ARRAY_SIZE(update_rates) - 1; i++) { * Find the nearest update interval from the table.
if (val >= update_rates[i]) * Use it to determine the matching update rate.
*/
for (i = 0; i < ARRAY_SIZE(update_intervals) - 1; i++) {
if (val >= update_intervals[i])
break; break;
} }
/* if not found, we point to the last entry (lowest update rate) */ /* if not found, we point to the last entry (lowest update interval) */
/* set the new update rate while preserving other settings */ /* set the new update rate while preserving other settings */
reg = adm1031_read_value(client, ADM1031_REG_FAN_FILTER); reg = adm1031_read_value(client, ADM1031_REG_FAN_FILTER);
...@@ -785,14 +788,14 @@ static ssize_t set_update_rate(struct device *dev, ...@@ -785,14 +788,14 @@ static ssize_t set_update_rate(struct device *dev,
adm1031_write_value(client, ADM1031_REG_FAN_FILTER, reg); adm1031_write_value(client, ADM1031_REG_FAN_FILTER, reg);
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->update_rate = update_rates[i]; data->update_interval = update_intervals[i];
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
return count; return count;
} }
static DEVICE_ATTR(update_rate, S_IRUGO | S_IWUSR, show_update_rate, static DEVICE_ATTR(update_interval, S_IRUGO | S_IWUSR, show_update_interval,
set_update_rate); set_update_interval);
static struct attribute *adm1031_attributes[] = { static struct attribute *adm1031_attributes[] = {
&sensor_dev_attr_fan1_input.dev_attr.attr, &sensor_dev_attr_fan1_input.dev_attr.attr,
...@@ -830,7 +833,7 @@ static struct attribute *adm1031_attributes[] = { ...@@ -830,7 +833,7 @@ static struct attribute *adm1031_attributes[] = {
&sensor_dev_attr_auto_fan1_min_pwm.dev_attr.attr, &sensor_dev_attr_auto_fan1_min_pwm.dev_attr.attr,
&dev_attr_update_rate.attr, &dev_attr_update_interval.attr,
&dev_attr_alarms.attr, &dev_attr_alarms.attr,
NULL NULL
...@@ -981,7 +984,8 @@ static void adm1031_init_client(struct i2c_client *client) ...@@ -981,7 +984,8 @@ static void adm1031_init_client(struct i2c_client *client)
mask = ADM1031_UPDATE_RATE_MASK; mask = ADM1031_UPDATE_RATE_MASK;
read_val = adm1031_read_value(client, ADM1031_REG_FAN_FILTER); read_val = adm1031_read_value(client, ADM1031_REG_FAN_FILTER);
i = (read_val & mask) >> ADM1031_UPDATE_RATE_SHIFT; i = (read_val & mask) >> ADM1031_UPDATE_RATE_SHIFT;
data->update_rate = update_rates[i]; /* Save it as update interval */
data->update_interval = update_intervals[i];
} }
static struct adm1031_data *adm1031_update_device(struct device *dev) 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,7 +997,8 @@ static struct adm1031_data *adm1031_update_device(struct device *dev)
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
next_update = data->last_updated + msecs_to_jiffies(data->update_rate); next_update = data->last_updated
+ msecs_to_jiffies(data->update_interval);
if (time_after(jiffies, next_update) || !data->valid) { if (time_after(jiffies, next_update) || !data->valid) {
dev_dbg(&client->dev, "Starting adm1031 update\n"); dev_dbg(&client->dev, "Starting adm1031 update\n");
......
...@@ -308,7 +308,6 @@ static int emc1403_probe(struct i2c_client *client, ...@@ -308,7 +308,6 @@ static int emc1403_probe(struct i2c_client *client,
res = sysfs_create_group(&client->dev.kobj, &m_thermal_gr); res = sysfs_create_group(&client->dev.kobj, &m_thermal_gr);
if (res) { if (res) {
dev_warn(&client->dev, "create group failed\n"); dev_warn(&client->dev, "create group failed\n");
hwmon_device_unregister(data->hwmon_dev);
goto thermal_error1; goto thermal_error1;
} }
data->hwmon_dev = hwmon_device_register(&client->dev); data->hwmon_dev = hwmon_device_register(&client->dev);
......
...@@ -79,7 +79,7 @@ enum chips { f75373, f75375 }; ...@@ -79,7 +79,7 @@ enum chips { f75373, f75375 };
#define F75375_REG_PWM2_DROP_DUTY 0x6C #define F75375_REG_PWM2_DROP_DUTY 0x6C
#define FAN_CTRL_LINEAR(nr) (4 + nr) #define FAN_CTRL_LINEAR(nr) (4 + nr)
#define FAN_CTRL_MODE(nr) (5 + ((nr) * 2)) #define FAN_CTRL_MODE(nr) (4 + ((nr) * 2))
/* /*
* Data structures and manipulation thereof * Data structures and manipulation thereof
...@@ -298,7 +298,7 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val) ...@@ -298,7 +298,7 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
return -EINVAL; return -EINVAL;
fanmode = f75375_read8(client, F75375_REG_FAN_TIMER); fanmode = f75375_read8(client, F75375_REG_FAN_TIMER);
fanmode = ~(3 << FAN_CTRL_MODE(nr)); fanmode &= ~(3 << FAN_CTRL_MODE(nr));
switch (val) { switch (val) {
case 0: /* Full speed */ case 0: /* Full speed */
...@@ -350,7 +350,7 @@ static ssize_t set_pwm_mode(struct device *dev, struct device_attribute *attr, ...@@ -350,7 +350,7 @@ static ssize_t set_pwm_mode(struct device *dev, struct device_attribute *attr,
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
conf = f75375_read8(client, F75375_REG_CONFIG1); conf = f75375_read8(client, F75375_REG_CONFIG1);
conf = ~(1 << FAN_CTRL_LINEAR(nr)); conf &= ~(1 << FAN_CTRL_LINEAR(nr));
if (val == 0) if (val == 0)
conf |= (1 << FAN_CTRL_LINEAR(nr)) ; conf |= (1 << FAN_CTRL_LINEAR(nr)) ;
......
...@@ -121,7 +121,7 @@ static int lis3lv02d_i2c_suspend(struct i2c_client *client, pm_message_t mesg) ...@@ -121,7 +121,7 @@ static int lis3lv02d_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
{ {
struct lis3lv02d *lis3 = i2c_get_clientdata(client); struct lis3lv02d *lis3 = i2c_get_clientdata(client);
if (!lis3->pdata->wakeup_flags) if (!lis3->pdata || !lis3->pdata->wakeup_flags)
lis3lv02d_poweroff(lis3); lis3lv02d_poweroff(lis3);
return 0; return 0;
} }
...@@ -130,7 +130,7 @@ static int lis3lv02d_i2c_resume(struct i2c_client *client) ...@@ -130,7 +130,7 @@ static int lis3lv02d_i2c_resume(struct i2c_client *client)
{ {
struct lis3lv02d *lis3 = i2c_get_clientdata(client); struct lis3lv02d *lis3 = i2c_get_clientdata(client);
if (!lis3->pdata->wakeup_flags) if (!lis3->pdata || !lis3->pdata->wakeup_flags)
lis3lv02d_poweron(lis3); lis3lv02d_poweron(lis3);
return 0; return 0;
} }
......
...@@ -92,7 +92,7 @@ static int lis3lv02d_spi_suspend(struct spi_device *spi, pm_message_t mesg) ...@@ -92,7 +92,7 @@ static int lis3lv02d_spi_suspend(struct spi_device *spi, pm_message_t mesg)
{ {
struct lis3lv02d *lis3 = spi_get_drvdata(spi); struct lis3lv02d *lis3 = spi_get_drvdata(spi);
if (!lis3->pdata->wakeup_flags) if (!lis3->pdata || !lis3->pdata->wakeup_flags)
lis3lv02d_poweroff(&lis3_dev); lis3lv02d_poweroff(&lis3_dev);
return 0; return 0;
...@@ -102,7 +102,7 @@ static int lis3lv02d_spi_resume(struct spi_device *spi) ...@@ -102,7 +102,7 @@ static int lis3lv02d_spi_resume(struct spi_device *spi)
{ {
struct lis3lv02d *lis3 = spi_get_drvdata(spi); struct lis3lv02d *lis3 = spi_get_drvdata(spi);
if (!lis3->pdata->wakeup_flags) if (!lis3->pdata || !lis3->pdata->wakeup_flags)
lis3lv02d_poweron(lis3); lis3lv02d_poweron(lis3);
return 0; return 0;
......
...@@ -91,7 +91,7 @@ static struct lm95241_data *lm95241_update_device(struct device *dev); ...@@ -91,7 +91,7 @@ static struct lm95241_data *lm95241_update_device(struct device *dev);
struct lm95241_data { struct lm95241_data {
struct device *hwmon_dev; struct device *hwmon_dev;
struct mutex update_lock; struct mutex update_lock;
unsigned long last_updated, rate; /* in jiffies */ unsigned long last_updated, interval; /* in jiffies */
char valid; /* zero until following fields are valid */ char valid; /* zero until following fields are valid */
/* registers values */ /* registers values */
u8 local_h, local_l; /* local */ u8 local_h, local_l; /* local */
...@@ -114,23 +114,23 @@ show_temp(local); ...@@ -114,23 +114,23 @@ show_temp(local);
show_temp(remote1); show_temp(remote1);
show_temp(remote2); show_temp(remote2);
static ssize_t show_rate(struct device *dev, struct device_attribute *attr, static ssize_t show_interval(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct lm95241_data *data = lm95241_update_device(dev); struct lm95241_data *data = lm95241_update_device(dev);
snprintf(buf, PAGE_SIZE - 1, "%lu\n", 1000 * data->rate / HZ); snprintf(buf, PAGE_SIZE - 1, "%lu\n", 1000 * data->interval / HZ);
return strlen(buf); return strlen(buf);
} }
static ssize_t set_rate(struct device *dev, struct device_attribute *attr, static ssize_t set_interval(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct lm95241_data *data = i2c_get_clientdata(client); struct lm95241_data *data = i2c_get_clientdata(client);
strict_strtol(buf, 10, &data->rate); strict_strtol(buf, 10, &data->interval);
data->rate = data->rate * HZ / 1000; data->interval = data->interval * HZ / 1000;
return count; return count;
} }
...@@ -286,7 +286,8 @@ static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_min1, set_min1); ...@@ -286,7 +286,8 @@ static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_min1, set_min1);
static DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_min2, set_min2); static DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_min2, set_min2);
static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_max1, set_max1); static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_max1, set_max1);
static DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_max2, set_max2); static DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_max2, set_max2);
static DEVICE_ATTR(rate, S_IWUSR | S_IRUGO, show_rate, set_rate); static DEVICE_ATTR(update_interval, S_IWUSR | S_IRUGO, show_interval,
set_interval);
static struct attribute *lm95241_attributes[] = { static struct attribute *lm95241_attributes[] = {
&dev_attr_temp1_input.attr, &dev_attr_temp1_input.attr,
...@@ -298,7 +299,7 @@ static struct attribute *lm95241_attributes[] = { ...@@ -298,7 +299,7 @@ static struct attribute *lm95241_attributes[] = {
&dev_attr_temp3_min.attr, &dev_attr_temp3_min.attr,
&dev_attr_temp2_max.attr, &dev_attr_temp2_max.attr,
&dev_attr_temp3_max.attr, &dev_attr_temp3_max.attr,
&dev_attr_rate.attr, &dev_attr_update_interval.attr,
NULL NULL
}; };
...@@ -376,7 +377,7 @@ static void lm95241_init_client(struct i2c_client *client) ...@@ -376,7 +377,7 @@ static void lm95241_init_client(struct i2c_client *client)
{ {
struct lm95241_data *data = i2c_get_clientdata(client); struct lm95241_data *data = i2c_get_clientdata(client);
data->rate = HZ; /* 1 sec default */ data->interval = HZ; /* 1 sec default */
data->valid = 0; data->valid = 0;
data->config = CFG_CR0076; data->config = CFG_CR0076;
data->model = 0; data->model = 0;
...@@ -410,7 +411,7 @@ static struct lm95241_data *lm95241_update_device(struct device *dev) ...@@ -410,7 +411,7 @@ static struct lm95241_data *lm95241_update_device(struct device *dev)
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + data->rate) || if (time_after(jiffies, data->last_updated + data->interval) ||
!data->valid) { !data->valid) {
dev_dbg(&client->dev, "Updating lm95241 data.\n"); dev_dbg(&client->dev, "Updating lm95241 data.\n");
data->local_h = data->local_h =
......
...@@ -127,6 +127,7 @@ superio_enter(int ioreg) ...@@ -127,6 +127,7 @@ superio_enter(int ioreg)
static inline void static inline void
superio_exit(int ioreg) superio_exit(int ioreg)
{ {
outb(0xaa, ioreg);
outb(0x02, ioreg); outb(0x02, ioreg);
outb(0x02, ioreg + 1); outb(0x02, ioreg + 1);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment