* New Style I2C Driver : how to get clients ?
@ 2008-07-24 9:07 fuhz-GANU6spQydw
[not found] ` <1216890432.48884640c4486-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
0 siblings, 1 reply; 16+ messages in thread
From: fuhz-GANU6spQydw @ 2008-07-24 9:07 UTC (permalink / raw)
To: i2c-GZX6beZjE8VD60Wz+7aTrA
Hello,
I am currently writing a I2C driver for a custom embedded board.
I have read lot about writing I2C driver using Linux I2C layer.
But there are still a few things I don't anderstand.
I am quite confuse.
I have written an algorithm and an adapter. For instance, I just register my
adapter on the module_init.
- Is it important for adapters to be registred as platform_driver ?
- Will it remove the 'forgot to specify physical address' error ?
- Can I ignore 'forgot to specify physical address' error ?
For my driver, I only implement probe(client) and remove(client).
They are never called !!
I thought the I2C layer register automatically the I2C devices present on the
bus.
Am I wrong ?
- How can I specify the addresses of my I2C clients ?
- What about i2c_probe ? Do I need to call it directly ?
Thank you for help.
Best regards.
Légion.
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <1216890432.48884640c4486-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
@ 2008-07-24 9:29 ` Felipe Balbi
0 siblings, 0 replies; 16+ messages in thread
From: Felipe Balbi @ 2008-07-24 9:29 UTC (permalink / raw)
To: fuhz-GANU6spQydw; +Cc: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
On Thu, Jul 24, 2008 at 12:07 PM, <fuhz-GANU6spQydw@public.gmane.org> wrote:
> - How can I specify the addresses of my I2C clients ?
> - What about i2c_probe ? Do I need to call it directly ?
basically you i2c_register_board_info() from the board file.
Take a look at arch/arm/mach-omap2/board-h2.c for
a simple example.
you'll see that it calls omap_register_i2c_bus(), but it's
just a wrapper for omap-specific initializations on top
of i2c_register_board_info();
--
Best Regards,
Felipe Balbi
felipebalbi-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
@ 2008-07-24 12:52 fuhz-GANU6spQydw
[not found] ` <1216903949.48887b0dd2039-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
0 siblings, 1 reply; 16+ messages in thread
From: fuhz-GANU6spQydw @ 2008-07-24 12:52 UTC (permalink / raw)
To: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
Thank you for your fast answer.
So, I added the register_board_info in my board init function.
I fill the i2c_board_info structure with the macro I2C_BOARD_INFO.
I define a few clients.
And so what ?
The system is supposed to call the probe(client) of the driver ?
I am really lost. I did not anderstand how to get a valid client instance.
I suppose the I2C layer says "Hey boy, you have a new client !", but when ?
What about 'static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END
};'.
Can it help me ?
Thank you in advance.
Best regards,
Légion.
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <1216903949.48887b0dd2039-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
@ 2008-07-24 13:16 ` Felipe Balbi
[not found] ` <31e679430807240616n4bed86c7sa5c5ce69e066d0b5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 16+ messages in thread
From: Felipe Balbi @ 2008-07-24 13:16 UTC (permalink / raw)
To: fuhz-GANU6spQydw; +Cc: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
On Thu, Jul 24, 2008 at 3:52 PM, <fuhz-GANU6spQydw@public.gmane.org> wrote:
> So, I added the register_board_info in my board init function.
> I fill the i2c_board_info structure with the macro I2C_BOARD_INFO.
> I define a few clients.
hmm... ok
>
> And so what ?
>
> The system is supposed to call the probe(client) of the driver ?
yes, if you have the proper struct i2c_driver and struct i2c_device_id in
your driver the i2c subsystem should call the probe of your device.
check drivers/i2c/chips/menelaus.c for an example.
See how I2C_BOARD_INFO() in arch/arm/mach-omap2/board-h4
and struct i2c_device_id have the same name for the device (menelaus).
> I am really lost. I did not anderstand how to get a valid client instance.
> I suppose the I2C layer says "Hey boy, you have a new client !", but when ?
no, i2c layer will call device probe based on the driver name being the same in
i2c_board_info and i2c_device_id (if I'm not wrong that's the match,
Jean correct
me if I'm wrong).
> What about 'static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END
> };'.
> Can it help me ?
That's old style i2c driver. You don't need that anymore ;-)
--
Best Regards,
Felipe Balbi
felipebalbi-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <31e679430807240616n4bed86c7sa5c5ce69e066d0b5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-07-24 14:26 ` fuhz-GANU6spQydw
[not found] ` <1216909598.4888911eb6cea-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
0 siblings, 1 reply; 16+ messages in thread
From: fuhz-GANU6spQydw @ 2008-07-24 14:26 UTC (permalink / raw)
To: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
Thank you so much for help.
> yes, if you have the proper struct i2c_driver and struct i2c_device_id in
> your driver the i2c subsystem should call the probe of your device.
>
> check drivers/i2c/chips/menelaus.c for an example.
>
> See how I2C_BOARD_INFO() in arch/arm/mach-omap2/board-h4
> and struct i2c_device_id have the same name for the device (menelaus).
I am not using the last snapshot of Linux, but the 2.6.23 release.
My source code is not completly up-to-date.
For example there is no reference of I2C_BOARD_INFO in board-h4.
I have no 'i2c_device_id menelaus_id[]' in the i2c drivers code.
Perhap's that's why I am quite confuse, I am refering to recent code examples
and I am using not-so-recent Linux version.
In the documentation, "New-style" drivers are presented very quickly.
In fact, I still don't know where must be located the valid client list:
- in the board init source code with I2C_BOARD_INFO() macro
- in the i2c driver source code
> no, i2c layer will call device probe based on the driver name being the same
> in
> i2c_board_info and i2c_device_id (if I'm not wrong that's the match,
> Jean correct
> me if I'm wrong).
>
With my Linux version, i2c_device_id list was not present in the i2c_driver
structure. So i2c_board_info is supposed to match with what ?
> That's old style i2c driver. You don't need that anymore ;-)
Cool :)
Lines removed !
Best regards,
Légion.
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <1216909598.4888911eb6cea-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
@ 2008-07-24 16:11 ` fuhz-GANU6spQydw
[not found] ` <1216915913.4888a9c91fc42-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
2008-07-24 18:23 ` Felipe Balbi
2008-07-24 18:26 ` Felipe Balbi
2 siblings, 1 reply; 16+ messages in thread
From: fuhz-GANU6spQydw @ 2008-07-24 16:11 UTC (permalink / raw)
To: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
Ok, I think I have anderstand the process.
It is not as mystic that I thaught.
Tell me if I am wrong.
This is the process :
- Board init step #1
- I2C bus platform_driver initialisation
- Board init step #2 (register hardware i2c busses to the platform_driver)
- The I2C bus platform_driver register the new adapters to I2C layer
- Board init step #3 (register hardware devices present on each I2C bus)
- The I2C layer performs compatibity checks and tell I2C bus driver to add
clients
=> The probe callback function of the i2c driver is called.
Am I right ?
Thanks for help.
Best regards,
Légion.
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <1216909598.4888911eb6cea-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
2008-07-24 16:11 ` fuhz-GANU6spQydw
@ 2008-07-24 18:23 ` Felipe Balbi
2008-07-24 18:26 ` Felipe Balbi
2 siblings, 0 replies; 16+ messages in thread
From: Felipe Balbi @ 2008-07-24 18:23 UTC (permalink / raw)
To: fuhz-GANU6spQydw; +Cc: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
On Thu, Jul 24, 2008 at 5:26 PM, <fuhz-GANU6spQydw@public.gmane.org> wrote:
> Hi,
>
> Thank you so much for help.
>
>
>> yes, if you have the proper struct i2c_driver and struct i2c_device_id in
>> your driver the i2c subsystem should call the probe of your device.
>>
>> check drivers/i2c/chips/menelaus.c for an example.
>>
>> See how I2C_BOARD_INFO() in arch/arm/mach-omap2/board-h4
>> and struct i2c_device_id have the same name for the device (menelaus).
>
> I am not using the last snapshot of Linux, but the 2.6.23 release.
> My source code is not completly up-to-date.
>
> For example there is no reference of I2C_BOARD_INFO in board-h4.
> I have no 'i2c_device_id menelaus_id[]' in the i2c drivers code.
>
> Perhap's that's why I am quite confuse, I am refering to recent code examples
> and I am using not-so-recent Linux version.
might be. Why are you using 2.6.23 and not 2.6.26 ?
Anyways, in 2.6.23 there was no i2c_device_id, so you can drop that comment.
But if you have to give the same name in the driver and in the i2c_board_info().
something like:
struct i2c_board_info *info[] =
{
>
>
> In the documentation, "New-style" drivers are presented very quickly.
> In fact, I still don't know where must be located the valid client list:
> - in the board init source code with I2C_BOARD_INFO() macro
> - in the i2c driver source code
>
>
>> no, i2c layer will call device probe based on the driver name being the same
>> in
>> i2c_board_info and i2c_device_id (if I'm not wrong that's the match,
>> Jean correct
>> me if I'm wrong).
>>
>
> With my Linux version, i2c_device_id list was not present in the i2c_driver
> structure. So i2c_board_info is supposed to match with what ?
>
>
>> That's old style i2c driver. You don't need that anymore ;-)
>
> Cool :)
> Lines removed !
>
>
>
> Best regards,
>
> Légion.
>
> _______________________________________________
> i2c mailing list
> i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
> http://lists.lm-sensors.org/mailman/listinfo/i2c
>
--
Best Regards,
Felipe Balbi
felipebalbi-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <1216909598.4888911eb6cea-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
2008-07-24 16:11 ` fuhz-GANU6spQydw
2008-07-24 18:23 ` Felipe Balbi
@ 2008-07-24 18:26 ` Felipe Balbi
[not found] ` <31e679430807241126l5bcea400ieafcfa082d11783a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2 siblings, 1 reply; 16+ messages in thread
From: Felipe Balbi @ 2008-07-24 18:26 UTC (permalink / raw)
To: fuhz-GANU6spQydw; +Cc: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
sorry pressed the send button by mistake.
read below
On Thu, Jul 24, 2008 at 5:26 PM, <fuhz-GANU6spQydw@public.gmane.org> wrote:
> I am not using the last snapshot of Linux, but the 2.6.23 release.
> My source code is not completly up-to-date.
>
> For example there is no reference of I2C_BOARD_INFO in board-h4.
> I have no 'i2c_device_id menelaus_id[]' in the i2c drivers code.
>
> Perhap's that's why I am quite confuse, I am refering to recent code examples
> and I am using not-so-recent Linux version.
might be. Why are you using 2.6.23 and not 2.6.26 ?
Anyways, in 2.6.23 there was no i2c_device_id, so you can drop that comment.
But if you have to give the same name in the driver and in the i2c_board_info().
something like:
board file:
struct i2c_board_info *info[] =
{
{
I2C_BOARD_INFO("mydevice", 0xff),
},
};
(...)
driver:
struct i2c_driver mydriver = {
.driver = {
.name = "mydevice",
},
.probe = myprobe,
.remove = __exit_p(myremove),
};
got it ??
--
Best Regards,
Felipe Balbi
felipebalbi-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <1216915913.4888a9c91fc42-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
@ 2008-07-24 18:28 ` Felipe Balbi
0 siblings, 0 replies; 16+ messages in thread
From: Felipe Balbi @ 2008-07-24 18:28 UTC (permalink / raw)
To: fuhz-GANU6spQydw; +Cc: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
On Thu, Jul 24, 2008 at 7:11 PM, <fuhz-GANU6spQydw@public.gmane.org> wrote:
> - Board init step #1
> - I2C bus platform_driver initialisation
>
> - Board init step #2 (register hardware i2c busses to the platform_driver)
> - The I2C bus platform_driver register the new adapters to I2C layer
>
> - Board init step #3 (register hardware devices present on each I2C bus)
are you writing a client driver or a bus driver ?
--
Best Regards,
Felipe Balbi
felipebalbi-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <31e679430807241126l5bcea400ieafcfa082d11783a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-07-25 9:00 ` fuhz-GANU6spQydw
[not found] ` <1216976458.4889964a5d9e2-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
0 siblings, 1 reply; 16+ messages in thread
From: fuhz-GANU6spQydw @ 2008-07-25 9:00 UTC (permalink / raw)
To: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
> are you writing a client driver or a bus driver ?
In fact, I just want to write a client driver for a embedded board.
But, the bus driver is not already ported, so I wrote an algorithm and
an adapter. I am currently write the client driver, but no client is
coming.
> might be. Why are you using 2.6.23 and not 2.6.26 ?
I want to use the 2.6.23 release because I have already a patched and
customized Linux directory tree, I don't want to merge it with new version of
kernel.
> But if you have to give the same name in the driver and in the
> i2c_board_info().
Ok, I have this now.
> got it ??
Not really. Thanks to you, I anderstand more about i2c layer.
But now, I think my problem is the bus driver.
I have this error :
"I2C adapter driver : forgot to specify physical device"
I don't anderstand where we are supposed to associate an adapter
with the client driver.
Thanks for help.
Best regards,
Légion.
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <1216976458.4889964a5d9e2-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
@ 2008-07-25 14:08 ` fuhz-GANU6spQydw
[not found] ` <1216994898.4889de52becd3-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
0 siblings, 1 reply; 16+ messages in thread
From: fuhz-GANU6spQydw @ 2008-07-25 14:08 UTC (permalink / raw)
To: i2c-GZX6beZjE8VD60Wz+7aTrA
Hello,
Ok, I have just read my code carefully and correct some mistakes.
It is quite clean now, but I still don't get my clients.
In the board initialisation file, I define two things :
- a platform_device for my I2C bus
The name field correspond to the adapter platform_driver.name
- a valid i2c_board_info struct defining my clients
The name field correspond to the client i2c_driver.name
I do not care about type field, I just use the I2C_BOARD_INFO macro
I have written different modules for the algorithm, the adapter, and the client.
First at all, I load the client driver with insmod utility.
Then, I load the algorithm.
And finally, I load the adapter.
When the adapter is loaded, my probe(platform_device) is correctly called.
I allocate a new structure correctly and register a new adapter.
On the remove callback function, I deallocate it.
No client is registred to my i2c_driver, so where is the mistake ?
> got it ??
As soon as possible :-)
Best regards,
Légion.
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <1216994898.4889de52becd3-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
@ 2008-07-25 14:26 ` Felipe Balbi
[not found] ` <31e679430807250726n3e4b189ehcff5dd02f46872f3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 16+ messages in thread
From: Felipe Balbi @ 2008-07-25 14:26 UTC (permalink / raw)
To: fuhz-GANU6spQydw; +Cc: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
On Fri, Jul 25, 2008 at 5:08 PM, <fuhz-GANU6spQydw@public.gmane.org> wrote:
> First at all, I load the client driver with insmod utility.
> Then, I load the algorithm.
> And finally, I load the adapter.
should be the other way around. You first need a bus in order
to have clients.
--
Best Regards,
Felipe Balbi
felipebalbi-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <31e679430807250726n3e4b189ehcff5dd02f46872f3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-07-25 14:30 ` fuhz-GANU6spQydw
[not found] ` <1216996221.4889e37d41fa3-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
0 siblings, 1 reply; 16+ messages in thread
From: fuhz-GANU6spQydw @ 2008-07-25 14:30 UTC (permalink / raw)
To: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
> should be the other way around. You first need a bus in order
> to have clients.
Ok, so I unload all the modules.
First, I load the algorithm.
Second, I load the adapter.
And finally I load the client driver.
There isn't any improvement.
Any other ideas ?
Best regards,
Légion.
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <1216996221.4889e37d41fa3-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
@ 2008-07-28 9:36 ` fuhz-GANU6spQydw
[not found] ` <1217237786.488d931ac5b9b-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
0 siblings, 1 reply; 16+ messages in thread
From: fuhz-GANU6spQydw @ 2008-07-28 9:36 UTC (permalink / raw)
To: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
In order to improve my understanding of Linux i2c layer, I read the source code.
I read i2c-core.c and I try to anderstand why my clients wasn't created.
The problem is in the i2c_register_adapter function :
/* create pre-declarated device nodes for new-style drivers */
if (adap->nr < __i2c_first_dynamic_bus_num)
i2c_scan_static_board_info(adap);
The test is NEVER true. So my clients are not created.
I read that __i2c_first_dynamic_bus_num is set to 1.
It does not seems to change.
And that adap->nr refers to "Dynamic Bus Number".
My first bus register with adap->nr=1.
The second register with adap->nr=2.
That's why the test fails.
So, I have had an idea to fix the problem.
I change :
i2c_add_adapter(adap);
with
adap->nr = 0;
i2c_add_numbered_adapter(adap);
But, it make new problems :
- I can't manage two busses
- I definitly don't anderstand how I2C_BOARD_INFO macro can associate
a client to a specified bus
- I don't anderstand what I am writing, and I really dislike it :c
So many questions :)
Thanks for help.
Best regards,
Légion.
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <1217237786.488d931ac5b9b-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
@ 2008-07-28 9:59 ` Felipe Balbi
[not found] ` <1217239920.488d9b70baec7@imp.free.fr>
0 siblings, 1 reply; 16+ messages in thread
From: Felipe Balbi @ 2008-07-28 9:59 UTC (permalink / raw)
To: fuhz-GANU6spQydw; +Cc: i2c-GZX6beZjE8VD60Wz+7aTrA
Hi,
On Mon, Jul 28, 2008 at 12:36 PM, <fuhz-GANU6spQydw@public.gmane.org> wrote:
> Hi,
>
> In order to improve my understanding of Linux i2c layer, I read the source code.
> I read i2c-core.c and I try to anderstand why my clients wasn't created.
>
> The problem is in the i2c_register_adapter function :
>
> /* create pre-declarated device nodes for new-style drivers */
> if (adap->nr < __i2c_first_dynamic_bus_num)
> i2c_scan_static_board_info(adap);
>
> The test is NEVER true. So my clients are not created.
>
>
>
> I read that __i2c_first_dynamic_bus_num is set to 1.
> It does not seems to change.
it changes in i2c-boardinfo.c@i2c_register_board_info:
/* dynamic bus numbers will be assigned after the last static one */
if (busnum >= __i2c_first_dynamic_bus_num)
__i2c_first_dynamic_bus_num = busnum + 1;
which would make the above if() true :-)
> And that adap->nr refers to "Dynamic Bus Number".
> My first bus register with adap->nr=1.
> The second register with adap->nr=2.
hmm.. i suppose your calling i2c_register_board_info() with wrong
parameters.
> That's why the test fails.
>
>
> So, I have had an idea to fix the problem.
>
> I change :
> i2c_add_adapter(adap);
>
> with
> adap->nr = 0;
> i2c_add_numbered_adapter(adap);
>
>
> But, it make new problems :
> - I can't manage two busses
> - I definitly don't anderstand how I2C_BOARD_INFO macro can associate
> a client to a specified bus
> - I don't anderstand what I am writing, and I really dislike it :c
show me your i2c_register_board_info() call.
it should be:
i2c_register_board_info(bus number, struct i2c_board_info **,
ARRAY_SIZE(i2c_board_info));
just a note, the first i2c bus is bus 1 and not bus 0. I suppose
that's not your problem, right ?
--
Best Regards,
Felipe Balbi
felipebalbi-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: New Style I2C Driver : how to get clients ?
[not found] ` <1217239920.488d9b70baec7-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
@ 2008-07-28 10:35 ` Felipe Balbi
0 siblings, 0 replies; 16+ messages in thread
From: Felipe Balbi @ 2008-07-28 10:35 UTC (permalink / raw)
To: fuhz-GANU6spQydw; +Cc: Linux I2C
Hi,
On Mon, Jul 28, 2008 at 1:12 PM, <fuhz-GANU6spQydw@public.gmane.org> wrote:
> Hi,
>
>> > I read that __i2c_first_dynamic_bus_num is set to 1.
>> > It does not seems to change.
>>
>> it changes in i2c-boardinfo.c@i2c_register_board_info:
>>
>> /* dynamic bus numbers will be assigned after the last static one */
>> if (busnum >= __i2c_first_dynamic_bus_num)
>> __i2c_first_dynamic_bus_num = busnum + 1;
>>
>> which would make the above if() true :-)
>
> You're right !
>
>
>> hmm.. i suppose your calling i2c_register_board_info() with wrong
>> parameters.
>
>> just a note, the first i2c bus is bus 1 and not bus 0. I suppose
>> that's not your problem, right ?
>
> It was :D
> I thought it was zero-based counter...and I tested the code with only one bus !
>
> Hehe, I feel stupid :D
>
>
>
> MANY MANY MANY THANKS :D
Cool. At least it's solved :-)
Have fun now ;-)
--
Best Regards,
Felipe Balbi
felipebalbi-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2008-07-28 10:35 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-24 12:52 New Style I2C Driver : how to get clients ? fuhz-GANU6spQydw
[not found] ` <1216903949.48887b0dd2039-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
2008-07-24 13:16 ` Felipe Balbi
[not found] ` <31e679430807240616n4bed86c7sa5c5ce69e066d0b5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-24 14:26 ` fuhz-GANU6spQydw
[not found] ` <1216909598.4888911eb6cea-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
2008-07-24 16:11 ` fuhz-GANU6spQydw
[not found] ` <1216915913.4888a9c91fc42-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
2008-07-24 18:28 ` Felipe Balbi
2008-07-24 18:23 ` Felipe Balbi
2008-07-24 18:26 ` Felipe Balbi
[not found] ` <31e679430807241126l5bcea400ieafcfa082d11783a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-25 9:00 ` fuhz-GANU6spQydw
[not found] ` <1216976458.4889964a5d9e2-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
2008-07-25 14:08 ` fuhz-GANU6spQydw
[not found] ` <1216994898.4889de52becd3-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
2008-07-25 14:26 ` Felipe Balbi
[not found] ` <31e679430807250726n3e4b189ehcff5dd02f46872f3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-25 14:30 ` fuhz-GANU6spQydw
[not found] ` <1216996221.4889e37d41fa3-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
2008-07-28 9:36 ` fuhz-GANU6spQydw
[not found] ` <1217237786.488d931ac5b9b-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
2008-07-28 9:59 ` Felipe Balbi
[not found] ` <1217239920.488d9b70baec7@imp.free.fr>
[not found] ` <1217239920.488d9b70baec7-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
2008-07-28 10:35 ` Felipe Balbi
-- strict thread matches above, loose matches on Subject: below --
2008-07-24 9:07 fuhz-GANU6spQydw
[not found] ` <1216890432.48884640c4486-HZaT1/I6gcdWj0EZb7rXcA@public.gmane.org>
2008-07-24 9:29 ` Felipe Balbi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox