auxdisplay: Convert timers to use timer_setup()
authorKees Cook <keescook@chromium.org>
Wed, 25 Oct 2017 10:22:57 +0000 (03:22 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 4 Nov 2017 11:03:13 +0000 (12:03 +0100)
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.

Cc: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Paul Burton <paul.burton@mips.com>
Tested-by: Paul Burton <paul.burton@mips.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/auxdisplay/img-ascii-lcd.c
drivers/auxdisplay/panel.c

index 25306fa2725101e714b5344d4af084e3de7f6ce3..c9e32d29ec815b88649423043702676e2ba83b23 100644 (file)
@@ -229,9 +229,9 @@ MODULE_DEVICE_TABLE(of, img_ascii_lcd_matches);
  * Scroll the current message along the LCD by one character, rearming the
  * timer if required.
  */
-static void img_ascii_lcd_scroll(unsigned long arg)
+static void img_ascii_lcd_scroll(struct timer_list *t)
 {
-       struct img_ascii_lcd_ctx *ctx = (struct img_ascii_lcd_ctx *)arg;
+       struct img_ascii_lcd_ctx *ctx = from_timer(ctx, t, timer);
        unsigned int i, ch = ctx->scroll_pos;
        unsigned int num_chars = ctx->cfg->num_chars;
 
@@ -299,7 +299,7 @@ static int img_ascii_lcd_display(struct img_ascii_lcd_ctx *ctx,
        ctx->scroll_pos = 0;
 
        /* update the LCD */
-       img_ascii_lcd_scroll((unsigned long)ctx);
+       img_ascii_lcd_scroll(&ctx->timer);
 
        return 0;
 }
@@ -395,9 +395,7 @@ static int img_ascii_lcd_probe(struct platform_device *pdev)
        ctx->scroll_rate = HZ / 2;
 
        /* initialise a timer for scrolling the message */
-       init_timer(&ctx->timer);
-       ctx->timer.function = img_ascii_lcd_scroll;
-       ctx->timer.data = (unsigned long)ctx;
+       timer_setup(&ctx->timer, img_ascii_lcd_scroll, 0);
 
        platform_set_drvdata(pdev, ctx);
 
index 6911acd896d935946b3c805d07c88bc03bf41918..ea7869c0d7f9f638ffb33f61d7b2b7437cd3bf41 100644 (file)
@@ -1396,7 +1396,7 @@ static void panel_process_inputs(void)
        }
 }
 
-static void panel_scan_timer(void)
+static void panel_scan_timer(struct timer_list *unused)
 {
        if (keypad.enabled && keypad_initialized) {
                if (spin_trylock_irq(&pprt_lock)) {
@@ -1421,7 +1421,7 @@ static void init_scan_timer(void)
        if (scan_timer.function)
                return;         /* already started */
 
-       setup_timer(&scan_timer, (void *)&panel_scan_timer, 0);
+       timer_setup(&scan_timer, panel_scan_timer, 0);
        scan_timer.expires = jiffies + INPUT_POLL_TIME;
        add_timer(&scan_timer);
 }