Problem registering the Platform ADC driver
Dear Friends, I am having issue with registering the platform device driver for ADC. http://pastebin.com/Ym1NTkfL - Link contains the snip code of kernel platform device and driver registration code . I have build the driver as module. When I load the driver as module, the probe function is not called from the driver. Can any one suggest what is missing in the code? I tried to find and study over internet about how to create platform device driver but in vain. Output: # insmod adc_at91.ko <8>Under at91_adc_init # rmmod adc_at91.ko <8>Under at91_adc_exit Thank you, Ankur.
Dear Friends,
I am having issue with registering the platform device driver for ADC.
http://pastebin.com/Ym1NTkfL - Link contains the snip code of kernel platform device and driver registration code .
I have build the driver as module. When I load the driver as module, the probe function is not called from the driver. Can any one suggest what is missing in the code?
As far as I am awayre, this indicates that the platform device is missing. somehow. Basically, the kernel doesn't know how to handle your new device. If you in you init function also call "t91_add_device_adc" it might work a bit better ;-) For me, I usually set this up in the arch specific board file. There, I also create device specific data which is then inserted into the driver once it's loaded. But, that may be too much information at this time :-) If you take a look at arch/arm/mach-msm/board-msm7x30.c, you will find "static struct platform_device *devices[] __initdata = {" This array is used to set up new platform devices. The structure looks jsut like the one you've created in the top of your code. Then in msm7x30_init, you will see that all platform devices that are defined in this struct will be registered via the platform_add_devices() function call. To get more information, please take a look at the struct platform_device structure. It contains some interesting information and user available pointers that can be used to allocate driver specific configuration data.
I tried to find and study over internet about how to create platform device driver but in vain.
I recommend to look at a similar driver (i2c drivers basically behave the same, and quite often, ADC devices also talk i2c), to figure out exactly how it works. My knowledge of the English language and my currently available time are sadly not sufficient to explain this in more detail :-( Hope this information got you started though. Brs, /Jocke!
Hi again! Sorry if I answered questions You were already aware of. Was too quick to answer. :-( /Jocke!
Dear Friends,
I am having issue with registering the platform device driver for ADC.
http://pastebin.com/Ym1NTkfL - Link contains the snip code of kernel platform device and driver registration code .
I have build the driver as module. When I load the driver as module, the probe function is not called from the driver. Can any one suggest what is missing in the code?
As far as I am awayre, this indicates that the platform device is missing. somehow. Basically, the kernel doesn't know how to handle your new device.
If you in you init function also call "t91_add_device_adc" it might work a bit better ;-)
For me, I usually set this up in the arch specific board file. There, I also create device specific data which is then inserted into the driver once it's loaded. But, that may be too much information at this time :-)
If you take a look at arch/arm/mach-msm/board-msm7x30.c, you will find "static struct platform_device *devices[] __initdata = {" This array is used to set up new platform devices. The structure looks jsut like the one you've created in the top of your code.
Then in msm7x30_init, you will see that all platform devices that are defined in this struct will be registered via the platform_add_devices() function call.
To get more information, please take a look at the struct platform_device structure. It contains some interesting information and user available pointers that can be used to allocate driver specific configuration data.
I tried to find and study over internet about how to create platform device driver but in vain.
I recommend to look at a similar driver (i2c drivers basically behave the same, and quite often, ADC devices also talk i2c), to figure out exactly how it works.
My knowledge of the English language and my currently available time are sadly not sufficient to explain this in more detail :-(
Hope this information got you started though.
Brs, /Jocke!
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-- If it can't be fixed with duct-tape, it's definitely borken...
On Tue, May 24, 2011 at 1:42 PM, Joachim Holst <jocke@holstenhof.se> wrote:
Hi again!
Sorry if I answered questions You were already aware of. Was too quick to answer.
:-(
/Jocke!
Thanks Jocke, for your reply. As you said in your example of board-msm7x30.c file which uses platform_add_devices, my board file board-icnova_adb4000.c uses platform_device_register for the registration of all peripherals initialized under function __init ek_board_init(void). I found that platform_add_device or platform_register_device can be used for device registration.
Here is board-icnova_adb4000.c http://pastebin.com/dr0QzsyQ <http://pastebin.com/dr0QzsyQ%20>Linux#390. The functions called under ek_board_init are defined under http://lxr.linux.no/#linux+v2.6.38/arch/arm/mach-at91/at91sam9g45_devices.c. All of them uses platform_device_register. In my case also it should work. Still I am not sure why it is not working, any further thoughts or suggestions? Have a Nice time, Ankur.
On Tue, May 24, 2011 at 1:42 PM, Joachim Holst <jocke@holstenhof.se> wrote:
Thanks Jocke, for your reply. As you said in your example of
board-msm7x30.c file which uses platform_add_devices, my board file board-icnova_adb4000.c uses platform_device_register for the registration of all peripherals initialized under function __init ek_board_init(void). I found that platform_add_device or platform_register_device can be used for device registration.
You are quite correct. I previously failed to read your code as good as I should have :-( Sorry about that.
Here is board-icnova_adb4000.c http://pastebin.com/dr0QzsyQ <http://pastebin.com/dr0QzsyQ%20>Linux#390. The functions called under ek_board_init are defined under http://lxr.linux.no/#linux+v2.6.38/arch/arm/mach-at91/at91sam9g45_devices.c. All of them uses platform_device_register. In my case also it should work.
Still I am not sure why it is not working, any further thoughts or suggestions?
First, are you sure that platform_device_register actually succeeds? The times this has happened to me, it has always been a problem with the "name" between the platform device and the platform driver. To avoid those problems, I usually use a #define for the name. That way, I'm sure that a spelling problem (which can be _really_ hard to spot) is not the problem. Also, I usually don't care about setting the .id and the .num_resources variables. Otherwise, as far as I can tell, your code should work. BRs, /Jocke! -- If it can't be fixed with duct-tape, it's definitely borken...
On Tue, May 24, 2011 at 1:42 PM, Joachim Holst <jocke@holstenhof.se> wrote:
Thanks Jocke, for your reply. As you said in your example of
board-msm7x30.c file which uses platform_add_devices, my board file board-icnova_adb4000.c uses platform_device_register for the registration of all peripherals initialized under function __init ek_board_init(void). I found that platform_add_device or platform_register_device can be used for device registration.
You are quite correct. I previously failed to read your code as good as I should have :-( Sorry about that.
Here is board-icnova_adb4000.c http://pastebin.com/dr0QzsyQ <http://pastebin.com/dr0QzsyQ%20>Linux#390. The functions called under ek_board_init are defined under
http://lxr.linux.no/#linux+v2.6.38/arch/arm/mach-at91/at91sam9g45_devices.c .
All of them uses platform_device_register. In my case also it should work.
Still I am not sure why it is not working, any further thoughts or suggestions?
First, are you sure that platform_device_register actually succeeds?
The times this has happened to me, it has always been a problem with the "name" between the platform device and the platform driver.
To avoid those problems, I usually use a #define for the name. That way, I'm sure that a spelling problem (which can be _really_ hard to spot) is not the problem. Also, I usually don't care about setting the .id and the .num_resources variables.
Otherwise, as far as I can tell, your code should work.
BRs, /Jocke!
Thank you for your kind suggestion.. :-)
participants (3)
-
conn intel -
Joachim Holst -
jocke@holstenhof.se