Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sparc/led: 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. Adds a static variable to hold timeout
value.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Geliang Tang <geliangtang@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Kees Cook and committed by
David S. Miller
68fa10dc a16036e9

+9 -7
+9 -7
arch/sparc/kernel/led.c
··· 31 31 } 32 32 33 33 static struct timer_list led_blink_timer; 34 + static unsigned long led_blink_timer_timeout; 34 35 35 - static void led_blink(unsigned long timeout) 36 + static void led_blink(struct timer_list *unused) 36 37 { 38 + unsigned long timeout = led_blink_timer_timeout; 39 + 37 40 led_toggle(); 38 41 39 42 /* reschedule */ 40 43 if (!timeout) { /* blink according to load */ 41 44 led_blink_timer.expires = jiffies + 42 45 ((1 + (avenrun[0] >> FSHIFT)) * HZ); 43 - led_blink_timer.data = 0; 44 46 } else { /* blink at user specified interval */ 45 47 led_blink_timer.expires = jiffies + (timeout * HZ); 46 - led_blink_timer.data = timeout; 47 48 } 48 49 add_timer(&led_blink_timer); 49 50 } ··· 89 88 } else if (!strcmp(buf, "toggle")) { 90 89 led_toggle(); 91 90 } else if ((*buf > '0') && (*buf <= '9')) { 92 - led_blink(simple_strtoul(buf, NULL, 10)); 91 + led_blink_timer_timeout = simple_strtoul(buf, NULL, 10); 92 + led_blink(&led_blink_timer); 93 93 } else if (!strcmp(buf, "load")) { 94 - led_blink(0); 94 + led_blink_timer_timeout = 0; 95 + led_blink(&led_blink_timer); 95 96 } else { 96 97 auxio_set_led(AUXIO_LED_OFF); 97 98 } ··· 118 115 119 116 static int __init led_init(void) 120 117 { 121 - init_timer(&led_blink_timer); 122 - led_blink_timer.function = led_blink; 118 + timer_setup(&led_blink_timer, led_blink, 0); 123 119 124 120 led = proc_create("led", 0, NULL, &led_proc_fops); 125 121 if (!led)