2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-30 22:05:11 +00:00

Do not return negative values to i2c_detect on non-fatal errors.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2837 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2005-01-07 20:21:58 +00:00
parent da76debaa5
commit aa1f43f680
8 changed files with 17 additions and 44 deletions

View File

@@ -228,10 +228,8 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
if (kind < 0) {
if ((adm1021_read_value(new_client, ADM1021_REG_STATUS) & 0x03) != 0x00
|| (adm1021_read_value(new_client, ADM1021_REG_CONFIG_R) & 0x3F) != 0x00
|| (adm1021_read_value(new_client, ADM1021_REG_CONV_RATE_R) & 0xF8) != 0x00) {
err = -ENODEV;
|| (adm1021_read_value(new_client, ADM1021_REG_CONV_RATE_R) & 0xF8) != 0x00)
goto error1;
}
}
/* Determine the chip type. */

View File

@@ -357,7 +357,7 @@ static int asb100_attach_adapter(struct i2c_adapter *adapter)
static int asb100_detect_subclients(struct i2c_adapter *adapter, int address,
int kind, struct i2c_client *new_client)
{
int i, id, err;
int i, id, err = 0;
struct asb100_data *data = new_client->data;
data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
@@ -383,7 +383,6 @@ static int asb100_detect_subclients(struct i2c_adapter *adapter, int address,
printk(KERN_ERR "asb100.o: invalid subclient "
"address %d; must be 0x48-0x4f\n",
force_subclients[i]);
err = -ENODEV;
goto ERROR_SC_2;
}
}
@@ -401,7 +400,6 @@ static int asb100_detect_subclients(struct i2c_adapter *adapter, int address,
if(data->lm75[0]->addr == data->lm75[1]->addr) {
printk(KERN_ERR "asb100.o: duplicate addresses 0x%x "
"for subclients\n", data->lm75[0]->addr);
err = -ENODEV;
goto ERROR_SC_2;
}
@@ -441,7 +439,7 @@ ERROR_SC_0:
static int asb100_detect(struct i2c_adapter *adapter, int address,
unsigned short flags, int kind)
{
int err;
int err = 0;
struct i2c_client *new_client;
struct asb100_data *data;
@@ -449,14 +447,12 @@ static int asb100_detect(struct i2c_adapter *adapter, int address,
if (i2c_is_isa_adapter(adapter)) {
pr_debug("asb100.o: detect failed, "
"cannot attach to legacy adapter!\n");
err = -ENODEV;
goto ERROR0;
}
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
pr_debug("asb100.o: detect failed, "
"smbus byte data not supported!\n");
err = -ENODEV;
goto ERROR0;
}
@@ -497,7 +493,6 @@ static int asb100_detect(struct i2c_adapter *adapter, int address,
((val1 & 0x80) && (val2 != 0x06)) ) ) {
pr_debug("asb100.o: detect failed, "
"bad chip id 0x%02x!\n", val2);
err = -ENODEV;
goto ERROR1;
}
@@ -521,7 +516,6 @@ static int asb100_detect(struct i2c_adapter *adapter, int address,
"'force' parameter for unknown chip "
"at adapter %d, address 0x%02x.\n",
i2c_adapter_id(adapter), address);
err = -ENODEV;
goto ERROR1;
}
}

View File

@@ -469,7 +469,7 @@ int it87_detect(struct i2c_adapter *adapter, int address,
if (inb_p(address + 2) != i
|| inb_p(address + 3) != i
|| inb_p(address + 7) != i)
return -ENODEV;
return 0;
#undef REALLY_SLOW_IO
/* Let's just hope nothing breaks here */
@@ -477,7 +477,7 @@ int it87_detect(struct i2c_adapter *adapter, int address,
outb_p(~i & 0x7f, address + 5);
if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) {
outb_p(i, address + 5);
return -ENODEV;
return 0;
}
}
@@ -504,10 +504,8 @@ int it87_detect(struct i2c_adapter *adapter, int address,
if (kind < 0) {
if ((it87_read_value(new_client, IT87_REG_CONFIG) & 0x80)
|| (!is_isa
&& it87_read_value(new_client, IT87_REG_I2C_ADDR) != address)) {
err = -ENODEV;
&& it87_read_value(new_client, IT87_REG_I2C_ADDR) != address))
goto ERROR1;
}
}
/* Determine the chip type. */
@@ -522,7 +520,6 @@ int it87_detect(struct i2c_adapter *adapter, int address,
("it87.o: Ignoring 'force' parameter for unknown chip at "
"adapter %d, address 0x%02x\n",
i2c_adapter_id(adapter), address);
err = -ENODEV;
goto ERROR1;
}
}

View File

@@ -302,11 +302,11 @@ static int lm92_detect (struct i2c_adapter *adapter,int address,unsigned short f
static int id = 0;
struct i2c_client *client;
lm92_t *data;
int result;
int result = 0;
u16 manufacturer;
if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA))
return (-ENODEV);
return 0;
if (!(data = kmalloc(sizeof(lm92_t), GFP_KERNEL)))
return (-ENOMEM);
@@ -331,7 +331,6 @@ static int lm92_detect (struct i2c_adapter *adapter,int address,unsigned short f
|| manufacturer != LM92_MANUFACTURER_ID)) {
/* Is it a MAX6635/MAX6635/MAX6635? */
if (!max6635_check(client)) {
result = -ENODEV;
goto ERROR2;
}
}

