Skip to contentSkip to conversation

i2c adapter scan device issue

DISCUSSION Lanttor 2 participants 4 messages Nov 25, 2009 3 messages not in the archive I2C subsystem host drivers

lore
Share & tools
lore

Lanttor

author
#0 lore raw

Hi,

I have a confused problem as follows:

I instantiate a i2c device with function i2c_register_board_info(); This function pre-declare the I2C devices which live on this bus and the call of it
is before the real i2c bus driver loaded.

In i2c_register_board_info(),
__i2c_first_dynamic_bus_num = busnum +1;

My i2c bus driver use i2c_add_adapter() to register adapter, In i2c_add_adapter(),
res = idr_get_new_above(&i2c_adapter_idr, adapter,

                                __i2c_first_dynamic_bus_num , &id);

adapter->nr = id;

That means if I pass busnum 0 to i2c_register_board_info(), but my i2c adapter will get
busnum 1 and so it can't scan pre-declared i2c devices.
In fact, I only have one i2c adapter.

It seems I can't use i2c_add_adapter(), instead of using i2c_add_numbered_adapter, right?

Best Regards,
Lanttor

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 19 lines · Lanttor

Hi,

I have a confused problem as follows:

I instantiate a i2c device with function i2c_register_board_info(); This function pre-declare the I2C devices which live on this bus and the call of it
is before the real i2c bus driver loaded.

In i2c_register_board_info(),
__i2c_first_dynamic_bus_num = busnum +1;

My i2c bus driver use i2c_add_adapter() to register adapter, In i2c_add_adapter(),
res = idr_get_new_above(&i2c_adapter_idr, adapter,

                                __i2c_first_dynamic_bus_num , &id);

adapter->nr = id;

Quoted 7 lines

That means if I pass busnum 0 to i2c_register_board_info(), but my i2c adapter will get
busnum 1 and so it can't scan pre-declared i2c devices.
In fact, I only have one i2c adapter.

It seems I can't use i2c_add_adapter(), instead of using i2c_add_numbered_adapter, right?

Yes, you are correct. You can't predefine I2C devices with i2c_register_board_info() if you don't also set I2C adapter numbers with i2c_add_numbered_adapter(). Trying would be equivalent to sending a letter to someone when you know the city and street number but not the street name: unlikely to succeed.

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#4 lore raw
Quoted 7 lines

Yes, you are correct. You can't predefine I2C devices with i2c_register_board_info() if you don't also set I2C adapter numbers with i2c_add_numbered_adapter(). Trying would be equivalent to sending a letter to someone when you know the city and street number but not the street name: unlikely to succeed.

Thanks Jean.

In fact my bus driver used i2c_add_adapter() not i2c_add_numbered_adapter(). Now I use i2c_add_numbered_adapter() to replace 2c_add_adapter() and set the bus number first.

In one word, you mean that i2c_add_adapter() can not work normally if useing i2c_register_board_info() to pre-declare the i2c device, right? I really need track i2c-stack in detail.

Best Regards,
Lanttor

------------------------------------------------------------------------
*From:* Jean Delvare <[email protected]> *Sent:* 11/25/2009 4:12:18 PM +0800
*To:* Lanttor <[email protected]> *CC:* [email protected] *Subject:* i2c adapter scan device issue

Quoted 37 lines · Lanttor
Quoted 20 lines

Hi,

I have a confused problem as follows:

I instantiate a i2c device with function i2c_register_board_info(); This function pre-declare the I2C devices which live on this bus and the call of it
is before the real i2c bus driver loaded.

In i2c_register_board_info(),
__i2c_first_dynamic_bus_num = busnum +1;

My i2c bus driver use i2c_add_adapter() to register adapter, In i2c_add_adapter(),
res = idr_get_new_above(&i2c_adapter_idr, adapter,

                                __i2c_first_dynamic_bus_num , &id);

adapter->nr = id;

Quoted 8 lines

That means if I pass busnum 0 to i2c_register_board_info(), but my i2c adapter will get
busnum 1 and so it can't scan pre-declared i2c devices.
In fact, I only have one i2c adapter.

It seems I can't use i2c_add_adapter(), instead of using i2c_add_numbered_adapter, right?

Yes, you are correct. You can't predefine I2C devices with i2c_register_board_info() if you don't also set I2C adapter numbers with i2c_add_numbered_adapter(). Trying would be equivalent to sending a letter to someone when you know the city and street number but not the street name: unlikely to succeed.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 7 lines · Lanttor
Quoted 7 lines

Yes, you are correct. You can't predefine I2C devices with i2c_register_board_info() if you don't also set I2C adapter numbers with i2c_add_numbered_adapter(). Trying would be equivalent to sending a letter to someone when you know the city and street number but not the street name: unlikely to succeed.

Quoted 8 lines

Thanks Jean.

In fact my bus driver used i2c_add_adapter() not i2c_add_numbered_adapter(). Now I use i2c_add_numbered_adapter() to replace 2c_add_adapter() and set the bus number first.

In one word, you mean that i2c_add_adapter() can not work normally if useing i2c_register_board_info() to pre-declare the i2c device, right?

Yes, exactly.

Quoted 1 line

I really need track i2c-stack in detail.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/wishlist.html