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/lm83.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/lm83.c')
-rw-r--r-- | drivers/hwmon/lm83.c | 81 |
1 files changed, 26 insertions, 55 deletions
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index e59e2d1f080..08b03e6ed0b 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c @@ -1,7 +1,7 @@ /* * lm83.c - Part of lm_sensors, Linux kernel modules for hardware * monitoring - * Copyright (C) 2003-2008 Jean Delvare <khali@linux-fr.org> + * Copyright (C) 2003-2009 Jean Delvare <khali@linux-fr.org> * * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is * a sensor chip made by National Semiconductor. It reports up to four @@ -295,69 +295,40 @@ static int lm83_detect(struct i2c_client *new_client, int kind, struct i2c_board_info *info) { struct i2c_adapter *adapter = new_client->adapter; - const char *name = ""; + const char *name; + u8 man_id, chip_id; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -ENODEV; - /* Now we do the detection and identification. A negative kind - * means that the driver was loaded with no force parameter - * (default), so we must both detect and identify the chip - * (actually there is only one possible kind of chip for now, LM83). - * 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. */ - - /* Default to an LM83 if forced */ - if (kind == 0) - kind = lm83; - - if (kind < 0) { /* detection */ - if (((i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS1) - & 0xA8) != 0x00) || - ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS2) - & 0x48) != 0x00) || - ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_CONFIG) - & 0x41) != 0x00)) { - dev_dbg(&adapter->dev, - "LM83 detection failed at 0x%02x.\n", - new_client->addr); - return -ENODEV; - } + /* Detection */ + if ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS1) & 0xA8) || + (i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS2) & 0x48) || + (i2c_smbus_read_byte_data(new_client, LM83_REG_R_CONFIG) & 0x41)) { + dev_dbg(&adapter->dev, "LM83 detection failed at 0x%02x\n", + new_client->addr); + return -ENODEV; } - if (kind <= 0) { /* identification */ - u8 man_id, chip_id; - - man_id = i2c_smbus_read_byte_data(new_client, - LM83_REG_R_MAN_ID); - chip_id = i2c_smbus_read_byte_data(new_client, - LM83_REG_R_CHIP_ID); - - if (man_id == 0x01) { /* National Semiconductor */ - if (chip_id == 0x03) { - kind = lm83; - } else - if (chip_id == 0x01) { - kind = lm82; - } - } - - 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 */ + man_id = i2c_smbus_read_byte_data(new_client, LM83_REG_R_MAN_ID); + if (man_id != 0x01) /* National Semiconductor */ + return -ENODEV; - if (kind == lm83) { + chip_id = i2c_smbus_read_byte_data(new_client, LM83_REG_R_CHIP_ID); + switch (chip_id) { + case 0x03: name = "lm83"; - } else - if (kind == lm82) { + break; + case 0x01: name = "lm82"; + break; + default: + /* identification failed */ + dev_info(&adapter->dev, + "Unsupported chip (man_id=0x%02X, chip_id=0x%02X)\n", + man_id, chip_id); + return -ENODEV; } strlcpy(info->type, name, I2C_NAME_SIZE); |