Avoid an unnecessary allocation/free by using stack instead.

Signed-off-by; Joe Perches <[email protected]>
---

This allocation seems unnecessary and the kasprintf isn't
checked for non-null, so maybe this is better.

 drivers/pinctrl/devicetree.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
index 340fb4e..ffb59c8 100644
--- a/drivers/pinctrl/devicetree.c
+++ b/drivers/pinctrl/devicetree.c
@@ -176,13 +176,13 @@ int pinctrl_dt_to_map(struct pinctrl *p)
 {
        struct device_node *np = p->dev->of_node;
        int state, ret;
-       char *propname;
        struct property *prop;
        const char *statename;
        const __be32 *list;
        int size, config;
        phandle phandle;
        struct device_node *np_config;
+       char propname[9 + sizeof(int) * 2 + 4] = "pinctrl-";
 
        /* CONFIG_OF enabled, p->dev not instantiated from DT */
        if (!np) {
@@ -196,9 +196,8 @@ int pinctrl_dt_to_map(struct pinctrl *p)
        /* For each defined state ID */
        for (state = 0; ; state++) {
                /* Retrieve the pinctrl-* property */
-               propname = kasprintf(GFP_KERNEL, "pinctrl-%d", state);
+               snprintf(&propname[8], ARRAY_SIZE(propname) - 9, "%d", state);
                prop = of_find_property(np, propname, &size);
-               kfree(propname);
                if (!prop)
                        break;
                list = prop->value;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to