From 52df6440a29123eed912183fe785bbe174ef14b9 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 9 Dec 2009 20:35:57 +0100 Subject: hwmon: Clean up detect functions As kind is now hard-coded to -1, there is room for code clean-ups. Signed-off-by: Jean Delvare Acked-by: Corentin Labbe Cc: "Mark M. Hoffman" Cc: Juerg Haefliger Cc: Riku Voipio Acked-by: "Hans J. Koch" Cc: Rudolf Marek --- drivers/hwmon/lm95241.c | 48 ++++++++++-------------------------------------- 1 file changed, 10 insertions(+), 38 deletions(-) (limited to 'drivers/hwmon/lm95241.c') diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c index e34f9e402a2c..906b896cf1d0 100644 --- a/drivers/hwmon/lm95241.c +++ b/drivers/hwmon/lm95241.c @@ -315,51 +315,23 @@ static int lm95241_detect(struct i2c_client *new_client, int kind, { struct i2c_adapter *adapter = new_client->adapter; int address = new_client->addr; - const char *name = ""; + const char *name; 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. - */ - if (kind < 0) { /* detection */ - if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID) - != MANUFACTURER_ID) - || (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) - < DEFAULT_REVISION)) { - dev_dbg(&adapter->dev, - "LM95241 detection failed at 0x%02x.\n", - address); - return -ENODEV; - } - } - - if (kind <= 0) { /* identification */ - if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID) - == MANUFACTURER_ID) - && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) - >= DEFAULT_REVISION)) { - - kind = lm95241; - - if (kind <= 0) { /* identification failed */ - dev_info(&adapter->dev, "Unsupported chip\n"); - return -ENODEV; - } - } + if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID) + == MANUFACTURER_ID) + && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) + >= DEFAULT_REVISION)) { + name = "lm95241"; + } else { + dev_dbg(&adapter->dev, "LM95241 detection failed at 0x%02x\n", + address); + return -ENODEV; } /* Fill the i2c board info */ - if (kind == lm95241) - name = "lm95241"; strlcpy(info->type, name, I2C_NAME_SIZE); return 0; } -- cgit v1.2.3