Skip to content

Commit

Permalink
PM / core: Convert timers to use timer_setup()
Browse files Browse the repository at this point in the history
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly. Removes test of .data field, since
that will be going away.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Kees Cook authored and Rafael J. Wysocki committed Oct 24, 2017
1 parent b082ddd commit 96428e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
7 changes: 3 additions & 4 deletions drivers/base/power/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,9 @@ static void pm_runtime_work(struct work_struct *work)
*
* Check if the time is right and queue a suspend request.
*/
static void pm_suspend_timer_fn(unsigned long data)
static void pm_suspend_timer_fn(struct timer_list *t)
{
struct device *dev = (struct device *)data;
struct device *dev = from_timer(dev, t, power.suspend_timer);
unsigned long flags;
unsigned long expires;

Expand Down Expand Up @@ -1499,8 +1499,7 @@ void pm_runtime_init(struct device *dev)
INIT_WORK(&dev->power.work, pm_runtime_work);

dev->power.timer_expires = 0;
setup_timer(&dev->power.suspend_timer, pm_suspend_timer_fn,
(unsigned long)dev);
timer_setup(&dev->power.suspend_timer, pm_suspend_timer_fn, 0);

init_waitqueue_head(&dev->power.wait_queue);
}
Expand Down
11 changes: 5 additions & 6 deletions drivers/base/power/wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static unsigned int saved_count;

static DEFINE_SPINLOCK(events_lock);

static void pm_wakeup_timer_fn(unsigned long data);
static void pm_wakeup_timer_fn(struct timer_list *t);

static LIST_HEAD(wakeup_sources);

Expand Down Expand Up @@ -176,7 +176,7 @@ void wakeup_source_add(struct wakeup_source *ws)
return;

spin_lock_init(&ws->lock);
setup_timer(&ws->timer, pm_wakeup_timer_fn, (unsigned long)ws);
timer_setup(&ws->timer, pm_wakeup_timer_fn, 0);
ws->active = false;
ws->last_time = ktime_get();

Expand Down Expand Up @@ -481,8 +481,7 @@ static bool wakeup_source_not_registered(struct wakeup_source *ws)
* Use timer struct to check if the given source is initialized
* by wakeup_source_add.
*/
return ws->timer.function != pm_wakeup_timer_fn ||
ws->timer.data != (unsigned long)ws;
return ws->timer.function != (TIMER_FUNC_TYPE)pm_wakeup_timer_fn;
}

/*
Expand Down Expand Up @@ -724,9 +723,9 @@ EXPORT_SYMBOL_GPL(pm_relax);
* in @data if it is currently active and its timer has not been canceled and
* the expiration time of the timer is not in future.
*/
static void pm_wakeup_timer_fn(unsigned long data)
static void pm_wakeup_timer_fn(struct timer_list *t)
{
struct wakeup_source *ws = (struct wakeup_source *)data;
struct wakeup_source *ws = from_timer(ws, t, timer);
unsigned long flags;

spin_lock_irqsave(&ws->lock, flags);
Expand Down

0 comments on commit 96428e9

Please sign in to comment.