* [PATCH] PM: Convert timers to use timer_setup()
@ 2017-10-16 23:20 Kees Cook
2017-10-16 23:53 ` Rafael J. Wysocki
0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2017-10-16 23:20 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Rafael J. Wysocki, Pavel Machek, Len Brown, Greg Kroah-Hartman,
linux-pm, linux-kernel
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.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Len Brown <len.brown@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/base/power/runtime.c | 7 +++----
drivers/base/power/wakeup.c | 11 +++++------
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)
*
* 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;
@@ -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);
}
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;
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);
@@ -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();
@@ -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;
}
/*
@@ -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);
--
2.7.4
--
Kees Cook
Pixel Security
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] PM: Convert timers to use timer_setup()
2017-10-16 23:20 [PATCH] PM: Convert timers to use timer_setup() Kees Cook
@ 2017-10-16 23:53 ` Rafael J. Wysocki
2017-10-17 0:19 ` Kees Cook
0 siblings, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2017-10-16 23:53 UTC (permalink / raw)
To: Kees Cook
Cc: Rafael J. Wysocki, Pavel Machek, Len Brown, Greg Kroah-Hartman,
linux-pm, linux-kernel
On 10/17/2017 1:20 AM, Kees Cook wrote:
> 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.
>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/base/power/runtime.c | 7 +++----
> drivers/base/power/wakeup.c | 11 +++++------
> 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)
> *
> * 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;
>
> @@ -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);
> }
> 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;
>
> 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);
>
> @@ -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();
>
> @@ -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;
> }
>
> /*
> @@ -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);
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] PM: Convert timers to use timer_setup()
2017-10-16 23:53 ` Rafael J. Wysocki
@ 2017-10-17 0:19 ` Kees Cook
2017-10-17 0:15 ` Rafael J. Wysocki
0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2017-10-17 0:19 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Rafael J. Wysocki, Pavel Machek, Len Brown, Greg Kroah-Hartman,
Linux PM list, LKML
On Mon, Oct 16, 2017 at 4:53 PM, Rafael J. Wysocki
<rafael.j.wysocki@intel.com> wrote:
> On 10/17/2017 1:20 AM, Kees Cook wrote:
>>
>> 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.
>>
>> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
>> Cc: Pavel Machek <pavel@ucw.cz>
>> Cc: Len Brown <len.brown@intel.com>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: linux-pm@vger.kernel.org
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>
>
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Do you want this to be carried in the timers tree, or can you pick it up?
Thanks!
-Kees
--
Kees Cook
Pixel Security
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PM: Convert timers to use timer_setup()
2017-10-17 0:19 ` Kees Cook
@ 2017-10-17 0:15 ` Rafael J. Wysocki
2017-10-17 0:30 ` Kees Cook
0 siblings, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2017-10-17 0:15 UTC (permalink / raw)
To: Kees Cook
Cc: Rafael J. Wysocki, Pavel Machek, Len Brown, Greg Kroah-Hartman,
Linux PM list, LKML
On Tuesday, October 17, 2017 2:19:48 AM CEST Kees Cook wrote:
> On Mon, Oct 16, 2017 at 4:53 PM, Rafael J. Wysocki
> <rafael.j.wysocki@intel.com> wrote:
> > On 10/17/2017 1:20 AM, Kees Cook wrote:
> >>
> >> 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.
> >>
> >> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> >> Cc: Pavel Machek <pavel@ucw.cz>
> >> Cc: Len Brown <len.brown@intel.com>
> >> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >> Cc: linux-pm@vger.kernel.org
> >> Signed-off-by: Kees Cook <keescook@chromium.org>
> >
> >
> > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Do you want this to be carried in the timers tree, or can you pick it up?
I can pick it up, but only for 4.15.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PM: Convert timers to use timer_setup()
2017-10-17 0:15 ` Rafael J. Wysocki
@ 2017-10-17 0:30 ` Kees Cook
0 siblings, 0 replies; 5+ messages in thread
From: Kees Cook @ 2017-10-17 0:30 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Rafael J. Wysocki, Pavel Machek, Len Brown, Greg Kroah-Hartman,
Linux PM list, LKML
On Mon, Oct 16, 2017 at 5:15 PM, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> On Tuesday, October 17, 2017 2:19:48 AM CEST Kees Cook wrote:
>> On Mon, Oct 16, 2017 at 4:53 PM, Rafael J. Wysocki
>> <rafael.j.wysocki@intel.com> wrote:
>> > On 10/17/2017 1:20 AM, Kees Cook wrote:
>> >>
>> >> 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.
>> >>
>> >> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
>> >> Cc: Pavel Machek <pavel@ucw.cz>
>> >> Cc: Len Brown <len.brown@intel.com>
>> >> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> >> Cc: linux-pm@vger.kernel.org
>> >> Signed-off-by: Kees Cook <keescook@chromium.org>
>> >
>> >
>> > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>
>> Do you want this to be carried in the timers tree, or can you pick it up?
>
> I can pick it up, but only for 4.15.
Yup, this is based on -next. Thanks!
-Kees
--
Kees Cook
Pixel Security
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-10-17 0:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-16 23:20 [PATCH] PM: Convert timers to use timer_setup() Kees Cook
2017-10-16 23:53 ` Rafael J. Wysocki
2017-10-17 0:19 ` Kees Cook
2017-10-17 0:15 ` Rafael J. Wysocki
2017-10-17 0:30 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).