From 809307768cb177621b8f45f87fa840993ca4cb60 Mon Sep 17 00:00:00 2001 From: Craig Kelley Date: Fri, 29 Feb 2008 10:24:44 -0700 Subject: hwmon: (smsc47b397) add a new chip id (0x8c) Added a new ID (0x8c) for the smsc47b397 hardware monitor driver. This ID is used by HP in, at least, their dc7700 line. Signed-off-by: Craig Kelley Signed-off-by: Mark M. Hoffman --- drivers/hwmon/smsc47b397.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'drivers/hwmon') diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 0b57d2ea2cf..54187bf25d3 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c @@ -331,11 +331,23 @@ exit: static int __init smsc47b397_find(unsigned short *addr) { u8 id, rev; + char *name; superio_enter(); id = superio_inb(SUPERIO_REG_DEVID); - if ((id != 0x6f) && (id != 0x81) && (id != 0x85)) { + switch(id) { + case 0x81: + name = "SCH5307-NS"; + break; + case 0x6f: + name = "LPC47B397-NC"; + break; + case 0x85: + case 0x8c: + name = "SCH5317"; + break; + default: superio_exit(); return -ENODEV; } @@ -348,8 +360,7 @@ static int __init smsc47b397_find(unsigned short *addr) printk(KERN_INFO DRVNAME ": found SMSC %s " "(base address 0x%04x, revision %u)\n", - id == 0x81 ? "SCH5307-NS" : id == 0x85 ? "SCH5317" : - "LPC47B397-NC", *addr, rev); + name, *addr, rev); superio_exit(); return 0; -- cgit v1.2.3 From 4040c415f5566ecfe95b509ee84d68fb7050b30c Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 12 Feb 2008 11:17:26 +0100 Subject: hwmon: (w83l785ts) Don't ask the user to report failures There's nothing we can do about read errors on the W83L785TS-S, so don't ask the user to report them. Signed-off-by: Jean Delvare Signed-off-by: Mark M. Hoffman --- drivers/hwmon/w83l785ts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/hwmon') diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 77f2d482888..52e268e25da 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c @@ -301,8 +301,8 @@ static u8 w83l785ts_read_value(struct i2c_client *client, u8 reg, u8 defval) msleep(i); } - dev_err(&client->dev, "Couldn't read value from register 0x%02x. " - "Please report.\n", reg); + dev_err(&client->dev, "Couldn't read value from register 0x%02x.\n", + reg); return defval; } -- cgit v1.2.3 From 93c75a4ac2d95834e7202965d853d3cd23aadb40 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 12 Feb 2008 11:25:07 +0100 Subject: hwmon: (w83793) VID and VRM handling cleanups * Rework the device initialization function so as to read the "Multi-Function Pin Control" register (0x58) once instead of twice. I2C transactions aren't cheap so this speeds up the driver loading. * Only create the "vrm" attribute if at least one VID value is available. Signed-off-by: Jean Delvare Cc: Gong Jun Acked-by: Rudolf Marek Signed-off-by: Mark M. Hoffman --- drivers/hwmon/w83793.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'drivers/hwmon') diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c index ee35af93b57..ed3c019b78c 100644 --- a/drivers/hwmon/w83793.c +++ b/drivers/hwmon/w83793.c @@ -1024,10 +1024,9 @@ static struct sensor_device_attribute_2 w83793_vid[] = { SENSOR_ATTR_2(cpu0_vid, S_IRUGO, show_vid, NULL, NOT_USED, 0), SENSOR_ATTR_2(cpu1_vid, S_IRUGO, show_vid, NULL, NOT_USED, 1), }; +static DEVICE_ATTR(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm); static struct sensor_device_attribute_2 sda_single_files[] = { - SENSOR_ATTR_2(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm, - NOT_USED, NOT_USED), SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep, store_chassis_clear, ALARM_STATUS, 30), SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable, @@ -1080,6 +1079,7 @@ static int w83793_detach_client(struct i2c_client *client) for (i = 0; i < ARRAY_SIZE(w83793_vid); i++) device_remove_file(dev, &w83793_vid[i].dev_attr); + device_remove_file(dev, &dev_attr_vrm); for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++) device_remove_file(dev, &w83793_left_fan[i].dev_attr); @@ -1282,7 +1282,6 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind) /* Initialize the chip */ w83793_init_client(client); - data->vrm = vid_which_vrm(); /* Only fan 1-5 has their own input pins, Pwm 1-3 has their own pins @@ -1293,7 +1292,9 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind) val = w83793_read_value(client, W83793_REG_FANIN_CTRL); /* check the function of pins 49-56 */ - if (!(tmp & 0x80)) { + if (tmp & 0x80) { + data->has_vid |= 0x2; /* has VIDB */ + } else { data->has_pwm |= 0x18; /* pwm 4,5 */ if (val & 0x01) { /* fan 6 */ data->has_fan |= 0x20; @@ -1309,13 +1310,15 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind) } } + /* check the function of pins 37-40 */ + if (!(tmp & 0x29)) + data->has_vid |= 0x1; /* has VIDA */ if (0x08 == (tmp & 0x0c)) { if (val & 0x08) /* fan 9 */ data->has_fan |= 0x100; if (val & 0x10) /* fan 10 */ data->has_fan |= 0x200; } - if (0x20 == (tmp & 0x30)) { if (val & 0x20) /* fan 11 */ data->has_fan |= 0x400; @@ -1359,13 +1362,6 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind) if (tmp & 0x02) data->has_temp |= 0x20; - /* Detect the VID usage and ignore unused input */ - tmp = w83793_read_value(client, W83793_REG_MFC); - if (!(tmp & 0x29)) - data->has_vid |= 0x1; /* has VIDA */ - if (tmp & 0x80) - data->has_vid |= 0x2; /* has VIDB */ - /* Register sysfs hooks */ for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) { err = device_create_file(dev, @@ -1381,6 +1377,12 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind) if (err) goto exit_remove; } + if (data->has_vid) { + data->vrm = vid_which_vrm(); + err = device_create_file(dev, &dev_attr_vrm); + if (err) + goto exit_remove; + } for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) { err = device_create_file(dev, &sda_single_files[i].dev_attr); -- cgit v1.2.3 From ccd6befceb9a9b02114a93ff4cfa29adbdf60b6d Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 19 Feb 2008 12:42:58 +0100 Subject: hwmon: (lm75) Fix an incorrect comment High-byte first is not opposite to the usual practice - that's what almost all hardware monitoring drivers do. It is opposite to the SMBus standard though. Also delete a duplicate comment. Signed-off-by: Jean Delvare Signed-off-by: Mark M. Hoffman --- drivers/hwmon/lm75.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/hwmon') diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 115f4090b98..fa769690515 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -248,7 +248,7 @@ static int lm75_detach_client(struct i2c_client *client) /* All registers are word-sized, except for the configuration register. LM75 uses a high-byte first convention, which is exactly opposite to - the usual practice. */ + the SMBus standard. */ static int lm75_read_value(struct i2c_client *client, u8 reg) { if (reg == LM75_REG_CONF) @@ -257,9 +257,6 @@ static int lm75_read_value(struct i2c_client *client, u8 reg) return swab16(i2c_smbus_read_word_data(client, reg)); } -/* All registers are word-sized, except for the configuration register. - LM75 uses a high-byte first convention, which is exactly opposite to - the usual practice. */ static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) { if (reg == LM75_REG_CONF) -- cgit v1.2.3 From 5d822e9bd9d866672984c6a6b613f0c11ca2543b Mon Sep 17 00:00:00 2001 From: "Mark M. Hoffman" Date: Tue, 26 Feb 2008 08:48:49 -0500 Subject: hwmon: (asb100) Remove some dead code Acked-by: Jean Delvare Signed-off-by: Mark M. Hoffman --- drivers/hwmon/asb100.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/hwmon') diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 84712a22ace..fe2eea4d799 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -953,12 +953,8 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value) static void asb100_init_client(struct i2c_client *client) { struct asb100_data *data = i2c_get_clientdata(client); - int vid = 0; - vid = asb100_read_value(client, ASB100_REG_VID_FANDIV) & 0x0f; - vid |= (asb100_read_value(client, ASB100_REG_CHIPID) & 0x01) << 4; data->vrm = vid_which_vrm(); - vid = vid_from_reg(vid, data->vrm); /* Start monitoring */ asb100_write_value(client, ASB100_REG_CONFIG, -- cgit v1.2.3 From 1852448652fd526d56099256dadc4ef32cb1b10e Mon Sep 17 00:00:00 2001 From: "Mark M. Hoffman" Date: Thu, 6 Mar 2008 08:41:09 -0500 Subject: hwmon: (adt7473) minor cleanup / refactoring Acked-by: Darrick J. Wong Signed-off-by: Mark M. Hoffman --- drivers/hwmon/adt7473.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'drivers/hwmon') diff --git a/drivers/hwmon/adt7473.c b/drivers/hwmon/adt7473.c index 9587869bdba..c1009d6f979 100644 --- a/drivers/hwmon/adt7473.c +++ b/drivers/hwmon/adt7473.c @@ -422,18 +422,14 @@ static ssize_t show_volt(struct device *dev, struct device_attribute *devattr, * number in the range -128 to 127, or as an unsigned number that must * be offset by 64. */ -static int decode_temp(struct adt7473_data *data, u8 raw) +static int decode_temp(u8 twos_complement, u8 raw) { - if (data->temp_twos_complement) - return (s8)raw; - return raw - 64; + return twos_complement ? (s8)raw : raw - 64; } -static u8 encode_temp(struct adt7473_data *data, int cooked) +static u8 encode_temp(u8 twos_complement, int cooked) { - if (data->temp_twos_complement) - return (cooked & 0xFF); - return cooked + 64; + return twos_complement ? cooked & 0xFF : cooked + 64; } static ssize_t show_temp_min(struct device *dev, @@ -442,8 +438,9 @@ static ssize_t show_temp_min(struct device *dev, { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7473_data *data = adt7473_update_device(dev); - return sprintf(buf, "%d\n", - 1000 * decode_temp(data, data->temp_min[attr->index])); + return sprintf(buf, "%d\n", 1000 * decode_temp( + data->temp_twos_complement, + data->temp_min[attr->index])); } static ssize_t set_temp_min(struct device *dev, @@ -455,7 +452,7 @@ static ssize_t set_temp_min(struct device *dev, struct i2c_client *client = to_i2c_client(dev); struct adt7473_data *data = i2c_get_clientdata(client); int temp = simple_strtol(buf, NULL, 10) / 1000; - temp = encode_temp(data, temp); + temp = encode_temp(data->temp_twos_complement, temp); mutex_lock(&data->lock); data->temp_min[attr->index] = temp; @@ -472,8 +469,9 @@ static ssize_t show_temp_max(struct device *dev, { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7473_data *data = adt7473_update_device(dev); - return sprintf(buf, "%d\n", - 1000 * decode_temp(data, data->temp_max[attr->index])); + return sprintf(buf, "%d\n", 1000 * decode_temp( + data->temp_twos_complement, + data->temp_max[attr->index])); } static ssize_t set_temp_max(struct device *dev, @@ -485,7 +483,7 @@ static ssize_t set_temp_max(struct device *dev, struct i2c_client *client = to_i2c_client(dev); struct adt7473_data *data = i2c_get_clientdata(client); int temp = simple_strtol(buf, NULL, 10) / 1000; - temp = encode_temp(data, temp); + temp = encode_temp(data->temp_twos_complement, temp); mutex_lock(&data->lock); data->temp_max[attr->index] = temp; @@ -501,8 +499,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7473_data *data = adt7473_update_device(dev); - return sprintf(buf, "%d\n", - 1000 * decode_temp(data, data->temp[attr->index])); + return sprintf(buf, "%d\n", 1000 * decode_temp( + data->temp_twos_complement, + data->temp[attr->index])); } static ssize_t show_fan_min(struct device *dev, @@ -671,8 +670,9 @@ static ssize_t show_temp_tmax(struct device *dev, { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7473_data *data = adt7473_update_device(dev); - return sprintf(buf, "%d\n", - 1000 * decode_temp(data, data->temp_tmax[attr->index])); + return sprintf(buf, "%d\n", 1000 * decode_temp( + data->temp_twos_complement, + data->temp_tmax[attr->index])); } static ssize_t set_temp_tmax(struct device *dev, @@ -684,7 +684,7 @@ static ssize_t set_temp_tmax(struct device *dev, struct i2c_client *client = to_i2c_client(dev); struct adt7473_data *data = i2c_get_clientdata(client); int temp = simple_strtol(buf, NULL, 10) / 1000; - temp = encode_temp(data, temp); + temp = encode_temp(data->temp_twos_complement, temp); mutex_lock(&data->lock); data->temp_tmax[attr->index] = temp; @@ -701,8 +701,9 @@ static ssize_t show_temp_tmin(struct device *dev, { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7473_data *data = adt7473_update_device(dev); - return sprintf(buf, "%d\n", - 1000 * decode_temp(data, data->temp_tmin[attr->index])); + return sprintf(buf, "%d\n", 1000 * decode_temp( + data->temp_twos_complement, + data->temp_tmin[attr->index])); } static ssize_t set_temp_tmin(struct device *dev, @@ -714,7 +715,7 @@ static ssize_t set_temp_tmin(struct device *dev, struct i2c_client *client = to_i2c_client(dev); struct adt7473_data *data = i2c_get_clientdata(client); int temp = simple_strtol(buf, NULL, 10) / 1000; - temp = encode_temp(data, temp); + temp = encode_temp(data->temp_twos_complement, temp); mutex_lock(&data->lock); data->temp_tmin[attr->index] = temp; -- cgit v1.2.3