lkml.org 
[lkml]   [2019]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/3] pinctrl: xway: Use devm_kasprintf() instead of fixed buffer formatting
Date
Improve readability and maintainability by replacing a hardcoded string
allocation and formatting by the use of the devm_kasprintf() helper.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/pinctrl/pinctrl-xway.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c
index 376222d0e5c570eb..913d38f29b7306f3 100644
--- a/drivers/pinctrl/pinctrl-xway.c
+++ b/drivers/pinctrl/pinctrl-xway.c
@@ -1731,13 +1731,11 @@ static int pinmux_xway_probe(struct platform_device *pdev)
return -ENOMEM;

for (i = 0; i < xway_chip.ngpio; i++) {
- /* strlen("ioXY") + 1 = 5 */
- char *name = devm_kzalloc(&pdev->dev, 5, GFP_KERNEL);
+ char *name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "io%d", i);

if (!name)
return -ENOMEM;

- snprintf(name, 5, "io%d", i);
xway_info.pads[i].number = GPIO0 + i;
xway_info.pads[i].name = name;
}
--
2.17.1
\
 
 \ /
  Last update: 2019-07-31 15:31    [W:0.057 / U:0.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site