aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2017-10-16 19:20:55 -0400
committerRafael J. Wysocki <rjw@rjwysocki.net>2017-10-24 04:27:42 -0400
commit96428e98aebe5db8a164711f102808651c7f518d (patch)
treed587150088277fb9e381747e88d940093617d4c8
parentb082ddd8a6a3aa0399763bfb58fc7bdd84c95713 (diff)
PM / core: Convert timers to use timer_setup()
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>
-rw-r--r--drivers/base/power/runtime.c7
-rw-r--r--drivers/base/power/wakeup.c11
2 files changed, 8 insertions, 10 deletions
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 7bcf80fa9ada..1cea431c0adf 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -894,9 +894,9 @@ static void pm_runtime_work(struct work_struct *work)
894 * 894 *
895 * Check if the time is right and queue a suspend request. 895 * Check if the time is right and queue a suspend request.
896 */ 896 */
897static void pm_suspend_timer_fn(unsigned long data) 897static void pm_suspend_timer_fn(struct timer_list *t)
898{ 898{
899 struct device *dev = (struct device *)data; 899 struct device *dev = from_timer(dev, t, power.suspend_timer);
900 unsigned long flags; 900 unsigned long flags;
901 unsigned long expires; 901 unsigned long expires;
902 902
@@ -1499,8 +1499,7 @@ void pm_runtime_init(struct device *dev)
1499 INIT_WORK(&dev->power.work, pm_runtime_work); 1499 INIT_WORK(&dev->power.work, pm_runtime_work);
1500 1500
1501 dev->power.timer_expires = 0; 1501 dev->power.timer_expires = 0;
1502 setup_timer(&dev->power.suspend_timer, pm_suspend_timer_fn, 1502 timer_setup(&dev->power.suspend_timer, pm_suspend_timer_fn, 0);
1503 (unsigned long)dev);
1504 1503
1505 init_waitqueue_head(&dev->power.wait_queue); 1504 init_waitqueue_head(&dev->power.wait_queue);
1506} 1505}
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index cdd6f256da59..680ee1d36ac9 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -54,7 +54,7 @@ static unsigned int saved_count;
54 54
55static DEFINE_SPINLOCK(events_lock); 55static DEFINE_SPINLOCK(events_lock);
56 56
57static void pm_wakeup_timer_fn(unsigned long data); 57static void pm_wakeup_timer_fn(struct timer_list *t);
58 58
59static LIST_HEAD(wakeup_sources); 59static LIST_HEAD(wakeup_sources);
60 60
@@ -176,7 +176,7 @@ void wakeup_source_add(struct wakeup_source *ws)
176 return; 176 return;
177 177
178 spin_lock_init(&ws->lock); 178 spin_lock_init(&ws->lock);
179 setup_timer(&ws->timer, pm_wakeup_timer_fn, (unsigned long)ws); 179 timer_setup(&ws->timer, pm_wakeup_timer_fn, 0);
180 ws->active = false; 180 ws->active = false;
181 ws->last_time = ktime_get(); 181 ws->last_time = ktime_get();
182 182
@@ -481,8 +481,7 @@ static bool wakeup_source_not_registered(struct wakeup_source *ws)
481 * Use timer struct to check if the given source is initialized 481 * Use timer struct to check if the given source is initialized
482 * by wakeup_source_add. 482 * by wakeup_source_add.
483 */ 483 */
484 return ws->timer.function != pm_wakeup_timer_fn || 484 return ws->timer.function != (TIMER_FUNC_TYPE)pm_wakeup_timer_fn;
485 ws->timer.data != (unsigned long)ws;
486} 485}
487 486
488/* 487/*
@@ -724,9 +723,9 @@ EXPORT_SYMBOL_GPL(pm_relax);
724 * in @data if it is currently active and its timer has not been canceled and 723 * in @data if it is currently active and its timer has not been canceled and
725 * the expiration time of the timer is not in future. 724 * the expiration time of the timer is not in future.
726 */ 725 */
727static void pm_wakeup_timer_fn(unsigned long data) 726static void pm_wakeup_timer_fn(struct timer_list *t)
728{ 727{
729 struct wakeup_source *ws = (struct wakeup_source *)data; 728 struct wakeup_source *ws = from_timer(ws, t, timer);
730 unsigned long flags; 729 unsigned long flags;
731 730
732 spin_lock_irqsave(&ws->lock, flags); 731 spin_lock_irqsave(&ws->lock, flags);