Skip to contentSkip to conversation

i2c-core error messages

lm-sensors Kai Svahn 2 participants 5 messages Mar 6, 2006

lore
Share & tools
lore

Kai Svahn

author
#0 lore raw

Hello all,

I was just wondering is there a reason that in i2c.core.c file, i2c_probe function returns 0 when there is an error? I changed the code a bit for my own chip driver to know that we fail and then I return negative value.
I noticed this problem when I had HW with faulty chip that communicates through i2c.

I can post a patch if you want.

Cheers,
Kai

#1 lore raw

Hi Kay,

Quoted 4 lines · Kai Svahn

I was just wondering is there a reason that in i2c.core.c file, i2c_probe function returns 0 when there is an error? I changed the code a bit for my own chip driver to know that we fail and then I return negative value.

Which version of the i2c-core.c file are you referring to, please? The file Linux 2.6.16-rc5 has an i2c_probe function which properly returns errors.

Thanks,
--
Jean Delvare

author
#2 lore raw
In reply to Kai Svahn

Hello,

Quoted 4 lines · ext Jean Delvare

Which version of the i2c-core.c file are you referring to, please? The file Linux 2.6.16-rc5 has an i2c_probe function which properly returns errors.

I have rc5 and I found a problem here
static int i2c_probe_address(struct i2c_adapter *adapter, int addr, int kind,
int (*found_proc) (struct i2c_adapter *,int, int)

---line 664---

if (kind < 0) {
	if (i2c_smbus_xfer(adapter, addr, 0, 0, 0,
		I2C_SMBUS_QUICK, NULL) < 0)
		return 0;
	      }

---
Shouldn't it be something like, or have I misunderstood something here?

if (kind < 0) {
	if ((err = (i2c_smbus_xfer(adapter, addr, 0, 0, 0,
	I2C_SMBUS_QUICK, NULL)) < 0)
	return err;
	      }

Cheers,
Kai

#3 lore raw
In reply to Kai Svahn

Hi Kai,

Quoted 7 lines · Kai Svahn
Quoted 3 lines

Which version of the i2c-core.c file are you referring to, please? The file Linux 2.6.16-rc5 has an i2c_probe function which properly returns errors.

I have rc5 and I found a problem here
static int i2c_probe_address(struct i2c_adapter *adapter, int addr,
int kind, int (*found_proc) (struct i2c_adapter *,int, int)

Ah, so it was function i2c_probe_address, not i2c_probe.

Quoted 6 lines

---line 664---

if (kind < 0) {
	if (i2c_smbus_xfer(adapter, addr, 0, 0, 0,
		          I2C_SMBUS_QUICK, NULL) < 0)
		return 0;
}
Quoted 8 lines

---
Shouldn't it be something like, or have I misunderstood something here?

if (kind < 0) {
	if ((err = (i2c_smbus_xfer(adapter, addr, 0, 0, 0,
	                           I2C_SMBUS_QUICK, NULL)) < 0)
		return err;
}

No, we return 0 on purpose.

Each driver lists the possible addresses for the device(s) it supports. More often than not, only one of these addresses will hold a real chip on a given system (unless the same chip is used several times in a given design.) Other address probes are expected to fail, so this is not an error.

The real problem here is that the design of our probing mechanism is not suitable for every design. When you know where your chip is, it's a bit frustrating that you have to let the i2c-core probe and find out by itself, especially when it makes it harder to detect errors.

A new explicit attach method is being worked on (for quite some time now...) which should hopefully help in this type of situation. A preliminary patch can be seen here:
http://khali.linux-fr.org/devel/i2c/linux-2.6/i2c-probe-04-explicit-attach.patch
But I need some real life uses to make sure it's properly designed. I wanted to experiment on the zoran media/video driver, but didn't quite find the time to do that yet.

Thanks,
--
Jean Delvare

author
#4 lore raw
In reply to Kai Svahn

Hello,

Quoted 2 lines · ext Jean Delvare

Ah, so it was function i2c_probe_address, not i2c_probe.

Yeah sorry about that I wrote at the first time just from my memory didn't look the code my mistake :) .

Quoted 24 lines
Quoted 7 lines

---line 664---

if (kind < 0) {
	if (i2c_smbus_xfer(adapter, addr, 0, 0, 0,
		          I2C_SMBUS_QUICK, NULL) < 0)
		return 0;
}
Quoted 8 lines

---
Shouldn't it be something like, or have I misunderstood something here?

if (kind < 0) {
	if ((err = (i2c_smbus_xfer(adapter, addr, 0, 0, 0,
	                           I2C_SMBUS_QUICK, NULL)) < 0)
		return err;
}

No, we return 0 on purpose.

Each driver lists the possible addresses for the device(s) it supports. More often than not, only one of these addresses will hold a real chip on a given system (unless the same chip is used several times in a given design.) Other address probes are expected to fail, so this is not an error.

Quoted 4 lines

The real problem here is that the design of our probing mechanism is not suitable for every design. When you know where your chip is, it's a bit frustrating that you have to let the i2c-core probe and find out by itself, especially when it makes it harder to detect errors.

Yes, that I found out it was kinda hard to debug but I found a solution for the problem without changing this.

Quoted 7 lines

A new explicit attach method is being worked on (for quite some time now...) which should hopefully help in this type of situation. A preliminary patch can be seen here:
http://khali.linux-fr.org/devel/i2c/linux-2.6/i2c-probe-04-explicit-attach.patch
But I need some real life uses to make sure it's properly designed. I wanted to experiment on the zoran media/video driver, but didn't quite find the time to do that yet.

Sounds nice I can take a look at it also and maybe try it out.

Quoted 3 lines

Thanks,
--
Jean Delvarei

Thank you about the information.

Cheers,
Kai