Commit c2101c90 authored by Nathan Fontenot's avatar Nathan Fontenot Committed by Michael Ellerman

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: default avatarNathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 23697760
...@@ -69,13 +69,36 @@ unsigned long pseries_memory_block_size(void) ...@@ -69,13 +69,36 @@ unsigned long pseries_memory_block_size(void)
return memblock_size; return memblock_size;
} }
static void dlpar_free_drconf_property(struct property *prop) static void dlpar_free_property(struct property *prop)
{ {
kfree(prop->name); kfree(prop->name);
kfree(prop->value); kfree(prop->value);
kfree(prop); kfree(prop);
} }
static struct property *dlpar_clone_property(struct property *prop,
u32 prop_size)
{
struct property *new_prop;
new_prop = kzalloc(sizeof(*new_prop), GFP_KERNEL);
if (!new_prop)
return NULL;
new_prop->name = kstrdup(prop->name, GFP_KERNEL);
new_prop->value = kzalloc(prop_size, GFP_KERNEL);
if (!new_prop->name || !new_prop->value) {
dlpar_free_property(new_prop);
return NULL;
}
memcpy(new_prop->value, prop->value, prop->length);
new_prop->length = prop_size;
of_property_set_flag(new_prop, OF_DYNAMIC);
return new_prop;
}
static struct property *dlpar_clone_drconf_property(struct device_node *dn) static struct property *dlpar_clone_drconf_property(struct device_node *dn)
{ {
struct property *prop, *new_prop; struct property *prop, *new_prop;
...@@ -87,19 +110,10 @@ static struct property *dlpar_clone_drconf_property(struct device_node *dn) ...@@ -87,19 +110,10 @@ static struct property *dlpar_clone_drconf_property(struct device_node *dn)
if (!prop) if (!prop)
return NULL; return NULL;
new_prop = kzalloc(sizeof(*new_prop), GFP_KERNEL); new_prop = dlpar_clone_property(prop, prop->length);
if (!new_prop) if (!new_prop)
return NULL; return NULL;
new_prop->name = kstrdup(prop->name, GFP_KERNEL);
new_prop->value = kmemdup(prop->value, prop->length, GFP_KERNEL);
if (!new_prop->name || !new_prop->value) {
dlpar_free_drconf_property(new_prop);
return NULL;
}
new_prop->length = prop->length;
/* Convert the property to cpu endian-ness */ /* Convert the property to cpu endian-ness */
p = new_prop->value; p = new_prop->value;
*p = be32_to_cpu(*p); *p = be32_to_cpu(*p);
...@@ -748,7 +762,7 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog) ...@@ -748,7 +762,7 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
break; break;
} }
dlpar_free_drconf_property(prop); dlpar_free_property(prop);
dlpar_memory_out: dlpar_memory_out:
of_node_put(dn); of_node_put(dn);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment