diff options
author | Nathan Fontenot <nfont@linux.vnet.ibm.com> | 2016-06-20 10:00:39 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-07-15 01:02:26 -0400 |
commit | c2101c9039fe2a005f7b4138e028ed9a8468a48a (patch) | |
tree | 4957f58f3ad1030c677ba625f6a92504d6ae96fe /arch/powerpc | |
parent | 236977609a81150c4561c33fa62b5c1f37f2b234 (diff) |
powerpc/pseries: Move property cloning into its own routine
Move property cloning code into its own routine
Split the pieces of dlpar_clone_drconf_property() that create a copy of
the property struct into its own routine. This allows for creating
clones of more than just the ibm,dynamic-memory property used in memory
hotplug.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/platforms/pseries/hotplug-memory.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 2ce138542083..3dbc82b7e374 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c | |||
@@ -69,13 +69,36 @@ unsigned long pseries_memory_block_size(void) | |||
69 | return memblock_size; | 69 | return memblock_size; |
70 | } | 70 | } |
71 | 71 | ||
72 | static void dlpar_free_drconf_property(struct property *prop) | 72 | static void dlpar_free_property(struct property *prop) |
73 | { | 73 | { |
74 | kfree(prop->name); | 74 | kfree(prop->name); |
75 | kfree(prop->value); | 75 | kfree(prop->value); |
76 | kfree(prop); | 76 | kfree(prop); |
77 | } | 77 | } |
78 | 78 | ||
79 | static struct property *dlpar_clone_property(struct property *prop, | ||
80 | u32 prop_size) | ||
81 | { | ||
82 | struct property *new_prop; | ||
83 | |||
84 | new_prop = kzalloc(sizeof(*new_prop), GFP_KERNEL); | ||
85 | if (!new_prop) | ||
86 | return NULL; | ||
87 | |||
88 | new_prop->name = kstrdup(prop->name, GFP_KERNEL); | ||
89 | new_prop->value = kzalloc(prop_size, GFP_KERNEL); | ||
90 | if (!new_prop->name || !new_prop->value) { | ||
91 | dlpar_free_property(new_prop); | ||
92 | return NULL; | ||
93 | } | ||
94 | |||
95 | memcpy(new_prop->value, prop->value, prop->length); | ||
96 | new_prop->length = prop_size; | ||
97 | |||
98 | of_property_set_flag(new_prop, OF_DYNAMIC); | ||
99 | return new_prop; | ||
100 | } | ||
101 | |||
79 | static struct property *dlpar_clone_drconf_property(struct device_node *dn) | 102 | static struct property *dlpar_clone_drconf_property(struct device_node *dn) |
80 | { | 103 | { |
81 | struct property *prop, *new_prop; | 104 | struct property *prop, *new_prop; |
@@ -87,19 +110,10 @@ static struct property *dlpar_clone_drconf_property(struct device_node *dn) | |||
87 | if (!prop) | 110 | if (!prop) |
88 | return NULL; | 111 | return NULL; |
89 | 112 | ||
90 | new_prop = kzalloc(sizeof(*new_prop), GFP_KERNEL); | 113 | new_prop = dlpar_clone_property(prop, prop->length); |
91 | if (!new_prop) | 114 | if (!new_prop) |
92 | return NULL; | 115 | return NULL; |
93 | 116 | ||
94 | new_prop->name = kstrdup(prop->name, GFP_KERNEL); | ||
95 | new_prop->value = kmemdup(prop->value, prop->length, GFP_KERNEL); | ||
96 | if (!new_prop->name || !new_prop->value) { | ||
97 | dlpar_free_drconf_property(new_prop); | ||
98 | return NULL; | ||
99 | } | ||
100 | |||
101 | new_prop->length = prop->length; | ||
102 | |||
103 | /* Convert the property to cpu endian-ness */ | 117 | /* Convert the property to cpu endian-ness */ |
104 | p = new_prop->value; | 118 | p = new_prop->value; |
105 | *p = be32_to_cpu(*p); | 119 | *p = be32_to_cpu(*p); |
@@ -748,7 +762,7 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog) | |||
748 | break; | 762 | break; |
749 | } | 763 | } |
750 | 764 | ||
751 | dlpar_free_drconf_property(prop); | 765 | dlpar_free_property(prop); |
752 | 766 | ||
753 | dlpar_memory_out: | 767 | dlpar_memory_out: |
754 | of_node_put(dn); | 768 | of_node_put(dn); |