diff options
Diffstat (limited to 'drivers/hwmon/lm75.c')
-rw-r--r-- | drivers/hwmon/lm75.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index ef902d5d06a..1888dd0fc05 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -35,6 +35,7 @@ */ enum lm75_type { /* keep sorted in alphabetical order */ + adt75, ds1775, ds75, lm75, @@ -213,6 +214,7 @@ static int lm75_remove(struct i2c_client *client) } static const struct i2c_device_id lm75_ids[] = { + { "adt75", adt75, }, { "ds1775", ds1775, }, { "ds75", ds75, }, { "lm75", lm75, }, @@ -247,19 +249,30 @@ static int lm75_detect(struct i2c_client *new_client, I2C_FUNC_SMBUS_WORD_DATA)) return -ENODEV; - /* Now, we do the remaining detection. There is no identification- - dedicated register so we have to rely on several tricks: - unused bits, registers cycling over 8-address boundaries, - addresses 0x04-0x07 returning the last read value. - The cycling+unused addresses combination is not tested, - since it would significantly slow the detection down and would - hardly add any value. - - The National Semiconductor LM75A is different than earlier - LM75s. It has an ID byte of 0xaX (where X is the chip - revision, with 1 being the only revision in existence) in - register 7, and unused registers return 0xff rather than the - last read value. */ + /* + * Now, we do the remaining detection. There is no identification- + * dedicated register so we have to rely on several tricks: + * unused bits, registers cycling over 8-address boundaries, + * addresses 0x04-0x07 returning the last read value. + * The cycling+unused addresses combination is not tested, + * since it would significantly slow the detection down and would + * hardly add any value. + * + * The National Semiconductor LM75A is different than earlier + * LM75s. It has an ID byte of 0xaX (where X is the chip + * revision, with 1 being the only revision in existence) in + * register 7, and unused registers return 0xff rather than the + * last read value. + * + * Note that this function only detects the original National + * Semiconductor LM75 and the LM75A. Clones from other vendors + * aren't detected, on purpose, because they are typically never + * found on PC hardware. They are found on embedded designs where + * they can be instantiated explicitly so detection is not needed. + * The absence of identification registers on all these clones + * would make their exhaustive detection very difficult and weak, + * and odds are that the driver would bind to unsupported devices. + */ /* Unused bits */ conf = i2c_smbus_read_byte_data(new_client, 1); @@ -371,13 +384,10 @@ static struct i2c_driver lm75_driver = { */ static int lm75_read_value(struct i2c_client *client, u8 reg) { - int value; - if (reg == LM75_REG_CONF) return i2c_smbus_read_byte_data(client, reg); - - value = i2c_smbus_read_word_data(client, reg); - return (value < 0) ? value : swab16(value); + else + return i2c_smbus_read_word_swapped(client, reg); } static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) @@ -385,7 +395,7 @@ static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) if (reg == LM75_REG_CONF) return i2c_smbus_write_byte_data(client, reg, value); else - return i2c_smbus_write_word_data(client, reg, swab16(value)); + return i2c_smbus_write_word_swapped(client, reg, value); } static struct lm75_data *lm75_update_device(struct device *dev) |