Hi, I am seeing probe function pointer and know the procedure to register of it for a specific device driver. However, I wonder when it is actually called? For example, for platform drivers, there is a structure like this: struct platform_driver { int (*probe)(struct platform_device *); int (*remove)(struct platform_device *); void (*shutdown)(struct platform_device *); int (*suspend)(struct platform_device *, pm_message_t state); int (*suspend_late)(struct platform_device *, pm_message_t state); int (*resume_early)(struct platform_device *); int (*resume)(struct platform_device *); struct device_driver driver; }; Then, it is registered by int platform_driver_register(struct platform_driver *drv); But, I wonder when actually, those functions (especially, probe) are called. Could you guide me about it, please? Thanks, -J.
Hi,
I am seeing probe function pointer and know the procedure to register of it for a specific device driver. However, I wonder when it is actually called?
For example, for platform drivers, there is a structure like this:
struct platform_driver { int (*probe)(struct platform_device *); int (*remove)(struct platform_device *); void (*shutdown)(struct platform_device *); int (*suspend)(struct platform_device *, pm_message_t state); int (*suspend_late)(struct platform_device *, pm_message_t state); int (*resume_early)(struct platform_device *); int (*resume)(struct platform_device *); struct device_driver driver; };
Then, it is registered by
int platform_driver_register(struct platform_driver *drv);
But, I wonder when actually, those functions (especially, probe) are called. Could you guide me about it, please?
AFAIK probe is called when your device is recognized by the platform.Generally registering the device requires the device name and this device name is compared with the driver name(when you are registering the driver you would be specifying the driver name,which should match with the device name). Once the device gets detected by the kernel it will call the corresponding driver probe for that device.
Thanks,
-J.
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Thanks, Anish, However, could you point me out where the kernel actually detects the device? Is it keep polling with the driver's name which was given at compile time? Or Is there other mechanism to detect the device? Basically, how the kernel detects those devices, which calls "probe"? -J On Sun, Feb 6, 2011 at 11:29 PM, anish singh <anish198519851985@gmail.com>wrote:
Hi,
I am seeing probe function pointer and know the procedure to register of it for a specific device driver. However, I wonder when it is actually called?
For example, for platform drivers, there is a structure like this:
struct platform_driver { int (*probe)(struct platform_device *); int (*remove)(struct platform_device *); void (*shutdown)(struct platform_device *); int (*suspend)(struct platform_device *, pm_message_t state); int (*suspend_late)(struct platform_device *, pm_message_t state); int (*resume_early)(struct platform_device *); int (*resume)(struct platform_device *); struct device_driver driver; };
Then, it is registered by
int platform_driver_register(struct platform_driver *drv);
But, I wonder when actually, those functions (especially, probe) are called. Could you guide me about it, please?
AFAIK probe is called when your device is recognized by the platform.Generally registering the device requires the device name and this device name is compared with the driver name(when you are registering the driver you would be specifying the driver name,which should match with the device name). Once the device gets detected by the kernel it will call the corresponding driver probe for that device.
Thanks,
-J.
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
However, could you point me out where the kernel actually detects the device? Is it keep polling with the driver's name which was given at compile time? Or Is there other mechanism to detect the device? Basically, how the kernel detects those devices, which calls "probe"?
Platform devices represent devices that are usually integrated into a given chip and therefore are always there. The platform-specific initialization code statically initializes such arrays of platform devices and then registers them in a row using platform_register. Therefore there is no need for sophisticated probing. Instead, the string contained in platform_device.name is compared platform_driver.driver.name and a match is assumed if they are equal. Have a look at the attached example file that defines and registers a dummy platform driver for a dummy platform device. If you change the string, the probe function will not be called anymore. Other buses have more sophisticated detection/probing methods. For more information about platform devices, including the places where these functions are called, see drivers/base/platform.c. Reading Documentation/driver-model/platform.txt is also a good idea. Alex.
Thank you so much with the nice example code. Now, I could understand. Thanks! J. On Sun, Feb 6, 2011 at 11:51 PM, Alexandre Courbot <gnurou@gmail.com> wrote:
However, could you point me out where the kernel actually detects the device? Is it keep polling with the driver's name which was given at compile time? Or Is there other mechanism to detect the device? Basically, how the kernel detects those devices, which calls "probe"?
Platform devices represent devices that are usually integrated into a given chip and therefore are always there. The platform-specific initialization code statically initializes such arrays of platform devices and then registers them in a row using platform_register. Therefore there is no need for sophisticated probing. Instead, the string contained in platform_device.name is compared platform_driver.driver.name and a match is assumed if they are equal. Have a look at the attached example file that defines and registers a dummy platform driver for a dummy platform device. If you change the string, the probe function will not be called anymore.
Other buses have more sophisticated detection/probing methods. For more information about platform devices, including the places where these functions are called, see drivers/base/platform.c. Reading Documentation/driver-model/platform.txt is also a good idea.
Alex.
On Mon, Feb 7, 2011 at 13:53, Joy Sun <joy2sun127@gmail.com> wrote:
Hi, I am seeing probe function pointer and know the procedure to register of it for a specific device driver. However, I wonder when it is actually called? For example, for platform drivers, there is a structure like this:
Hi... AFAIK, it's mostly related to interrupt and/or bus handling. Whenever there is new device gets active, "message" is sent along to the bus, for example when you insert a USB flash disc. NB: Might be loosely related to HAL or udev -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
Thanks, Mulyadi, Can you tell me which kernel part is monitoring those jobs which will trigger the interrupt? I mean, when we're making a device driver for the linux kernel, the very beginning job is registering "probe" function. However, I still don't know how the "probe" is actually called. For example as yours, when USB key is inserted, which/what function will trigger the interrupt? In case of USB memory stick, the interrupt might be triggered by the USB Host Controller (e.g., EHCI). So, assuming that the USB Host Controller Driver will do it, but isn't it that the USB Host Controller, itself is registerred by "probe"? If then, how kernel knows the controller is actually active on the bus? J. On Sun, Feb 6, 2011 at 11:31 PM, Mulyadi Santosa <mulyadi.santosa@gmail.com>wrote:
On Mon, Feb 7, 2011 at 13:53, Joy Sun <joy2sun127@gmail.com> wrote:
Hi, I am seeing probe function pointer and know the procedure to register of it for a specific device driver. However, I wonder when it is actually called? For example, for platform drivers, there is a structure like this:
Hi...
AFAIK, it's mostly related to interrupt and/or bus handling. Whenever there is new device gets active, "message" is sent along to the bus, for example when you insert a USB flash disc.
NB: Might be loosely related to HAL or udev
-- regards,
Mulyadi Santosa Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
participants (4)
-
Alexandre Courbot -
anish singh -
Joy Sun -
Mulyadi Santosa