Splitting out new_property() for coming reusing and moving it to
of_helpers.c.

Also do some coding style cleanup.

Signed-off-by: Pingfan Liu <kernelf...@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Herrenschmidt <b...@kernel.crashing.org>
Cc: Paul Mackerras <pau...@samba.org>
Cc: Michael Ellerman <m...@ellerman.id.au>
Cc: Hari Bathini <hbath...@linux.ibm.com>
Cc: Aneesh Kumar K.V <aneesh.ku...@linux.ibm.com>
Cc: Oliver O'Halloran <ooh...@gmail.com>
Cc: Dan Williams <dan.j.willi...@intel.com>
Cc: Andrew Donnellan <a...@linux.ibm.com>
Cc: Christophe Leroy <christophe.le...@c-s.fr>
Cc: ke...@lists.infradead.org
---
 arch/powerpc/platforms/pseries/of_helpers.c | 28 ++++++++++++++++++++++++++++
 arch/powerpc/platforms/pseries/of_helpers.h |  3 +++
 arch/powerpc/platforms/pseries/reconfig.c   | 26 --------------------------
 3 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/of_helpers.c 
b/arch/powerpc/platforms/pseries/of_helpers.c
index 66dfd82..1022e0f 100644
--- a/arch/powerpc/platforms/pseries/of_helpers.c
+++ b/arch/powerpc/platforms/pseries/of_helpers.c
@@ -7,6 +7,34 @@
 
 #include "of_helpers.h"
 
+struct property *new_property(const char *name, const int length,
+               const unsigned char *value, struct property *last)
+{
+       struct property *new = kzalloc(sizeof(*new), GFP_KERNEL);
+
+       if (!new)
+               return NULL;
+
+       new->name = kstrdup(name, GFP_KERNEL);
+       if (!new->name)
+               goto cleanup;
+       new->value = kmalloc(length + 1, GFP_KERNEL);
+       if (!new->value)
+               goto cleanup;
+
+       memcpy(new->value, value, length);
+       *(((char *)new->value) + length) = 0;
+       new->length = length;
+       new->next = last;
+       return new;
+
+cleanup:
+       kfree(new->name);
+       kfree(new->value);
+       kfree(new);
+       return NULL;
+}
+
 /**
  * pseries_of_derive_parent - basically like dirname(1)
  * @path:  the full_name of a node to be added to the tree
diff --git a/arch/powerpc/platforms/pseries/of_helpers.h 
b/arch/powerpc/platforms/pseries/of_helpers.h
index decad65..34add82 100644
--- a/arch/powerpc/platforms/pseries/of_helpers.h
+++ b/arch/powerpc/platforms/pseries/of_helpers.h
@@ -4,6 +4,9 @@
 
 #include <linux/of.h>
 
+struct property *new_property(const char *name, const int length,
+               const unsigned char *value, struct property *last);
+
 struct device_node *pseries_of_derive_parent(const char *path);
 
 #endif /* _PSERIES_OF_HELPERS_H */
diff --git a/arch/powerpc/platforms/pseries/reconfig.c 
b/arch/powerpc/platforms/pseries/reconfig.c
index 7f7369f..8e5a2ba 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -165,32 +165,6 @@ static char * parse_next_property(char *buf, char *end, 
char **name, int *length
        return tmp;
 }
 
-static struct property *new_property(const char *name, const int length,
-                                    const unsigned char *value, struct 
property *last)
-{
-       struct property *new = kzalloc(sizeof(*new), GFP_KERNEL);
-
-       if (!new)
-               return NULL;
-
-       if (!(new->name = kstrdup(name, GFP_KERNEL)))
-               goto cleanup;
-       if (!(new->value = kmalloc(length + 1, GFP_KERNEL)))
-               goto cleanup;
-
-       memcpy(new->value, value, length);
-       *(((char *)new->value) + length) = 0;
-       new->length = length;
-       new->next = last;
-       return new;
-
-cleanup:
-       kfree(new->name);
-       kfree(new->value);
-       kfree(new);
-       return NULL;
-}
-
 static int do_add_node(char *buf, size_t bufsize)
 {
        char *path, *end, *name;
-- 
2.7.5

Reply via email to