From bb362d0e91e198a9b71e2c60611999734f358067 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 4 Aug 2023 17:39:10 +0300 Subject: 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 Link: https://lore.kernel.org/r/20230804143910.15504-5-andriy.shevchenko@linux.intel.com Signed-off-by: Stephen Boyd --- drivers/clk/ti/clk.c | 4 ++-- drivers/clk/ti/clkctrl.c | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'drivers/clk') diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c index 3d636938a739..1862958ab412 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -123,10 +124,9 @@ static struct device_node *ti_find_clock_provider(struct device_node *from, const char *n; char *tmp; - tmp = kstrdup(name, GFP_KERNEL); + tmp = kstrdup_and_replace(name, '-', '_', GFP_KERNEL); if (!tmp) return NULL; - strreplace(tmp, '-', '_'); /* Node named "clock" with "clock-output-names" */ for_each_of_allnodes_from(from, np) { diff --git a/drivers/clk/ti/clkctrl.c b/drivers/clk/ti/clkctrl.c index 8c40f10280b7..607e34d8e289 100644 --- a/drivers/clk/ti/clkctrl.c +++ b/drivers/clk/ti/clkctrl.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "clock.h" @@ -473,11 +474,11 @@ static const char * __init clkctrl_get_name(struct device_node *np) const int prefix_len = 11; const char *compat; const char *output; + const char *end; char *name; if (!of_property_read_string_index(np, "clock-output-names", 0, &output)) { - const char *end; int len; len = strlen(output); @@ -491,13 +492,13 @@ static const char * __init clkctrl_get_name(struct device_node *np) of_property_for_each_string(np, "compatible", prop, compat) { if (!strncmp("ti,clkctrl-", compat, prefix_len)) { + end = compat + prefix_len; /* Two letter minimum name length for l3, l4 etc */ - if (strnlen(compat + prefix_len, 16) < 2) + if (strnlen(end, 16) < 2) continue; - name = kasprintf(GFP_KERNEL, "%s", compat + prefix_len); + name = kstrdup_and_replace(end, '-', '_', GFP_KERNEL); if (!name) continue; - strreplace(name, '-', '_'); return name; } -- cgit v1.2.3