Skip to content

Commit

Permalink
of: dynamic: Add __of_node_dupv()
Browse files Browse the repository at this point in the history
Add an __of_node_dupv() private method and make __of_node_dup() use it.
This is required for the subsequent changeset accessors which will
make use of it.

Signed-off-by: Pantelis Antoniou <[email protected]>
  • Loading branch information
pantoniou authored and RobertCNelson committed Jan 28, 2020
1 parent d05509b commit ab5ab74
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions drivers/of/dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,26 +396,25 @@ struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags)
}

/**
* __of_node_dup() - Duplicate or create an empty device node dynamically.
* @fmt: Format string (plus vargs) for new full name of the device node
* __of_node_dupv() - Duplicate or create an empty device node dynamically.
* @fmt: Format string for new full name of the device node
* @vargs: va_list containing the arugments for the node full name
*
* Create an device tree node, either by duplicating an empty node or by allocating
* an empty one suitable for further modification. The node data are
* dynamically allocated and all the node flags have the OF_DYNAMIC &
* OF_DETACHED bits set. Returns the newly allocated node or NULL on out of
* memory error.
*/
struct device_node *__of_node_dup(const struct device_node *np, const char *fmt, ...)
struct device_node *__of_node_dupv(const struct device_node *np,
const char *fmt, va_list vargs)
{
va_list vargs;
struct device_node *node;

node = kzalloc(sizeof(*node), GFP_KERNEL);
if (!node)
return NULL;
va_start(vargs, fmt);
node->full_name = kvasprintf(GFP_KERNEL, fmt, vargs);
va_end(vargs);
if (!node->full_name) {
kfree(node);
return NULL;
Expand Down Expand Up @@ -447,6 +446,24 @@ struct device_node *__of_node_dup(const struct device_node *np, const char *fmt,
return NULL;
}

/**
* __of_node_dup() - Duplicate or create an empty device node dynamically.
* @fmt: Format string (plus vargs) for new full name of the device node
*
* See: __of_node_dupv()
*/
struct device_node *__of_node_dup(const struct device_node *np,
const char *fmt, ...)
{
va_list vargs;
struct device_node *node;

va_start(vargs, fmt);
node = __of_node_dupv(np, fmt, vargs);
va_end(vargs);
return node;
}

static void __of_changeset_entry_destroy(struct of_changeset_entry *ce)
{
of_node_put(ce->np);
Expand Down

0 comments on commit ab5ab74

Please sign in to comment.