path: root/drivers/of/dynamic.c
diff options
authorGrant Likely <grant.likely@linaro.org>2014-11-14 15:33:07 +0000
committerMark Brown <broonie@kernel.org>2015-02-20 23:41:28 +0900
commit8e13f7dacf243610e4478d82479f85b97d5c923f (patch)
tree31ce487cfadd4e97a5b729f9cfc62fc0613fe5cb /drivers/of/dynamic.c
parent94b62a841aac10919826afaf3cdee118dbdabef2 (diff)
of: Use vargs in __of_node_alloc
The overlay code needs to construct a new full_name from the parent name and the node name, but the current method has to allocate and then free an temporary string which is wasteful. Fix this problem by using vargs to pass in a format and arguments into __of_node_alloc(). At the same time remove the allocflags argument to __of_node_alloc(). The only users all use GFP_KERNEL, so there is no need to provide it as an option. If there is ever a need later it can be added back. Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit ef8bbd73a76197cf8362a2b43aaadc5717bd0746) Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/of/dynamic.c')
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index d4a24d716f1d..925fe13052bd 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -409,33 +409,33 @@ struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags)
* __of_node_alloc() - Create an empty device node dynamically.
* @full_name: Full name of the new device node
- * @allocflags: Allocation flags (typically pass GFP_KERNEL)
* Create an empty device tree node, 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_alloc(const char *full_name, gfp_t allocflags)
+struct device_node *__of_node_alloc(const char *fmt, ...)
+ va_list vargs;
struct device_node *node;
- node = kzalloc(sizeof(*node), allocflags);
+ node = kzalloc(sizeof(*node), GFP_KERNEL);
if (!node)
return NULL;
- node->full_name = kstrdup(full_name, allocflags);
- of_node_set_flag(node, OF_DYNAMIC);
- of_node_set_flag(node, OF_DETACHED);
+ va_start(vargs, fmt);
+ node->full_name = kvasprintf(GFP_KERNEL, fmt, vargs);
+ va_end(vargs);
if (!node->full_name)
goto err_free;
+ of_node_set_flag(node, OF_DYNAMIC);
+ of_node_set_flag(node, OF_DETACHED);
return node;
- kfree(node->full_name);
return NULL;