Skip to content

Commit

Permalink
PM / wakeup: wakeup_source_create: use kstrdup_const
Browse files Browse the repository at this point in the history
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]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
Villemoes authored and rafaeljw committed Sep 25, 2015
1 parent a6f5f0d commit 7236214
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/base/power/wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,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);
Expand Down Expand Up @@ -157,7 +157,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);
Expand Down

0 comments on commit 7236214

Please sign in to comment.