hwmon: (tmp401/tmp421) Clean up detect functions
As kind is now hard-coded to -1, there is room for code clean-ups. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Andre Prendel <andre.prendel@gmx.de>
This commit is contained in:
@@ -488,20 +488,18 @@ static void tmp401_init_client(struct i2c_client *client)
|
|||||||
i2c_smbus_write_byte_data(client, TMP401_CONFIG_WRITE, config);
|
i2c_smbus_write_byte_data(client, TMP401_CONFIG_WRITE, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tmp401_detect(struct i2c_client *client, int kind,
|
static int tmp401_detect(struct i2c_client *client, int _kind,
|
||||||
struct i2c_board_info *info)
|
struct i2c_board_info *info)
|
||||||
{
|
{
|
||||||
|
enum chips kind;
|
||||||
struct i2c_adapter *adapter = client->adapter;
|
struct i2c_adapter *adapter = client->adapter;
|
||||||
|
u8 reg;
|
||||||
|
|
||||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
/* Detect and identify the chip */
|
/* Detect and identify the chip */
|
||||||
if (kind <= 0) {
|
reg = i2c_smbus_read_byte_data(client, TMP401_MANUFACTURER_ID_REG);
|
||||||
u8 reg;
|
|
||||||
|
|
||||||
reg = i2c_smbus_read_byte_data(client,
|
|
||||||
TMP401_MANUFACTURER_ID_REG);
|
|
||||||
if (reg != TMP401_MANUFACTURER_ID)
|
if (reg != TMP401_MANUFACTURER_ID)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
@@ -522,12 +520,11 @@ static int tmp401_detect(struct i2c_client *client, int kind,
|
|||||||
if (reg & 0x1b)
|
if (reg & 0x1b)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
reg = i2c_smbus_read_byte_data(client,
|
reg = i2c_smbus_read_byte_data(client, TMP401_CONVERSION_RATE_READ);
|
||||||
TMP401_CONVERSION_RATE_READ);
|
|
||||||
/* Datasheet says: 0x1-0x6 */
|
/* Datasheet says: 0x1-0x6 */
|
||||||
if (reg > 15)
|
if (reg > 15)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
|
||||||
strlcpy(info->type, tmp401_id[kind - 1].name, I2C_NAME_SIZE);
|
strlcpy(info->type, tmp401_id[kind - 1].name, I2C_NAME_SIZE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -223,25 +223,22 @@ static int tmp421_init_client(struct i2c_client *client)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tmp421_detect(struct i2c_client *client, int kind,
|
static int tmp421_detect(struct i2c_client *client, int _kind,
|
||||||
struct i2c_board_info *info)
|
struct i2c_board_info *info)
|
||||||
{
|
{
|
||||||
|
enum chips kind;
|
||||||
struct i2c_adapter *adapter = client->adapter;
|
struct i2c_adapter *adapter = client->adapter;
|
||||||
const char *names[] = { "TMP421", "TMP422", "TMP423" };
|
const char *names[] = { "TMP421", "TMP422", "TMP423" };
|
||||||
|
u8 reg;
|
||||||
|
|
||||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
if (kind <= 0) {
|
reg = i2c_smbus_read_byte_data(client, TMP421_MANUFACTURER_ID_REG);
|
||||||
u8 reg;
|
|
||||||
|
|
||||||
reg = i2c_smbus_read_byte_data(client,
|
|
||||||
TMP421_MANUFACTURER_ID_REG);
|
|
||||||
if (reg != TMP421_MANUFACTURER_ID)
|
if (reg != TMP421_MANUFACTURER_ID)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
reg = i2c_smbus_read_byte_data(client,
|
reg = i2c_smbus_read_byte_data(client, TMP421_DEVICE_ID_REG);
|
||||||
TMP421_DEVICE_ID_REG);
|
|
||||||
switch (reg) {
|
switch (reg) {
|
||||||
case TMP421_DEVICE_ID:
|
case TMP421_DEVICE_ID:
|
||||||
kind = tmp421;
|
kind = tmp421;
|
||||||
@@ -255,7 +252,7 @@ static int tmp421_detect(struct i2c_client *client, int kind,
|
|||||||
default:
|
default:
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
strlcpy(info->type, tmp421_id[kind - 1].name, I2C_NAME_SIZE);
|
strlcpy(info->type, tmp421_id[kind - 1].name, I2C_NAME_SIZE);
|
||||||
dev_info(&adapter->dev, "Detected TI %s chip at 0x%02x\n",
|
dev_info(&adapter->dev, "Detected TI %s chip at 0x%02x\n",
|
||||||
names[kind - 1], client->addr);
|
names[kind - 1], client->addr);
|
||||||
|
Reference in New Issue
Block a user