]> Git Repo - linux.git/commitdiff
platform: set of_node in platform_device_register_full()
authorMans Rullgard <[email protected]>
Thu, 21 Feb 2019 11:29:35 +0000 (11:29 +0000)
committerGreg Kroah-Hartman <[email protected]>
Tue, 26 Feb 2019 11:58:10 +0000 (12:58 +0100)
If the provided fwnode is an OF node, set dev.of_node as well.

Also add an of_node_reused flag to struct platform_device_info and copy
this to the new device.  This is needed to avoid pinctrl settings being
requested twice.  See 4e75e1d7dac9 ("driver core: add helper to reuse a
device-tree node") for a longer explanation.

Some drivers are just shims that create extra "glue" devices with the
DT device as parent and have the real driver bind to these.  In these
cases, the glue device needs to get a reference to the original DT node
in order for the main driver to access properties and child nodes.

For example, the sunxi-musb driver creates such a glue device using
platform_device_register_full().  Consequently, devices attached to
this USB interface don't get associated with DT nodes, if present,
the way they do with EHCI.

This change will allow sunxi-musb and similar drivers to easily
propagate the DT node to child devices as required.

Signed-off-by: Mans Rullgard <[email protected]>
Reviewed-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
drivers/base/platform.c
include/linux/platform_device.h

index 0d3611cd1b3bc40a5113417138456341230d1aa9..fc67a325beaab774bf21992a6e0ae7ae1acca306 100644 (file)
@@ -525,6 +525,8 @@ struct platform_device *platform_device_register_full(
 
        pdev->dev.parent = pdevinfo->parent;
        pdev->dev.fwnode = pdevinfo->fwnode;
+       pdev->dev.of_node = of_node_get(to_of_node(pdev->dev.fwnode));
+       pdev->dev.of_node_reused = pdevinfo->of_node_reused;
 
        if (pdevinfo->dma_mask) {
                /*
index c7c081dc6034e7057d69a79680e796d0f48a3831..466a8d02e29801abd74162cd3cff212381045838 100644 (file)
@@ -63,6 +63,7 @@ extern int platform_add_devices(struct platform_device **, int);
 struct platform_device_info {
                struct device *parent;
                struct fwnode_handle *fwnode;
+               bool of_node_reused;
 
                const char *name;
                int id;
This page took 0.06568 seconds and 4 git commands to generate.