Commit bb362d0e authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Stephen Boyd

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

Replace open coded functionality of kstrdup_and_replace() with a call.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230804143910.15504-5-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent 28df1500
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/string_helpers.h>
#include <linux/memblock.h> #include <linux/memblock.h>
#include <linux/device.h> #include <linux/device.h>
...@@ -123,10 +124,9 @@ static struct device_node *ti_find_clock_provider(struct device_node *from, ...@@ -123,10 +124,9 @@ static struct device_node *ti_find_clock_provider(struct device_node *from,
const char *n; const char *n;
char *tmp; char *tmp;
tmp = kstrdup(name, GFP_KERNEL); tmp = kstrdup_and_replace(name, '-', '_', GFP_KERNEL);
if (!tmp) if (!tmp)
return NULL; return NULL;
strreplace(tmp, '-', '_');
/* Node named "clock" with "clock-output-names" */ /* Node named "clock" with "clock-output-names" */
for_each_of_allnodes_from(from, np) { for_each_of_allnodes_from(from, np) {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/clk/ti.h> #include <linux/clk/ti.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/string_helpers.h>
#include <linux/timekeeping.h> #include <linux/timekeeping.h>
#include "clock.h" #include "clock.h"
...@@ -473,11 +474,11 @@ static const char * __init clkctrl_get_name(struct device_node *np) ...@@ -473,11 +474,11 @@ static const char * __init clkctrl_get_name(struct device_node *np)
const int prefix_len = 11; const int prefix_len = 11;
const char *compat; const char *compat;
const char *output; const char *output;
const char *end;
char *name; char *name;
if (!of_property_read_string_index(np, "clock-output-names", 0, if (!of_property_read_string_index(np, "clock-output-names", 0,
&output)) { &output)) {
const char *end;
int len; int len;
len = strlen(output); len = strlen(output);
...@@ -491,13 +492,13 @@ static const char * __init clkctrl_get_name(struct device_node *np) ...@@ -491,13 +492,13 @@ static const char * __init clkctrl_get_name(struct device_node *np)
of_property_for_each_string(np, "compatible", prop, compat) { of_property_for_each_string(np, "compatible", prop, compat) {
if (!strncmp("ti,clkctrl-", compat, prefix_len)) { if (!strncmp("ti,clkctrl-", compat, prefix_len)) {
end = compat + prefix_len;
/* Two letter minimum name length for l3, l4 etc */ /* Two letter minimum name length for l3, l4 etc */
if (strnlen(compat + prefix_len, 16) < 2) if (strnlen(end, 16) < 2)
continue; continue;
name = kasprintf(GFP_KERNEL, "%s", compat + prefix_len); name = kstrdup_and_replace(end, '-', '_', GFP_KERNEL);
if (!name) if (!name)
continue; continue;
strreplace(name, '-', '_');
return name; return name;
} }
......
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