Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 273578
b: refs/heads/master
c: 24d6e2a
h: refs/heads/master
v: v3
  • Loading branch information
Jean Delvare authored and Jean Delvare committed Nov 4, 2011
1 parent 2abc409 commit aff5b42
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 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: 746cdfbf01c0a30d59f6e1b6942d432658d7c7cd
refs/heads/master: 24d6e2a89a1ff0a035f163a83a2812a3192083b6
22 changes: 18 additions & 4 deletions trunk/drivers/hwmon/lm73.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,31 @@ static int lm73_detect(struct i2c_client *new_client,
struct i2c_board_info *info)
{
struct i2c_adapter *adapter = new_client->adapter;
u16 id;
u8 ctrl;
int id, ctrl, conf;

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

/*
* Do as much detection as possible with byte reads first, as word
* reads can confuse other devices.
*/
ctrl = i2c_smbus_read_byte_data(new_client, LM73_REG_CTRL);
if (ctrl < 0 || (ctrl & 0x10))
return -ENODEV;

conf = i2c_smbus_read_byte_data(new_client, LM73_REG_CONF);
if (conf < 0 || (conf & 0x0c))
return -ENODEV;

id = i2c_smbus_read_byte_data(new_client, LM73_REG_ID);
if (id < 0 || id != (LM73_ID & 0xff))
return -ENODEV;

/* Check device ID */
id = i2c_smbus_read_word_data(new_client, LM73_REG_ID);
ctrl = i2c_smbus_read_byte_data(new_client, LM73_REG_CTRL);
if ((id != LM73_ID) || (ctrl & 0x10))
if (id < 0 || id != LM73_ID)
return -ENODEV;

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

0 comments on commit aff5b42

Please sign in to comment.