device tree nodes and platform drivers

Max Ruttenberg mruttenberg at emutechnology.com
Wed May 17 19:01:56 EDT 2017


Hi all,

I'm trying to write a platform driver for a device node that I have
defined inside of a device tree.

The node looks like this:

my-node0 {
      compatible = "my,id";
      dcok-gpios = <&gpio1 6 0>;
};

In my kernel module I have something like this:

const static struct of_device_id my_ids [] = {
            { .compatible = "my,id" },
            { /* sentinal */ }
};

struct platform_driver my_drv = {
            .driver = {
                        .name = "my-node",
                        .owner = THIS_MODULE,
                        .of_match_table = my_ids,
            };
            .probe = my_probe_func,
            .remove = my_remove_func,
};

static int __init my_init(void)
{
            /* some extra stuff */
            return platform_driver_register(&my_drv);
}

module_init(my_init);

And yet... the driver for my probe function is never called! I've
looked in /proc for device tree node, and I can see it there.
Furthermore, just to be sure, I call

of_find_compatbile_node(NULL,NULL,"my,id")

and it returns my device node. I'm tempted to just extract what I need
from it (i.e. those gpio descriptors) in my init function and skip the
platform driver stuff. Can anyone help me understand what I might be
missing?

Thank you,
Max



More information about the Kernelnewbies mailing list