Commit 069d7796 authored by Andy Shevchenko's avatar Andy Shevchenko

pinctrl/rockchip: 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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarHeiko Stuebner <heiko@sntech.de>
parent 0045028f
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/mfd/syscon.h> #include <linux/mfd/syscon.h>
#include <linux/string_helpers.h>
#include <dt-bindings/pinctrl/rockchip.h> #include <dt-bindings/pinctrl/rockchip.h>
#include "core.h" #include "core.h"
...@@ -2452,6 +2454,7 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, ...@@ -2452,6 +2454,7 @@ static int rockchip_pinctrl_register(struct platform_device *pdev,
struct pinctrl_pin_desc *pindesc, *pdesc; struct pinctrl_pin_desc *pindesc, *pdesc;
struct rockchip_pin_bank *pin_bank; struct rockchip_pin_bank *pin_bank;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
char **pin_names;
int pin, bank, ret; int pin, bank, ret;
int k; int k;
...@@ -2471,10 +2474,14 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, ...@@ -2471,10 +2474,14 @@ static int rockchip_pinctrl_register(struct platform_device *pdev,
pdesc = pindesc; pdesc = pindesc;
for (bank = 0, k = 0; bank < info->ctrl->nr_banks; bank++) { for (bank = 0, k = 0; bank < info->ctrl->nr_banks; bank++) {
pin_bank = &info->ctrl->pin_banks[bank]; pin_bank = &info->ctrl->pin_banks[bank];
pin_names = devm_kasprintf_strarray(dev, pin_bank->name, pin_bank->nr_pins);
if (IS_ERR(pin_names))
return PTR_ERR(pin_names);
for (pin = 0; pin < pin_bank->nr_pins; pin++, k++) { for (pin = 0; pin < pin_bank->nr_pins; pin++, k++) {
pdesc->number = k; pdesc->number = k;
pdesc->name = kasprintf(GFP_KERNEL, "%s-%d", pdesc->name = pin_names[pin];
pin_bank->name, pin);
pdesc++; pdesc++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment