diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2023-08-04 17:39:10 +0300 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2023-08-04 18:21:51 -0700 |
commit | bb362d0e91e198a9b71e2c60611999734f358067 (patch) | |
tree | ee8d3c151f9d46cdcac2d4fe28c3c406f4bde03f | |
parent | 28df1500f53874e310d55b64dfbdfde286953ebc (diff) | |
download | linux-stable-bb362d0e91e198a9b71e2c60611999734f358067.tar.gz linux-stable-bb362d0e91e198a9b71e2c60611999734f358067.tar.bz2 linux-stable-bb362d0e91e198a9b71e2c60611999734f358067.zip |
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>
-rw-r--r-- | drivers/clk/ti/clk.c | 4 | ||||
-rw-r--r-- | drivers/clk/ti/clkctrl.c | 9 |
2 files changed, 7 insertions, 6 deletions
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 <linux/of_address.h> #include <linux/list.h> #include <linux/regmap.h> +#include <linux/string_helpers.h> #include <linux/memblock.h> #include <linux/device.h> @@ -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 <linux/of_address.h> #include <linux/clk/ti.h> #include <linux/delay.h> +#include <linux/string_helpers.h> #include <linux/timekeeping.h> #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; } |