PM / wakeup: wakeup_source_create: use kstrdup_const
Subsystems (4)
PATCH 1/1 PM / wakeup: wakeup_source_create: use kstrdup_const
Using kstrdup_const allows us to save a little runtime memory (and a string copy) in the common case where name is a string literal.
Signed-off-by Rasmus Villemoes <[email protected]>
--- drivers/base/power/wakeup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/power/wakeup.c +2 -2
@@ -91,7 +91,7 @@ struct wakeup_source *wakeup_source_create(const char *name)if (!ws)return NULL ; -wakeup_source_prepare (ws, name ?kstrdup (name,GFP_KERNEL ) :NULL ); +wakeup_source_prepare (ws, name ?kstrdup_const (name,GFP_KERNEL ) :NULL );return ws; }EXPORT_SYMBOL_GPL (wakeup_source_create);
@@ -154,7 +154,7 @@ void wakeup_source_destroy(struct wakeup_source *ws)wakeup_source_drop (ws);wakeup_source_record (ws); -kfree (ws->name); +kfree_const (ws->name);kfree (ws); }EXPORT_SYMBOL_GPL (wakeup_source_destroy);
Signature · 1 line
2.1.3
Rafael J. Wysocki
AppliedQuoted 4 lines · Rasmus Villemoes
Using
kstrdup_constallows us to save a little runtime memory (and a string copy) in the common case where name is a string literal.Signed-off-by Rasmus Villemoes <[email protected]>
Applied, thanks!
Rafael