diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2021-11-05 15:42:40 +0300 |
---|---|---|
committer | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2021-11-18 19:40:10 +0300 |
commit | 3956d6c85f26b5dd59cc6d3bf85a6a7341c68518 (patch) | |
tree | a33ab71bc1dbb3935ac3cf25ccb103933e6713a9 /drivers/pinctrl/pinctrl-st.c | |
parent | 3d4d3e0a7d67a9d49fb661c6ea3b51fc3696030f (diff) | |
download | linux-3956d6c85f26b5dd59cc6d3bf85a6a7341c68518.tar.xz |
pinctrl: st: Switch to use devm_kasprintf_strarray()
Since we have a generic helper, switch the module to use it.
As a side effect, add check for the memory allocation failures and
cleanup it either in error case or when driver is unloading.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-st.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-st.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 9cb0da88b098..0fea71fd9a00 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -1624,6 +1624,8 @@ static int st_pctl_probe_dt(struct platform_device *pdev, for_each_child_of_node(np, child) { if (of_property_read_bool(child, "gpio-controller")) { const char *bank_name = NULL; + char **pin_names; + ret = st_gpiolib_register_bank(info, bank, child); if (ret) { of_node_put(child); @@ -1632,10 +1634,16 @@ static int st_pctl_probe_dt(struct platform_device *pdev, k = info->banks[bank].range.pin_base; bank_name = info->banks[bank].range.name; + + pin_names = devm_kasprintf_strarray(dev, bank_name, ST_GPIO_PINS_PER_BANK); + if (IS_ERR(pin_names)) { + of_node_put(child); + return PTR_ERR(pin_names); + } + for (j = 0; j < ST_GPIO_PINS_PER_BANK; j++, k++) { pdesc->number = k; - pdesc->name = kasprintf(GFP_KERNEL, "%s[%d]", - bank_name, j); + pdesc->name = pin_names[j]; pdesc++; } st_parse_syscfgs(info, bank, child); |