[PATCH 03/13] timer: Remove init_timer_on_stack() in favor of timer_setup_on_stack()

Rafael J. Wysocki rafael at kernel.org
Fri Oct 6 00:18:32 AEDT 2017


On Thu, Oct 5, 2017 at 1:26 AM, Kees Cook <keescook at chromium.org> wrote:
> Remove uses of init_timer_on_stack() with open-coded function and data
> assignments that could be expressed using timer_setup_on_stack(). Several
> were removed from the stack entirely since there was a one-to-one mapping
> of parent structure to timer, those are switched to using timer_setup()
> instead. All related callbacks were adjusted to use from_timer().
>
> Cc: "Rafael J. Wysocki" <rjw at rjwysocki.net>
> Cc: Pavel Machek <pavel at ucw.cz>
> Cc: Len Brown <len.brown at intel.com>
> Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
> Cc: Stefan Richter <stefanr at s5r6.in-berlin.de>
> Cc: Sudip Mukherjee <sudipm.mukherjee at gmail.com>
> Cc: Martin Schwidefsky <schwidefsky at de.ibm.com>
> Cc: Heiko Carstens <heiko.carstens at de.ibm.com>
> Cc: Julian Wiedmann <jwi at linux.vnet.ibm.com>
> Cc: Ursula Braun <ubraun at linux.vnet.ibm.com>
> Cc: Michael Reed <mdr at sgi.com>
> Cc: "James E.J. Bottomley" <jejb at linux.vnet.ibm.com>
> Cc: "Martin K. Petersen" <martin.petersen at oracle.com>
> Cc: Thomas Gleixner <tglx at linutronix.de>
> Cc: linux-pm at vger.kernel.org
> Cc: linux1394-devel at lists.sourceforge.net
> Cc: linux-s390 at vger.kernel.org
> Cc: linux-scsi at vger.kernel.org
> Signed-off-by: Kees Cook <keescook at chromium.org>
> ---
>  drivers/base/power/main.c           |  8 +++-----
>  drivers/firewire/core-transaction.c | 10 +++++-----
>  drivers/parport/ieee1284.c          | 21 +++++++--------------
>  drivers/s390/char/tape.h            |  1 +
>  drivers/s390/char/tape_std.c        | 18 ++++++------------
>  drivers/s390/net/lcs.c              | 16 ++++++----------
>  drivers/s390/net/lcs.h              |  1 +
>  drivers/scsi/qla1280.c              | 14 +++++---------
>  drivers/scsi/qla1280.h              |  1 +
>  include/linux/parport.h             |  1 +
>  include/linux/timer.h               |  2 --
>  11 files changed, 36 insertions(+), 57 deletions(-)
>
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index 770b1539a083..ae47b2ec84b4 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -478,9 +478,9 @@ struct dpm_watchdog {
>   * There's not much we can do here to recover so panic() to
>   * capture a crash-dump in pstore.
>   */
> -static void dpm_watchdog_handler(unsigned long data)
> +static void dpm_watchdog_handler(struct timer_list *t)
>  {
> -       struct dpm_watchdog *wd = (void *)data;
> +       struct dpm_watchdog *wd = from_timer(wd, t, timer);
>
>         dev_emerg(wd->dev, "**** DPM device timeout ****\n");
>         show_stack(wd->tsk, NULL);
> @@ -500,11 +500,9 @@ static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)
>         wd->dev = dev;
>         wd->tsk = current;
>
> -       init_timer_on_stack(timer);
> +       timer_setup_on_stack(timer, dpm_watchdog_handler, 0);
>         /* use same timeout value for both suspend and resume */
>         timer->expires = jiffies + HZ * CONFIG_DPM_WATCHDOG_TIMEOUT;
> -       timer->function = dpm_watchdog_handler;
> -       timer->data = (unsigned long)wd;
>         add_timer(timer);
>  }

For the above:

Acked-by: Rafael J. Wysocki <rafael.j.wysocki at intel.com>


More information about the Linuxppc-dev mailing list