Skip to content

Commit

Permalink
drivers/base/core.c: use strreplace()
Browse files Browse the repository at this point in the history
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 <linux@rasmusvillemoes.dk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Rasmus Villemoes authored and Linus Torvalds committed Jun 26, 2015
1 parent 2abf114 commit a29fd61
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit a29fd61

Please sign in to comment.