powerpc/pseries: extract of_helpers module
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 1 Oct 2015 09:46:06 +0000 (12:46 +0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 5 Oct 2015 10:11:24 +0000 (21:11 +1100)
Extract a new module to share the code between other modules.

There is no functional change.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/pseries/Makefile
arch/powerpc/platforms/pseries/of_helpers.c [new file with mode: 0644]
arch/powerpc/platforms/pseries/of_helpers.h [new file with mode: 0644]
arch/powerpc/platforms/pseries/reconfig.c

index 03480796af9a55cad0b024aaf23223a8b51d8175..2e857c2b6ea3411180011d2ab21b62a13c5bec3a 100644 (file)
@@ -2,6 +2,7 @@ ccflags-$(CONFIG_PPC64)                 := $(NO_MINIMAL_TOC)
 ccflags-$(CONFIG_PPC_PSERIES_DEBUG)    += -DDEBUG
 
 obj-y                  := lpar.o hvCall.o nvram.o reconfig.o \
+                          of_helpers.o \
                           setup.o iommu.o event_sources.o ras.o \
                           firmware.o power.o dlpar.o mobility.o rng.o
 obj-$(CONFIG_SMP)      += smp.o
diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c
new file mode 100644 (file)
index 0000000..1cbd896
--- /dev/null
@@ -0,0 +1,38 @@
+#include <linux/string.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+
+#include "of_helpers.h"
+
+/**
+ * pseries_of_derive_parent - basically like dirname(1)
+ * @path:  the full_name of a node to be added to the tree
+ *
+ * Returns the node which should be the parent of the node
+ * described by path.  E.g., for path = "/foo/bar", returns
+ * the node with full_name = "/foo".
+ */
+struct device_node *pseries_of_derive_parent(const char *path)
+{
+       struct device_node *parent = NULL;
+       char *parent_path = "/";
+       size_t parent_path_len = strrchr(path, '/') - path + 1;
+
+       /* reject if path is "/" */
+       if (!strcmp(path, "/"))
+               return ERR_PTR(-EINVAL);
+
+       if (strrchr(path, '/') != path) {
+               parent_path = kmalloc(parent_path_len, GFP_KERNEL);
+               if (!parent_path)
+                       return ERR_PTR(-ENOMEM);
+               strlcpy(parent_path, path, parent_path_len);
+       }
+       parent = of_find_node_by_path(parent_path);
+       if (!parent)
+               return ERR_PTR(-EINVAL);
+       if (strcmp(parent_path, "/"))
+               kfree(parent_path);
+       return parent;
+}
diff --git a/arch/powerpc/platforms/pseries/of_helpers.h b/arch/powerpc/platforms/pseries/of_helpers.h
new file mode 100644 (file)
index 0000000..bb83d39
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef _PSERIES_OF_HELPERS_H
+#define _PSERIES_OF_HELPERS_H
+
+#include <linux/of.h>
+
+struct device_node *pseries_of_derive_parent(const char *path);
+
+#endif /* _PSERIES_OF_HELPERS_H */
index 0f319521e0020b674ed6c8e49e53ef394ebdda0f..7c7fcc04254948837a3a747ef83fd6cdd6babb3b 100644 (file)
 #include <asm/uaccess.h>
 #include <asm/mmu.h>
 
-/**
- *     derive_parent - basically like dirname(1)
- *     @path:  the full_name of a node to be added to the tree
- *
- *     Returns the node which should be the parent of the node
- *     described by path.  E.g., for path = "/foo/bar", returns
- *     the node with full_name = "/foo".
- */
-static struct device_node *derive_parent(const char *path)
-{
-       struct device_node *parent = NULL;
-       char *parent_path = "/";
-       size_t parent_path_len = strrchr(path, '/') - path + 1;
-
-       /* reject if path is "/" */
-       if (!strcmp(path, "/"))
-               return ERR_PTR(-EINVAL);
-
-       if (strrchr(path, '/') != path) {
-               parent_path = kmalloc(parent_path_len, GFP_KERNEL);
-               if (!parent_path)
-                       return ERR_PTR(-ENOMEM);
-               strlcpy(parent_path, path, parent_path_len);
-       }
-       parent = of_find_node_by_path(parent_path);
-       if (!parent)
-               return ERR_PTR(-EINVAL);
-       if (strcmp(parent_path, "/"))
-               kfree(parent_path);
-       return parent;
-}
+#include "of_helpers.h"
 
 static int pSeries_reconfig_add_node(const char *path, struct property *proplist)
 {
@@ -71,7 +41,7 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist
        of_node_set_flag(np, OF_DYNAMIC);
        of_node_init(np);
 
-       np->parent = derive_parent(path);
+       np->parent = pseries_of_derive_parent(path);
        if (IS_ERR(np->parent)) {
                err = PTR_ERR(np->parent);
                goto out_err;
This page took 0.026242 seconds and 5 git commands to generate.