Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: ti: Replace kstrdup() + strreplace() with kstrdup_and_replace()

Replace open coded functionality of kstrdup_and_replace() with a call.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230804143910.15504-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Andy Shevchenko and committed by
Stephen Boyd
bb362d0e 28df1500

+7 -6
+2 -2
drivers/clk/ti/clk.c
··· 16 16 #include <linux/of_address.h> 17 17 #include <linux/list.h> 18 18 #include <linux/regmap.h> 19 + #include <linux/string_helpers.h> 19 20 #include <linux/memblock.h> 20 21 #include <linux/device.h> 21 22 ··· 124 123 const char *n; 125 124 char *tmp; 126 125 127 - tmp = kstrdup(name, GFP_KERNEL); 126 + tmp = kstrdup_and_replace(name, '-', '_', GFP_KERNEL); 128 127 if (!tmp) 129 128 return NULL; 130 - strreplace(tmp, '-', '_'); 131 129 132 130 /* Node named "clock" with "clock-output-names" */ 133 131 for_each_of_allnodes_from(from, np) {
+5 -4
drivers/clk/ti/clkctrl.c
··· 13 13 #include <linux/of_address.h> 14 14 #include <linux/clk/ti.h> 15 15 #include <linux/delay.h> 16 + #include <linux/string_helpers.h> 16 17 #include <linux/timekeeping.h> 17 18 #include "clock.h" 18 19 ··· 474 473 const int prefix_len = 11; 475 474 const char *compat; 476 475 const char *output; 476 + const char *end; 477 477 char *name; 478 478 479 479 if (!of_property_read_string_index(np, "clock-output-names", 0, 480 480 &output)) { 481 - const char *end; 482 481 int len; 483 482 484 483 len = strlen(output); ··· 492 491 493 492 of_property_for_each_string(np, "compatible", prop, compat) { 494 493 if (!strncmp("ti,clkctrl-", compat, prefix_len)) { 494 + end = compat + prefix_len; 495 495 /* Two letter minimum name length for l3, l4 etc */ 496 - if (strnlen(compat + prefix_len, 16) < 2) 496 + if (strnlen(end, 16) < 2) 497 497 continue; 498 - name = kasprintf(GFP_KERNEL, "%s", compat + prefix_len); 498 + name = kstrdup_and_replace(end, '-', '_', GFP_KERNEL); 499 499 if (!name) 500 500 continue; 501 - strreplace(name, '-', '_'); 502 501 503 502 return name; 504 503 }