From: Rasmus Villemoes Date: Thu, 25 Jun 2015 22:02:33 +0000 (-0700) Subject: drivers/base/core.c: use strreplace() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a29fd614a6af57610b1963e3445f1758c3806187;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git drivers/base/core.c: use strreplace() This eliminates a little .text and avoids repeating the strchr call when we meet a '!' (which will happen at least once). Signed-off-by: Rasmus Villemoes Cc: Greg Kroah-Hartman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/base/core.c b/drivers/base/core.c index 21d13038534e..dafae6d2f7ac 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1303,12 +1303,11 @@ const char *device_get_devnode(struct device *dev, return dev_name(dev); /* replace '!' in the name with '/' */ - *tmp = kstrdup(dev_name(dev), GFP_KERNEL); - if (!*tmp) + s = kstrdup(dev_name(dev), GFP_KERNEL); + if (!s) return NULL; - while ((s = strchr(*tmp, '!'))) - s[0] = '/'; - return *tmp; + strreplace(s, '!', '/'); + return *tmp = s; } /**