pinctrl: zynqmp: Unify pin naming
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 5 Nov 2021 12:42:41 +0000 (14:42 +0200)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 19 Nov 2021 08:38:16 +0000 (10:38 +0200)
Since we have devm_kasprintf_strarray() helper, which is used in
the rest of pin control drivers, it makes sense to switch this
driver to it. The pin names are not part of any ABI and hence
there will be no regression based on that. Otherwise all generated
pin names will follow the same schema in the pin control subsystem.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-zynqmp.c

index e14012209992f997d086e15fc2462b08bbd6e938..42da6bd399ee78950bc42f5a85d9e8d465a5ed42 100644 (file)
@@ -809,6 +809,7 @@ static int zynqmp_pinctrl_prepare_pin_desc(struct device *dev,
                                           unsigned int *npins)
 {
        struct pinctrl_pin_desc *pins, *pin;
+       char **pin_names;
        int ret;
        int i;
 
@@ -820,13 +821,14 @@ static int zynqmp_pinctrl_prepare_pin_desc(struct device *dev,
        if (!pins)
                return -ENOMEM;
 
+       pin_names = devm_kasprintf_strarray(dev, ZYNQMP_PIN_PREFIX, *npins);
+       if (IS_ERR(pin_names))
+               return PTR_ERR(pin_names);
+
        for (i = 0; i < *npins; i++) {
                pin = &pins[i];
                pin->number = i;
-               pin->name = devm_kasprintf(dev, GFP_KERNEL, "%s%d",
-                                          ZYNQMP_PIN_PREFIX, i);
-               if (!pin->name)
-                       return -ENOMEM;
+               pin->name = pin_names[i];
        }
 
        *zynqmp_pins = pins;