Skip to content

Commit

Permalink
pinctrl: st: Switch to use devm_kasprintf_strarray()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andy Shevchenko committed Nov 18, 2021
1 parent 3d4d3e0 commit 3956d6c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/pinctrl/pinctrl-st.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 3956d6c

Please sign in to comment.