2012年6月26日 星期二

Linux driver :platform devices and driver

find out at /sys/bus/platform/devices and /sys/bus/platform/drivers

ex:
./arch/arm/board-file.c
+static struct platform_device foo_device = {
+       .name       = "foo_device",
+       .id     = -1,
+       .dev        = {
+               .platform_data = NULL,
+       },
+};

This will create foo_device at /sys/devices/platform/

ex:
./driver/misc/foo.c

static struct platform_driver foo_driver = {
    .probe = foo_probe,
    .driver =  {
        .name = "foo_device",
        .owner = THIS_MODULE,
    },
};
static int __init foo_init(void)
{  
    return platform_driver_register(&foo_driver);


static void __exit foo_exit(void)
{
    return platform_driver_unregister(&foo_driver);


This will find the foo_device folder at /sys/bus/platform/drivers




/sys/bus/platform/drivers/foo_device # ls
bind             foo_device  uevent           unbind

/sys/bus/platform/drivers/foo_device # ls foo_device/
driver     modalias   power      subsystem  uevent




沒有留言:

張貼留言