Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 115517
b: refs/heads/master
c: 69fc1fe
h: refs/heads/master
i:
  115515: b31561b
v: v3
  • Loading branch information
Jean Delvare authored and Jean Delvare committed Oct 17, 2008
1 parent 3cd9972 commit 4af7ad8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 74 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: dbee356262bb1c84cfa585530e33e7003534052a
refs/heads/master: 69fc1feba2d5856ff74dedb6ae9d8c490210825c
123 changes: 50 additions & 73 deletions trunk/drivers/hwmon/lm85.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,6 @@ static void lm85_init_client(struct i2c_client *client)
static int lm85_detect(struct i2c_adapter *adapter, int address,
int kind)
{
int company, verstep;
struct i2c_client *client;
struct lm85_data *data;
int err = 0;
Expand All @@ -1117,10 +1116,6 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
goto ERROR0;
}

/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access lm85_{read,write}_value. */

if (!(data = kzalloc(sizeof(struct lm85_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
Expand All @@ -1132,75 +1127,57 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
client->adapter = adapter;
client->driver = &lm85_driver;

/* Now, we do the remaining detection. */

company = lm85_read_value(client, LM85_REG_COMPANY);
verstep = lm85_read_value(client, LM85_REG_VERSTEP);

dev_dbg(&adapter->dev, "Detecting device at %d,0x%02x with"
" COMPANY: 0x%02x and VERSTEP: 0x%02x\n",
i2c_adapter_id(client->adapter), client->addr,
company, verstep);

/* If auto-detecting, Determine the chip type. */
if (kind <= 0) {
dev_dbg(&adapter->dev, "Autodetecting device at %d,0x%02x ...\n",
i2c_adapter_id(adapter), address);
if (company == LM85_COMPANY_NATIONAL
&& verstep == LM85_VERSTEP_LM85C) {
kind = lm85c;
} else if (company == LM85_COMPANY_NATIONAL
&& verstep == LM85_VERSTEP_LM85B) {
kind = lm85b;
} else if (company == LM85_COMPANY_NATIONAL
&& (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x"
" Defaulting to LM85.\n", verstep);
kind = any_chip;
} else if (company == LM85_COMPANY_ANALOG_DEV
&& verstep == LM85_VERSTEP_ADM1027) {
kind = adm1027;
} else if (company == LM85_COMPANY_ANALOG_DEV
&& (verstep == LM85_VERSTEP_ADT7463
|| verstep == LM85_VERSTEP_ADT7463C)) {
kind = adt7463;
} else if (company == LM85_COMPANY_ANALOG_DEV
&& (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x"
" Defaulting to Generic LM85.\n", verstep);
kind = any_chip;
} else if (company == LM85_COMPANY_SMSC
&& (verstep == LM85_VERSTEP_EMC6D100_A0
|| verstep == LM85_VERSTEP_EMC6D100_A1)) {
/* Unfortunately, we can't tell a '100 from a '101
* from the registers. Since a '101 is a '100
* in a package with fewer pins and therefore no
* 3.3V, 1.5V or 1.8V inputs, perhaps if those
* inputs read 0, then it's a '101.
*/
kind = emc6d100;
} else if (company == LM85_COMPANY_SMSC
&& verstep == LM85_VERSTEP_EMC6D102) {
kind = emc6d102;
} else if (company == LM85_COMPANY_SMSC
&& (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
dev_err(&adapter->dev, "lm85: Detected SMSC chip\n");
dev_err(&adapter->dev, "lm85: Unrecognized version/stepping 0x%02x"
" Defaulting to Generic LM85.\n", verstep);
kind = any_chip;
} else if (kind == any_chip
&& (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
dev_err(&adapter->dev, "Generic LM85 Version 6 detected\n");
/* Leave kind as "any_chip" */
} else {
dev_dbg(&adapter->dev, "Autodetection failed\n");
/* Not an LM85... */
if (kind == any_chip) { /* User used force=x,y */
dev_err(&adapter->dev, "Generic LM85 Version 6 not"
" found at %d,0x%02x. Try force_lm85c.\n",
i2c_adapter_id(adapter), address);
/* If auto-detecting, determine the chip type */
if (kind < 0) {
int company = lm85_read_value(client, LM85_REG_COMPANY);
int verstep = lm85_read_value(client, LM85_REG_VERSTEP);

dev_dbg(&adapter->dev, "Detecting device at 0x%02x with "
"COMPANY: 0x%02x and VERSTEP: 0x%02x\n",
address, company, verstep);

/* All supported chips have the version in common */
if ((verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC) {
dev_dbg(&adapter->dev, "Autodetection failed: "
"unsupported version\n");
goto ERROR1;
}
kind = any_chip;

/* Now, refine the detection */
if (company == LM85_COMPANY_NATIONAL) {
switch (verstep) {
case LM85_VERSTEP_LM85C:
kind = lm85c;
break;
case LM85_VERSTEP_LM85B:
kind = lm85b;
break;
}
} else if (company == LM85_COMPANY_ANALOG_DEV) {
switch (verstep) {
case LM85_VERSTEP_ADM1027:
kind = adm1027;
break;
case LM85_VERSTEP_ADT7463:
case LM85_VERSTEP_ADT7463C:
kind = adt7463;
break;
}
err = 0;
} else if (company == LM85_COMPANY_SMSC) {
switch (verstep) {
case LM85_VERSTEP_EMC6D100_A0:
case LM85_VERSTEP_EMC6D100_A1:
/* Note: we can't tell a '100 from a '101 */
kind = emc6d100;
break;
case LM85_VERSTEP_EMC6D102:
kind = emc6d102;
break;
}
} else {
dev_dbg(&adapter->dev, "Autodetection failed: "
"unknown vendor\n");
goto ERROR1;
}
}
Expand Down

0 comments on commit 4af7ad8

Please sign in to comment.