of: wrap accesses to device_node kobject
authorRob Herring <robh@kernel.org>
Wed, 4 Oct 2017 19:04:01 +0000 (14:04 -0500)
committerRob Herring <robh@kernel.org>
Mon, 16 Oct 2017 18:37:38 +0000 (13:37 -0500)
In preparation to make kobject element in struct device_node optional,
provide and use a macro to return the kobject pointer. The only user
outside the DT core is the driver core.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Tested-by: Nicolas Pitre <nico@linaro.org>
Reviewed-by: Frank Rowand <frowand.list@gmail.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Rob Herring <robh@kernel.org>
drivers/base/core.c
include/linux/of.h

index 12ebd055724cd6cdc01edff013583f38979fe92a..c07b4705953860519267a58d778d50a1063172e4 100644 (file)
@@ -1571,7 +1571,7 @@ static int device_add_class_symlinks(struct device *dev)
        int error;
 
        if (of_node) {
-               error = sysfs_create_link(&dev->kobj, &of_node->kobj,"of_node");
+               error = sysfs_create_link(&dev->kobj, of_node_kobj(of_node), "of_node");
                if (error)
                        dev_warn(dev, "Error %d creating of_node link\n",error);
                /* An error here doesn't warrant bringing down the device */
index 7eb94b7fbcf38a21e1be99346881d5110979729c..2d685e76940903332981aa91e484630dfdab6bf3 100644 (file)
@@ -111,6 +111,8 @@ static inline void of_node_init(struct device_node *node)
        node->fwnode.ops = &of_fwnode_ops;
 }
 
+#define of_node_kobj(n) (&(n)->kobj)
+
 /* true when node is initialized */
 static inline int of_node_is_initialized(struct device_node *node)
 {