View File

@@ -2187,7 +2187,7 @@ static struct i2c_driver lm93_driver;
static int lm93_detect(struct i2c_adapter *adapter, int address,
unsigned short flags, int kind)
{
int err, func;
int err = 0, func;
struct lm93_data *data;
struct i2c_client *client;
void (*update)(struct lm93_data *, struct i2c_client *);
@@ -2196,7 +2196,6 @@ static int lm93_detect(struct i2c_adapter *adapter, int address,
if (i2c_is_isa_adapter(adapter)) {
pr_debug("lm93.o: detect failed, "
"cannot attach to legacy adapter!\n");
err = -ENODEV;
goto ERROR0;
}
@@ -2213,7 +2212,6 @@ static int lm93_detect(struct i2c_adapter *adapter, int address,
} else {
pr_debug("lm93.o: detect failed, "
"smbus byte and/or word data not supported!\n");
err = -ENODEV;
goto ERROR0;
}
@@ -2242,7 +2240,6 @@ static int lm93_detect(struct i2c_adapter *adapter, int address,
if (mfr != 0x01) {
pr_debug("lm93.o: detect failed, "
"bad manufacturer id 0x%02x!\n", mfr);
err = -ENODEV;
goto ERROR1;
}
}
@@ -2258,7 +2255,6 @@ static int lm93_detect(struct i2c_adapter *adapter, int address,
if (kind == 0)
pr_debug("lm93.o: "
"(ignored 'force' parameter)\n");
err = -ENODEV;
goto ERROR1;
}
}

View File

@@ -125,10 +125,8 @@ int pca9540_detect(struct i2c_adapter *adapter, int address,
if ((reg & 0xfa) != 0x00
|| reg != i2c_smbus_read_byte(new_client)
|| reg != i2c_smbus_read_byte(new_client)
|| reg != i2c_smbus_read_byte(new_client)) {
err = -ENODEV;
|| reg != i2c_smbus_read_byte(new_client))
goto ERROR1;
}
}
kind = pca9540;

View File

@@ -324,7 +324,6 @@ int pca954x_detect(struct i2c_adapter *adapter, int address,
printk(KERN_WARNING
"i2c-%d: pca954x.o failed to read reg at %0x",
i2c_adapter_id(adapter), address);
err = -ENODEV;
goto ERROR1;
}
data->origval = i;

View File

@@ -840,28 +840,24 @@ static int w83781d_detect(struct i2c_adapter *adapter, int address,
bank. */
if (kind < 0) {
if (w83781d_read_value(new_client, W83781D_REG_CONFIG) &
0x80) {
err = -ENODEV;
0x80)
goto ERROR1;
}
val1 = w83781d_read_value(new_client, W83781D_REG_BANK);
val2 = w83781d_read_value(new_client, W83781D_REG_CHIPMAN);
/* Check for Winbond or Asus ID if in bank 0 */
if ((!(val1 & 0x07)) &&
(((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3))
|| ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12)))) {
err = -ENODEV;
|| ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12))))
goto ERROR1;
}
/* If Winbond SMBus, check address at 0x48.
Asus doesn't support, except for the as99127f rev.2 */
if ((!is_isa) && (((!(val1 & 0x80)) && (val2 == 0xa3)) ||
((val1 & 0x80) && (val2 == 0x5c)))) {
if (w83781d_read_value
(new_client, W83781D_REG_I2C_ADDR) != address) {
err = -ENODEV;
(new_client, W83781D_REG_I2C_ADDR) != address)
goto ERROR1;
}
}
}
@@ -880,10 +876,9 @@ static int w83781d_detect(struct i2c_adapter *adapter, int address,
vendid = winbond;
else if (val2 == 0x12)
vendid = asus;
else {
err = -ENODEV;
else
goto ERROR1;
}
val1 =
w83781d_read_value(new_client, W83781D_REG_WCHIPID);
if ((val1 == 0x10 || val1 == 0x11) && vendid == winbond)
@@ -906,7 +901,6 @@ static int w83781d_detect(struct i2c_adapter *adapter, int address,
(KERN_WARNING "w83781d.o: Ignoring 'force' parameter for unknown chip at"
"adapter %d, address 0x%02x\n",
i2c_adapter_id(adapter), address);
err = -EINVAL;
goto ERROR1;
}
}
@@ -971,7 +965,6 @@ static int w83781d_detect(struct i2c_adapter *adapter, int address,
force_subclients[i] > 0x4f) {
printk(KERN_ERR "w83781d.o: Invalid subclient address %d; must be 0x48-0x4f\n",
force_subclients[i]);
err = -EINVAL;
goto ERROR5;
}
}
@@ -995,7 +988,6 @@ static int w83781d_detect(struct i2c_adapter *adapter, int address,
if(data->lm75[0].addr == data->lm75[1].addr) {
printk(KERN_ERR "w83781d.o: Duplicate addresses 0x%x for subclients.\n",
data->lm75[0].addr);
err = -EBUSY;
goto ERROR5;
}
}