mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-09-01 23:05:25 +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:
@@ -228,11 +228,9 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
|
|||||||
if (kind < 0) {
|
if (kind < 0) {
|
||||||
if ((adm1021_read_value(new_client, ADM1021_REG_STATUS) & 0x03) != 0x00
|
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_CONFIG_R) & 0x3F) != 0x00
|
||||||
|| (adm1021_read_value(new_client, ADM1021_REG_CONV_RATE_R) & 0xF8) != 0x00) {
|
|| (adm1021_read_value(new_client, ADM1021_REG_CONV_RATE_R) & 0xF8) != 0x00)
|
||||||
err = -ENODEV;
|
|
||||||
goto error1;
|
goto error1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Determine the chip type. */
|
/* Determine the chip type. */
|
||||||
|
|
||||||
|
@@ -357,7 +357,7 @@ static int asb100_attach_adapter(struct i2c_adapter *adapter)
|
|||||||
static int asb100_detect_subclients(struct i2c_adapter *adapter, int address,
|
static int asb100_detect_subclients(struct i2c_adapter *adapter, int address,
|
||||||
int kind, struct i2c_client *new_client)
|
int kind, struct i2c_client *new_client)
|
||||||
{
|
{
|
||||||
int i, id, err;
|
int i, id, err = 0;
|
||||||
struct asb100_data *data = new_client->data;
|
struct asb100_data *data = new_client->data;
|
||||||
|
|
||||||
data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
|
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 "
|
printk(KERN_ERR "asb100.o: invalid subclient "
|
||||||
"address %d; must be 0x48-0x4f\n",
|
"address %d; must be 0x48-0x4f\n",
|
||||||
force_subclients[i]);
|
force_subclients[i]);
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR_SC_2;
|
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) {
|
if(data->lm75[0]->addr == data->lm75[1]->addr) {
|
||||||
printk(KERN_ERR "asb100.o: duplicate addresses 0x%x "
|
printk(KERN_ERR "asb100.o: duplicate addresses 0x%x "
|
||||||
"for subclients\n", data->lm75[0]->addr);
|
"for subclients\n", data->lm75[0]->addr);
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR_SC_2;
|
goto ERROR_SC_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,7 +439,7 @@ ERROR_SC_0:
|
|||||||
static int asb100_detect(struct i2c_adapter *adapter, int address,
|
static int asb100_detect(struct i2c_adapter *adapter, int address,
|
||||||
unsigned short flags, int kind)
|
unsigned short flags, int kind)
|
||||||
{
|
{
|
||||||
int err;
|
int err = 0;
|
||||||
struct i2c_client *new_client;
|
struct i2c_client *new_client;
|
||||||
struct asb100_data *data;
|
struct asb100_data *data;
|
||||||
|
|
||||||
@@ -449,14 +447,12 @@ static int asb100_detect(struct i2c_adapter *adapter, int address,
|
|||||||
if (i2c_is_isa_adapter(adapter)) {
|
if (i2c_is_isa_adapter(adapter)) {
|
||||||
pr_debug("asb100.o: detect failed, "
|
pr_debug("asb100.o: detect failed, "
|
||||||
"cannot attach to legacy adapter!\n");
|
"cannot attach to legacy adapter!\n");
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR0;
|
goto ERROR0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
|
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
|
||||||
pr_debug("asb100.o: detect failed, "
|
pr_debug("asb100.o: detect failed, "
|
||||||
"smbus byte data not supported!\n");
|
"smbus byte data not supported!\n");
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR0;
|
goto ERROR0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +493,6 @@ static int asb100_detect(struct i2c_adapter *adapter, int address,
|
|||||||
((val1 & 0x80) && (val2 != 0x06)) ) ) {
|
((val1 & 0x80) && (val2 != 0x06)) ) ) {
|
||||||
pr_debug("asb100.o: detect failed, "
|
pr_debug("asb100.o: detect failed, "
|
||||||
"bad chip id 0x%02x!\n", val2);
|
"bad chip id 0x%02x!\n", val2);
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,7 +516,6 @@ static int asb100_detect(struct i2c_adapter *adapter, int address,
|
|||||||
"'force' parameter for unknown chip "
|
"'force' parameter for unknown chip "
|
||||||
"at adapter %d, address 0x%02x.\n",
|
"at adapter %d, address 0x%02x.\n",
|
||||||
i2c_adapter_id(adapter), address);
|
i2c_adapter_id(adapter), address);
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -469,7 +469,7 @@ int it87_detect(struct i2c_adapter *adapter, int address,
|
|||||||
if (inb_p(address + 2) != i
|
if (inb_p(address + 2) != i
|
||||||
|| inb_p(address + 3) != i
|
|| inb_p(address + 3) != i
|
||||||
|| inb_p(address + 7) != i)
|
|| inb_p(address + 7) != i)
|
||||||
return -ENODEV;
|
return 0;
|
||||||
#undef REALLY_SLOW_IO
|
#undef REALLY_SLOW_IO
|
||||||
|
|
||||||
/* Let's just hope nothing breaks here */
|
/* 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);
|
outb_p(~i & 0x7f, address + 5);
|
||||||
if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) {
|
if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) {
|
||||||
outb_p(i, address + 5);
|
outb_p(i, address + 5);
|
||||||
return -ENODEV;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,11 +504,9 @@ int it87_detect(struct i2c_adapter *adapter, int address,
|
|||||||
if (kind < 0) {
|
if (kind < 0) {
|
||||||
if ((it87_read_value(new_client, IT87_REG_CONFIG) & 0x80)
|
if ((it87_read_value(new_client, IT87_REG_CONFIG) & 0x80)
|
||||||
|| (!is_isa
|
|| (!is_isa
|
||||||
&& it87_read_value(new_client, IT87_REG_I2C_ADDR) != address)) {
|
&& it87_read_value(new_client, IT87_REG_I2C_ADDR) != address))
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Determine the chip type. */
|
/* Determine the chip type. */
|
||||||
if (kind <= 0) {
|
if (kind <= 0) {
|
||||||
@@ -522,7 +520,6 @@ int it87_detect(struct i2c_adapter *adapter, int address,
|
|||||||
("it87.o: Ignoring 'force' parameter for unknown chip at "
|
("it87.o: Ignoring 'force' parameter for unknown chip at "
|
||||||
"adapter %d, address 0x%02x\n",
|
"adapter %d, address 0x%02x\n",
|
||||||
i2c_adapter_id(adapter), address);
|
i2c_adapter_id(adapter), address);
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -302,11 +302,11 @@ static int lm92_detect (struct i2c_adapter *adapter,int address,unsigned short f
|
|||||||
static int id = 0;
|
static int id = 0;
|
||||||
struct i2c_client *client;
|
struct i2c_client *client;
|
||||||
lm92_t *data;
|
lm92_t *data;
|
||||||
int result;
|
int result = 0;
|
||||||
u16 manufacturer;
|
u16 manufacturer;
|
||||||
|
|
||||||
if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA))
|
if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA))
|
||||||
return (-ENODEV);
|
return 0;
|
||||||
|
|
||||||
if (!(data = kmalloc(sizeof(lm92_t), GFP_KERNEL)))
|
if (!(data = kmalloc(sizeof(lm92_t), GFP_KERNEL)))
|
||||||
return (-ENOMEM);
|
return (-ENOMEM);
|
||||||
@@ -331,7 +331,6 @@ static int lm92_detect (struct i2c_adapter *adapter,int address,unsigned short f
|
|||||||
|| manufacturer != LM92_MANUFACTURER_ID)) {
|
|| manufacturer != LM92_MANUFACTURER_ID)) {
|
||||||
/* Is it a MAX6635/MAX6635/MAX6635? */
|
/* Is it a MAX6635/MAX6635/MAX6635? */
|
||||||
if (!max6635_check(client)) {
|
if (!max6635_check(client)) {
|
||||||
result = -ENODEV;
|
|
||||||
goto ERROR2;
|
goto ERROR2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2187,7 +2187,7 @@ static struct i2c_driver lm93_driver;
|
|||||||
static int lm93_detect(struct i2c_adapter *adapter, int address,
|
static int lm93_detect(struct i2c_adapter *adapter, int address,
|
||||||
unsigned short flags, int kind)
|
unsigned short flags, int kind)
|
||||||
{
|
{
|
||||||
int err, func;
|
int err = 0, func;
|
||||||
struct lm93_data *data;
|
struct lm93_data *data;
|
||||||
struct i2c_client *client;
|
struct i2c_client *client;
|
||||||
void (*update)(struct lm93_data *, struct i2c_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)) {
|
if (i2c_is_isa_adapter(adapter)) {
|
||||||
pr_debug("lm93.o: detect failed, "
|
pr_debug("lm93.o: detect failed, "
|
||||||
"cannot attach to legacy adapter!\n");
|
"cannot attach to legacy adapter!\n");
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR0;
|
goto ERROR0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2213,7 +2212,6 @@ static int lm93_detect(struct i2c_adapter *adapter, int address,
|
|||||||
} else {
|
} else {
|
||||||
pr_debug("lm93.o: detect failed, "
|
pr_debug("lm93.o: detect failed, "
|
||||||
"smbus byte and/or word data not supported!\n");
|
"smbus byte and/or word data not supported!\n");
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR0;
|
goto ERROR0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2242,7 +2240,6 @@ static int lm93_detect(struct i2c_adapter *adapter, int address,
|
|||||||
if (mfr != 0x01) {
|
if (mfr != 0x01) {
|
||||||
pr_debug("lm93.o: detect failed, "
|
pr_debug("lm93.o: detect failed, "
|
||||||
"bad manufacturer id 0x%02x!\n", mfr);
|
"bad manufacturer id 0x%02x!\n", mfr);
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2258,7 +2255,6 @@ static int lm93_detect(struct i2c_adapter *adapter, int address,
|
|||||||
if (kind == 0)
|
if (kind == 0)
|
||||||
pr_debug("lm93.o: "
|
pr_debug("lm93.o: "
|
||||||
"(ignored 'force' parameter)\n");
|
"(ignored 'force' parameter)\n");
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -125,11 +125,9 @@ int pca9540_detect(struct i2c_adapter *adapter, int address,
|
|||||||
if ((reg & 0xfa) != 0x00
|
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)
|
|| reg != i2c_smbus_read_byte(new_client)
|
||||||
|| reg != i2c_smbus_read_byte(new_client)) {
|
|| reg != i2c_smbus_read_byte(new_client))
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
kind = pca9540;
|
kind = pca9540;
|
||||||
|
|
||||||
|
@@ -324,7 +324,6 @@ int pca954x_detect(struct i2c_adapter *adapter, int address,
|
|||||||
printk(KERN_WARNING
|
printk(KERN_WARNING
|
||||||
"i2c-%d: pca954x.o failed to read reg at %0x",
|
"i2c-%d: pca954x.o failed to read reg at %0x",
|
||||||
i2c_adapter_id(adapter), address);
|
i2c_adapter_id(adapter), address);
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
}
|
||||||
data->origval = i;
|
data->origval = i;
|
||||||
|
@@ -840,30 +840,26 @@ static int w83781d_detect(struct i2c_adapter *adapter, int address,
|
|||||||
bank. */
|
bank. */
|
||||||
if (kind < 0) {
|
if (kind < 0) {
|
||||||
if (w83781d_read_value(new_client, W83781D_REG_CONFIG) &
|
if (w83781d_read_value(new_client, W83781D_REG_CONFIG) &
|
||||||
0x80) {
|
0x80)
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
|
||||||
val1 = w83781d_read_value(new_client, W83781D_REG_BANK);
|
val1 = w83781d_read_value(new_client, W83781D_REG_BANK);
|
||||||
val2 = w83781d_read_value(new_client, W83781D_REG_CHIPMAN);
|
val2 = w83781d_read_value(new_client, W83781D_REG_CHIPMAN);
|
||||||
/* Check for Winbond or Asus ID if in bank 0 */
|
/* Check for Winbond or Asus ID if in bank 0 */
|
||||||
if ((!(val1 & 0x07)) &&
|
if ((!(val1 & 0x07)) &&
|
||||||
(((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3))
|
(((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3))
|
||||||
|| ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12)))) {
|
|| ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12))))
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
|
||||||
/* If Winbond SMBus, check address at 0x48.
|
/* If Winbond SMBus, check address at 0x48.
|
||||||
Asus doesn't support, except for the as99127f rev.2 */
|
Asus doesn't support, except for the as99127f rev.2 */
|
||||||
if ((!is_isa) && (((!(val1 & 0x80)) && (val2 == 0xa3)) ||
|
if ((!is_isa) && (((!(val1 & 0x80)) && (val2 == 0xa3)) ||
|
||||||
((val1 & 0x80) && (val2 == 0x5c)))) {
|
((val1 & 0x80) && (val2 == 0x5c)))) {
|
||||||
if (w83781d_read_value
|
if (w83781d_read_value
|
||||||
(new_client, W83781D_REG_I2C_ADDR) != address) {
|
(new_client, W83781D_REG_I2C_ADDR) != address)
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* We have either had a force parameter, or we have already detected the
|
/* We have either had a force parameter, or we have already detected the
|
||||||
Winbond. Put it now into bank 0 and Vendor ID High Byte */
|
Winbond. Put it now into bank 0 and Vendor ID High Byte */
|
||||||
@@ -880,10 +876,9 @@ static int w83781d_detect(struct i2c_adapter *adapter, int address,
|
|||||||
vendid = winbond;
|
vendid = winbond;
|
||||||
else if (val2 == 0x12)
|
else if (val2 == 0x12)
|
||||||
vendid = asus;
|
vendid = asus;
|
||||||
else {
|
else
|
||||||
err = -ENODEV;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
|
||||||
val1 =
|
val1 =
|
||||||
w83781d_read_value(new_client, W83781D_REG_WCHIPID);
|
w83781d_read_value(new_client, W83781D_REG_WCHIPID);
|
||||||
if ((val1 == 0x10 || val1 == 0x11) && vendid == winbond)
|
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"
|
(KERN_WARNING "w83781d.o: Ignoring 'force' parameter for unknown chip at"
|
||||||
"adapter %d, address 0x%02x\n",
|
"adapter %d, address 0x%02x\n",
|
||||||
i2c_adapter_id(adapter), address);
|
i2c_adapter_id(adapter), address);
|
||||||
err = -EINVAL;
|
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -971,7 +965,6 @@ static int w83781d_detect(struct i2c_adapter *adapter, int address,
|
|||||||
force_subclients[i] > 0x4f) {
|
force_subclients[i] > 0x4f) {
|
||||||
printk(KERN_ERR "w83781d.o: Invalid subclient address %d; must be 0x48-0x4f\n",
|
printk(KERN_ERR "w83781d.o: Invalid subclient address %d; must be 0x48-0x4f\n",
|
||||||
force_subclients[i]);
|
force_subclients[i]);
|
||||||
err = -EINVAL;
|
|
||||||
goto ERROR5;
|
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) {
|
if(data->lm75[0].addr == data->lm75[1].addr) {
|
||||||
printk(KERN_ERR "w83781d.o: Duplicate addresses 0x%x for subclients.\n",
|
printk(KERN_ERR "w83781d.o: Duplicate addresses 0x%x for subclients.\n",
|
||||||
data->lm75[0].addr);
|
data->lm75[0].addr);
|
||||||
err = -EBUSY;
|
|
||||||
goto ERROR5;
|
goto ERROR5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user