Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Shevchenko and committed by
Stephen Boyd
7f146b24 045ad464

+2 -3
+2 -3
drivers/base/core.c
··· 17 17 #include <linux/kstrtox.h> 18 18 #include <linux/module.h> 19 19 #include <linux/slab.h> 20 - #include <linux/string.h> 21 20 #include <linux/kdev_t.h> 22 21 #include <linux/notifier.h> 23 22 #include <linux/of.h> ··· 27 28 #include <linux/netdevice.h> 28 29 #include <linux/sched/signal.h> 29 30 #include <linux/sched/mm.h> 31 + #include <linux/string_helpers.h> 30 32 #include <linux/swiotlb.h> 31 33 #include <linux/sysfs.h> 32 34 #include <linux/dma-map-ops.h> /* for dma_default_coherent */ ··· 3910 3910 return dev_name(dev); 3911 3911 3912 3912 /* replace '!' in the name with '/' */ 3913 - s = kstrdup(dev_name(dev), GFP_KERNEL); 3913 + s = kstrdup_and_replace(dev_name(dev), '!', '/', GFP_KERNEL); 3914 3914 if (!s) 3915 3915 return NULL; 3916 - strreplace(s, '!', '/'); 3917 3916 return *tmp = s; 3918 3917 } 3919 3918