Skip to content

Commit 7f146b2

Browse files
andy-shevbebarino
authored andcommitted
driver core: Replace kstrdup() + strreplace() with kstrdup_and_replace()
Replace open coded functionality of kstrdup_and_replace() with a call. Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20230804143910.15504-3-andriy.shevchenko@linux.intel.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 045ad46 commit 7f146b2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/base/core.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <linux/kstrtox.h>
1818
#include <linux/module.h>
1919
#include <linux/slab.h>
20-
#include <linux/string.h>
2120
#include <linux/kdev_t.h>
2221
#include <linux/notifier.h>
2322
#include <linux/of.h>
@@ -28,6 +27,7 @@
2827
#include <linux/netdevice.h>
2928
#include <linux/sched/signal.h>
3029
#include <linux/sched/mm.h>
30+
#include <linux/string_helpers.h>
3131
#include <linux/swiotlb.h>
3232
#include <linux/sysfs.h>
3333
#include <linux/dma-map-ops.h> /* for dma_default_coherent */
@@ -3910,10 +3910,9 @@ const char *device_get_devnode(const struct device *dev,
39103910
return dev_name(dev);
39113911

39123912
/* replace '!' in the name with '/' */
3913-
s = kstrdup(dev_name(dev), GFP_KERNEL);
3913+
s = kstrdup_and_replace(dev_name(dev), '!', '/', GFP_KERNEL);
39143914
if (!s)
39153915
return NULL;
3916-
strreplace(s, '!', '/');
39173916
return *tmp = s;
39183917
}
39193918

0 commit comments

Comments
 (0)