Skip to content

Commit 0d105d0

Browse files
vo4rafaeljw
authored andcommitted
PM / wakeup: Drop wakeup_source_init(), wakeup_source_prepare()
wakeup_source_init() has no users. Remove it. As a result, wakeup_source_prepare() is only called from wakeup_source_create(). Merge wakeup_source_prepare() into wakeup_source_create() and remove it. Change wakeup_source_create() behavior so that assigning NULL to wakeup source's name throws an error. Signed-off-by: Tri Vo <trong@android.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent d30bdfc commit 0d105d0

2 files changed

Lines changed: 13 additions & 31 deletions

File tree

‎drivers/base/power/wakeup.c‎

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,37 +72,30 @@ static struct wakeup_source deleted_ws = {
7272
.lock = __SPIN_LOCK_UNLOCKED(deleted_ws.lock),
7373
};
7474

75-
/**
76-
* wakeup_source_prepare - Prepare a new wakeup source for initialization.
77-
* @ws: Wakeup source to prepare.
78-
* @name: Pointer to the name of the new wakeup source.
79-
*
80-
* Callers must ensure that the @name string won't be freed when @ws is still in
81-
* use.
82-
*/
83-
void wakeup_source_prepare(struct wakeup_source *ws, const char *name)
84-
{
85-
if (ws) {
86-
memset(ws, 0, sizeof(*ws));
87-
ws->name = name;
88-
}
89-
}
90-
EXPORT_SYMBOL_GPL(wakeup_source_prepare);
91-
9275
/**
9376
* wakeup_source_create - Create a struct wakeup_source object.
9477
* @name: Name of the new wakeup source.
9578
*/
9679
struct wakeup_source *wakeup_source_create(const char *name)
9780
{
9881
struct wakeup_source *ws;
82+
const char *ws_name;
9983

100-
ws = kmalloc(sizeof(*ws), GFP_KERNEL);
84+
ws = kzalloc(sizeof(*ws), GFP_KERNEL);
10185
if (!ws)
102-
return NULL;
86+
goto err_ws;
87+
88+
ws_name = kstrdup_const(name, GFP_KERNEL);
89+
if (!ws_name)
90+
goto err_name;
91+
ws->name = ws_name;
10392

104-
wakeup_source_prepare(ws, name ? kstrdup_const(name, GFP_KERNEL) : NULL);
10593
return ws;
94+
95+
err_name:
96+
kfree(ws);
97+
err_ws:
98+
return NULL;
10699
}
107100
EXPORT_SYMBOL_GPL(wakeup_source_create);
108101

‎include/linux/pm_wakeup.h‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ static inline void device_set_wakeup_path(struct device *dev)
8181
}
8282

8383
/* drivers/base/power/wakeup.c */
84-
extern void wakeup_source_prepare(struct wakeup_source *ws, const char *name);
8584
extern struct wakeup_source *wakeup_source_create(const char *name);
8685
extern void wakeup_source_destroy(struct wakeup_source *ws);
8786
extern void wakeup_source_add(struct wakeup_source *ws);
@@ -112,9 +111,6 @@ static inline bool device_can_wakeup(struct device *dev)
112111
return dev->power.can_wakeup;
113112
}
114113

115-
static inline void wakeup_source_prepare(struct wakeup_source *ws,
116-
const char *name) {}
117-
118114
static inline struct wakeup_source *wakeup_source_create(const char *name)
119115
{
120116
return NULL;
@@ -181,13 +177,6 @@ static inline void pm_wakeup_dev_event(struct device *dev, unsigned int msec,
181177

182178
#endif /* !CONFIG_PM_SLEEP */
183179

184-
static inline void wakeup_source_init(struct wakeup_source *ws,
185-
const char *name)
186-
{
187-
wakeup_source_prepare(ws, name);
188-
wakeup_source_add(ws);
189-
}
190-
191180
static inline void __pm_wakeup_event(struct wakeup_source *ws, unsigned int msec)
192181
{
193182
return pm_wakeup_ws_event(ws, msec, false);

0 commit comments

Comments
 (0)