Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 253109
b: refs/heads/master
c: 942c1a9
h: refs/heads/master
i:
  253107: 767e785
v: v3
  • Loading branch information
Per Dalén authored and Guenter Roeck committed Jun 4, 2011
1 parent bea762c commit 822d004
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 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: bb9973e4e73f43bd86698483d0c3f7a362ff94ce
refs/heads/master: 942c1a927bf296fd64fd49f04c5a8f66bb14446b
18 changes: 16 additions & 2 deletions trunk/drivers/hwmon/max6642.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,29 @@ static int max6642_detect(struct i2c_client *client,
if (man_id != 0x4D)
return -ENODEV;

/* sanity check */
if (i2c_smbus_read_byte_data(client, 0x04) != 0x4D
|| i2c_smbus_read_byte_data(client, 0x06) != 0x4D
|| i2c_smbus_read_byte_data(client, 0xff) != 0x4D)
return -ENODEV;

/*
* We read the config and status register, the 4 lower bits in the
* config register should be zero and bit 5, 3, 1 and 0 should be
* zero in the status register.
*/
reg_config = i2c_smbus_read_byte_data(client, MAX6642_REG_R_CONFIG);
if ((reg_config & 0x0f) != 0x00)
return -ENODEV;

/* in between, another round of sanity checks */
if (i2c_smbus_read_byte_data(client, 0x04) != reg_config
|| i2c_smbus_read_byte_data(client, 0x06) != reg_config
|| i2c_smbus_read_byte_data(client, 0xff) != reg_config)
return -ENODEV;

reg_status = i2c_smbus_read_byte_data(client, MAX6642_REG_R_STATUS);
if (((reg_config & 0x0f) != 0x00) ||
((reg_status & 0x2b) != 0x00))
if ((reg_status & 0x2b) != 0x00)
return -ENODEV;

strlcpy(info->type, "max6642", I2C_NAME_SIZE);
Expand Down

0 comments on commit 822d004

Please sign in to comment.