diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-06 11:33:09 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-06 11:33:09 -0800 |
commit | dff6d1c5ef9116a4478908001d72ee67127ecf01 (patch) | |
tree | 43c6e7ff8e8059f8fd733efd45b51f84b510d305 /drivers/hwmon/tmp421.c | |
parent | 66ce3cf84deba6cc71dcf43c9d56a4278e5f712d (diff) | |
parent | a0a5e3488a51c46f383c5faa86b53828e30ce153 (diff) | |
download | op-kernel-dev-dff6d1c5ef9116a4478908001d72ee67127ecf01.zip op-kernel-dev-dff6d1c5ef9116a4478908001d72ee67127ecf01.tar.gz |
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: (23 commits)
hwmon: Remove the deprecated adt7473 driver
hwmon: Fix off-by-one kind values
hwmon: (tmp421) Fix temperature conversions
hwmon: (tmp421) Restore missing inputs
hwmon: Driver for Andigilog aSC7621 family monitoring chips
hwmon: (adt7411) Improve locking
hwmon: Add driver for ADT7411 voltage and temperature sensor
hwmon: (w83793) Add watchdog functionality
hwmon: (g760a) Make rpm_from_cnt static
hwmon: (it87) Validate auto pwm settings
hwmon: (it87) Add support for old automatic fan speed control
hwmon: (it87) Drop dead web links in documentation
hwmon: (it87) Add an entry in MAINTAINERS
hwmon: (it87) Use strict_strtol instead of simple_strtol
hwmon: (it87) Fix many checkpatch errors and warnings
hwmon: (it87) Add support for beep on alarm
hwmon: (it87) Create vid attributes by group
hwmon: (it87) Refactor attributes creation and removal
hwmon: (it87) Expose the PWM/temperature mappings
hwmon: (it87) Display fan outputs in automatic mode as such
...
Diffstat (limited to 'drivers/hwmon/tmp421.c')
-rw-r--r-- | drivers/hwmon/tmp421.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/hwmon/tmp421.c b/drivers/hwmon/tmp421.c index 4f7c051..738c472 100644 --- a/drivers/hwmon/tmp421.c +++ b/drivers/hwmon/tmp421.c @@ -61,9 +61,9 @@ static const u8 TMP421_TEMP_LSB[4] = { 0x10, 0x11, 0x12, 0x13 }; #define TMP423_DEVICE_ID 0x23 static const struct i2c_device_id tmp421_id[] = { - { "tmp421", tmp421 }, - { "tmp422", tmp422 }, - { "tmp423", tmp423 }, + { "tmp421", 2 }, + { "tmp422", 3 }, + { "tmp423", 4 }, { } }; MODULE_DEVICE_TABLE(i2c, tmp421_id); @@ -73,21 +73,23 @@ struct tmp421_data { struct mutex update_lock; char valid; unsigned long last_updated; - int kind; + int channels; u8 config; s16 temp[4]; }; static int temp_from_s16(s16 reg) { - int temp = reg; + /* Mask out status bits */ + int temp = reg & ~0xf; return (temp * 1000 + 128) / 256; } static int temp_from_u16(u16 reg) { - int temp = reg; + /* Mask out status bits */ + int temp = reg & ~0xf; /* Add offset for extended temperature range. */ temp -= 64 * 256; @@ -107,7 +109,7 @@ static struct tmp421_data *tmp421_update_device(struct device *dev) data->config = i2c_smbus_read_byte_data(client, TMP421_CONFIG_REG_1); - for (i = 0; i <= data->kind; i++) { + for (i = 0; i < data->channels; i++) { data->temp[i] = i2c_smbus_read_byte_data(client, TMP421_TEMP_MSB[i]) << 8; data->temp[i] |= i2c_smbus_read_byte_data(client, @@ -166,7 +168,7 @@ static mode_t tmp421_is_visible(struct kobject *kobj, struct attribute *a, devattr = container_of(a, struct device_attribute, attr); index = to_sensor_dev_attr(devattr)->index; - if (data->kind > index) + if (index < data->channels) return a->mode; return 0; @@ -252,9 +254,9 @@ static int tmp421_detect(struct i2c_client *client, return -ENODEV; } - strlcpy(info->type, tmp421_id[kind - 1].name, I2C_NAME_SIZE); + strlcpy(info->type, tmp421_id[kind].name, I2C_NAME_SIZE); dev_info(&adapter->dev, "Detected TI %s chip at 0x%02x\n", - names[kind - 1], client->addr); + names[kind], client->addr); return 0; } @@ -271,7 +273,7 @@ static int tmp421_probe(struct i2c_client *client, i2c_set_clientdata(client, data); mutex_init(&data->update_lock); - data->kind = id->driver_data; + data->channels = id->driver_data; err = tmp421_init_client(client); if (err) |