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/adm1025.c | |
parent | 78f1ae193d1662c22cfebb916e788e1ca896c0fe (diff) | |
parent | 54fe4671aa5853ca88da72d67e969a3d8de6dcf6 (diff) |
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/adm1025.c')
-rw-r--r-- | drivers/hwmon/adm1025.c | 73 |
1 files changed, 20 insertions, 53 deletions
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 4db04d603ec..db6ac2b04f6 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c @@ -2,7 +2,7 @@ * adm1025.c * * Copyright (C) 2000 Chen-Yuan Wu <gwu@esoft.com> - * Copyright (C) 2003-2008 Jean Delvare <khali@linux-fr.org> + * Copyright (C) 2003-2009 Jean Delvare <khali@linux-fr.org> * * The ADM1025 is a sensor chip made by Analog Devices. It reports up to 6 * voltages (including its own power source) and up to two temperatures @@ -413,67 +413,34 @@ static int adm1025_detect(struct i2c_client *client, int kind, struct i2c_board_info *info) { struct i2c_adapter *adapter = client->adapter; - const char *name = ""; - u8 config; + const char *name; + u8 man_id, chip_id; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -ENODEV; - /* - * Now we do the remaining detection. A negative kind means that - * the driver was loaded with no force parameter (default), so we - * must both detect and identify the chip. A zero kind means that - * the driver was loaded with the force parameter, the detection - * step shall be skipped. A positive kind means that the driver - * was loaded with the force parameter and a given kind of chip is - * requested, so both the detection and the identification steps - * are skipped. - */ - config = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG); - if (kind < 0) { /* detection */ - if ((config & 0x80) != 0x00 - || (i2c_smbus_read_byte_data(client, - ADM1025_REG_STATUS1) & 0xC0) != 0x00 - || (i2c_smbus_read_byte_data(client, - ADM1025_REG_STATUS2) & 0xBC) != 0x00) { - dev_dbg(&adapter->dev, - "ADM1025 detection failed at 0x%02x.\n", - client->addr); - return -ENODEV; - } + /* Check for unused bits */ + if ((i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG) & 0x80) + || (i2c_smbus_read_byte_data(client, ADM1025_REG_STATUS1) & 0xC0) + || (i2c_smbus_read_byte_data(client, ADM1025_REG_STATUS2) & 0xBC)) { + dev_dbg(&adapter->dev, "ADM1025 detection failed at 0x%02x\n", + client->addr); + return -ENODEV; } - if (kind <= 0) { /* identification */ - u8 man_id, chip_id; - - man_id = i2c_smbus_read_byte_data(client, ADM1025_REG_MAN_ID); - chip_id = i2c_smbus_read_byte_data(client, ADM1025_REG_CHIP_ID); - - if (man_id == 0x41) { /* Analog Devices */ - if ((chip_id & 0xF0) == 0x20) { /* ADM1025/ADM1025A */ - kind = adm1025; - } - } else - if (man_id == 0xA1) { /* Philips */ - if (client->addr != 0x2E - && (chip_id & 0xF0) == 0x20) { /* NE1619 */ - kind = ne1619; - } - } - - if (kind <= 0) { /* identification failed */ - dev_info(&adapter->dev, - "Unsupported chip (man_id=0x%02X, " - "chip_id=0x%02X).\n", man_id, chip_id); - return -ENODEV; - } - } + /* Identification */ + chip_id = i2c_smbus_read_byte_data(client, ADM1025_REG_CHIP_ID); + if ((chip_id & 0xF0) != 0x20) + return -ENODEV; - if (kind == adm1025) { + man_id = i2c_smbus_read_byte_data(client, ADM1025_REG_MAN_ID); + if (man_id == 0x41) name = "adm1025"; - } else if (kind == ne1619) { + else if (man_id == 0xA1 && client->addr != 0x2E) name = "ne1619"; - } + else + return -ENODEV; + strlcpy(info->type, name, I2C_NAME_SIZE); return 0; |