Skip to content

Commit bb362d0

Browse files
andy-shevbebarino
authored andcommitted
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>
1 parent 28df150 commit bb362d0

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

drivers/clk/ti/clk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/of_address.h>
1717
#include <linux/list.h>
1818
#include <linux/regmap.h>
19+
#include <linux/string_helpers.h>
1920
#include <linux/memblock.h>
2021
#include <linux/device.h>
2122

@@ -123,10 +124,9 @@ static struct device_node *ti_find_clock_provider(struct device_node *from,
123124
const char *n;
124125
char *tmp;
125126

126-
tmp = kstrdup(name, GFP_KERNEL);
127+
tmp = kstrdup_and_replace(name, '-', '_', GFP_KERNEL);
127128
if (!tmp)
128129
return NULL;
129-
strreplace(tmp, '-', '_');
130130

131131
/* Node named "clock" with "clock-output-names" */
132132
for_each_of_allnodes_from(from, np) {

drivers/clk/ti/clkctrl.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/of_address.h>
1414
#include <linux/clk/ti.h>
1515
#include <linux/delay.h>
16+
#include <linux/string_helpers.h>
1617
#include <linux/timekeeping.h>
1718
#include "clock.h"
1819

@@ -473,11 +474,11 @@ static const char * __init clkctrl_get_name(struct device_node *np)
473474
const int prefix_len = 11;
474475
const char *compat;
475476
const char *output;
477+
const char *end;
476478
char *name;
477479

478480
if (!of_property_read_string_index(np, "clock-output-names", 0,
479481
&output)) {
480-
const char *end;
481482
int len;
482483

483484
len = strlen(output);
@@ -491,13 +492,13 @@ static const char * __init clkctrl_get_name(struct device_node *np)
491492

492493
of_property_for_each_string(np, "compatible", prop, compat) {
493494
if (!strncmp("ti,clkctrl-", compat, prefix_len)) {
495+
end = compat + prefix_len;
494496
/* Two letter minimum name length for l3, l4 etc */
495-
if (strnlen(compat + prefix_len, 16) < 2)
497+
if (strnlen(end, 16) < 2)
496498
continue;
497-
name = kasprintf(GFP_KERNEL, "%s", compat + prefix_len);
499+
name = kstrdup_and_replace(end, '-', '_', GFP_KERNEL);
498500
if (!name)
499501
continue;
500-
strreplace(name, '-', '_');
501502

502503
return name;
503504
}

0 commit comments

Comments
 (0)