diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-09 19:53:11 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-09 19:53:11 -0800 |
commit | f71eaf68406cfee91b6a96bcdf7ce33dc78829c5 (patch) | |
tree | 92a1663ae15d521f25849d28ebb4dfad10567892 /drivers/hwmon/lm87.c | |
parent | 78f1ae193d1662c22cfebb916e788e1ca896c0fe (diff) | |
parent | 54fe4671aa5853ca88da72d67e969a3d8de6dcf6 (diff) | |
download | talos-op-linux-f71eaf68406cfee91b6a96bcdf7ce33dc78829c5.tar.gz talos-op-linux-f71eaf68406cfee91b6a96bcdf7ce33dc78829c5.zip |
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: (41 commits)
hwmon: (adt7475) Add VID support for the ADT7476
hwmon: (adt7475) Add an entry in MAINTAINERS
hwmon: (adt7475) Add support for the ADT7476
hwmon: (adt7475) Voltage attenuators can be bypassed
hwmon: (adt7475) Print device information on probe
hwmon: (adt7475) Handle alternative pin functions
hwmon: (adt7475) Move sysfs files removal to a separate function
hwmon: (adt7475) Add support for the ADT7490
hwmon: (adt7475) Improve device detection
hwmon: (adt7475) Add missing static marker
hwmon: (adt7475) Rework voltage inputs handling
hwmon: (adt7475) Implement pwm_use_point2_pwm_at_crit
hwmon: (adt7475) New documentation
hwmon: (adt7475) Add support for the ADT7473
hwmon: (f71882fg) Add support for the f71889fg (version 2)
hwmon: (f71882fg) Fix sysfs file removal
hwmon: (f71882fg) Cleanup sysfs attr creation 2/2
hwmon: (f71882fg) Cleanup sysfs attr creation 1/2
hwmon: (thmc50) Stop using I2C_CLIENT_MODULE_PARM
hwmon: Add Freescale MC13783 ADC driver
...
Diffstat (limited to 'drivers/hwmon/lm87.c')
-rw-r--r-- | drivers/hwmon/lm87.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 2e4a3cea95f7..4929b1815eee 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -666,37 +666,32 @@ static int lm87_detect(struct i2c_client *new_client, int kind, struct i2c_board_info *info) { struct i2c_adapter *adapter = new_client->adapter; - static const char *names[] = { "lm87", "adm1024" }; + const char *name; + u8 cid, rev; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -ENODEV; - /* Default to an LM87 if forced */ - if (kind == 0) - kind = lm87; + if (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80) + return -ENODEV; /* Now, we do the remaining detection. */ - if (kind < 0) { - u8 cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID); - u8 rev = lm87_read_value(new_client, LM87_REG_REVISION); - - if (cid == 0x02 /* National Semiconductor */ - && (rev >= 0x01 && rev <= 0x08)) - kind = lm87; - else if (cid == 0x41 /* Analog Devices */ - && (rev & 0xf0) == 0x10) - kind = adm1024; - - if (kind < 0 - || (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80)) { - dev_dbg(&adapter->dev, - "LM87 detection failed at 0x%02x.\n", - new_client->addr); - return -ENODEV; - } + cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID); + rev = lm87_read_value(new_client, LM87_REG_REVISION); + + if (cid == 0x02 /* National Semiconductor */ + && (rev >= 0x01 && rev <= 0x08)) + name = "lm87"; + else if (cid == 0x41 /* Analog Devices */ + && (rev & 0xf0) == 0x10) + name = "adm1024"; + else { + dev_dbg(&adapter->dev, "LM87 detection failed at 0x%02x\n", + new_client->addr); + return -ENODEV; } - strlcpy(info->type, names[kind - 1], I2C_NAME_SIZE); + strlcpy(info->type, name, I2C_NAME_SIZE); return 0; } |