Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 174300
b: refs/heads/master
c: dbe73c8
h: refs/heads/master
v: v3
  • Loading branch information
Jean Delvare committed Dec 9, 2009
1 parent b764613 commit e4ccda7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 54 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8f2fa77c53ba8c10696143c21b4111d449c85fb2
refs/heads/master: dbe73c8f454a40de06039ec97bc0272f41f1d3c7
55 changes: 26 additions & 29 deletions trunk/drivers/hwmon/tmp401.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,46 +488,43 @@ static void tmp401_init_client(struct i2c_client *client)
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)
{
enum chips kind;
struct i2c_adapter *adapter = client->adapter;
u8 reg;

if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;

/* Detect and identify the chip */
if (kind <= 0) {
u8 reg;

reg = i2c_smbus_read_byte_data(client,
TMP401_MANUFACTURER_ID_REG);
if (reg != TMP401_MANUFACTURER_ID)
return -ENODEV;

reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG);

switch (reg) {
case TMP401_DEVICE_ID:
kind = tmp401;
break;
case TMP411_DEVICE_ID:
kind = tmp411;
break;
default:
return -ENODEV;
}
reg = i2c_smbus_read_byte_data(client, TMP401_MANUFACTURER_ID_REG);
if (reg != TMP401_MANUFACTURER_ID)
return -ENODEV;

reg = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ);
if (reg & 0x1b)
return -ENODEV;
reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG);

reg = i2c_smbus_read_byte_data(client,
TMP401_CONVERSION_RATE_READ);
/* Datasheet says: 0x1-0x6 */
if (reg > 15)
return -ENODEV;
switch (reg) {
case TMP401_DEVICE_ID:
kind = tmp401;
break;
case TMP411_DEVICE_ID:
kind = tmp411;
break;
default:
return -ENODEV;
}

reg = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ);
if (reg & 0x1b)
return -ENODEV;

reg = i2c_smbus_read_byte_data(client, TMP401_CONVERSION_RATE_READ);
/* Datasheet says: 0x1-0x6 */
if (reg > 15)
return -ENODEV;

strlcpy(info->type, tmp401_id[kind - 1].name, I2C_NAME_SIZE);

return 0;
Expand Down
45 changes: 21 additions & 24 deletions trunk/drivers/hwmon/tmp421.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,39 +223,36 @@ static int tmp421_init_client(struct i2c_client *client)
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)
{
enum chips kind;
struct i2c_adapter *adapter = client->adapter;
const char *names[] = { "TMP421", "TMP422", "TMP423" };
u8 reg;

if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;

if (kind <= 0) {
u8 reg;

reg = i2c_smbus_read_byte_data(client,
TMP421_MANUFACTURER_ID_REG);
if (reg != TMP421_MANUFACTURER_ID)
return -ENODEV;

reg = i2c_smbus_read_byte_data(client,
TMP421_DEVICE_ID_REG);
switch (reg) {
case TMP421_DEVICE_ID:
kind = tmp421;
break;
case TMP422_DEVICE_ID:
kind = tmp422;
break;
case TMP423_DEVICE_ID:
kind = tmp423;
break;
default:
return -ENODEV;
}
reg = i2c_smbus_read_byte_data(client, TMP421_MANUFACTURER_ID_REG);
if (reg != TMP421_MANUFACTURER_ID)
return -ENODEV;

reg = i2c_smbus_read_byte_data(client, TMP421_DEVICE_ID_REG);
switch (reg) {
case TMP421_DEVICE_ID:
kind = tmp421;
break;
case TMP422_DEVICE_ID:
kind = tmp422;
break;
case TMP423_DEVICE_ID:
kind = tmp423;
break;
default:
return -ENODEV;
}

strlcpy(info->type, tmp421_id[kind - 1].name, I2C_NAME_SIZE);
dev_info(&adapter->dev, "Detected TI %s chip at 0x%02x\n",
names[kind - 1], client->addr);
Expand Down

0 comments on commit e4ccda7

Please sign in to comment.