diff options
author | Kees Cook <keescook@chromium.org> | 2017-10-10 00:42:26 -0400 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2017-11-02 18:50:36 -0400 |
commit | a66b899dfbb51201e6ee176d77f27885dc362fc6 (patch) | |
tree | acb3333ccf280c8618b5f38cbf950e33582cd18b | |
parent | 96d130824f6f965418c2c36061842c354ab60178 (diff) |
mips: ip22/32: 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: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-mips@linux-mips.org
Signed-off-by: Kees Cook <keescook@chromium.org>
-rw-r--r-- | arch/mips/sgi-ip22/ip22-reset.c | 26 | ||||
-rw-r--r-- | arch/mips/sgi-ip32/ip32-reset.c | 21 |
2 files changed, 22 insertions, 25 deletions
diff --git a/arch/mips/sgi-ip22/ip22-reset.c b/arch/mips/sgi-ip22/ip22-reset.c index 03a39ac5ead9..c374f3ceec38 100644 --- a/arch/mips/sgi-ip22/ip22-reset.c +++ b/arch/mips/sgi-ip22/ip22-reset.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #define PANIC_FREQ (HZ / 8) | 38 | #define PANIC_FREQ (HZ / 8) |
39 | 39 | ||
40 | static struct timer_list power_timer, blink_timer, debounce_timer; | 40 | static struct timer_list power_timer, blink_timer, debounce_timer; |
41 | static unsigned long blink_timer_timeout; | ||
41 | 42 | ||
42 | #define MACHINE_PANICED 1 | 43 | #define MACHINE_PANICED 1 |
43 | #define MACHINE_SHUTTING_DOWN 2 | 44 | #define MACHINE_SHUTTING_DOWN 2 |
@@ -81,21 +82,21 @@ static void __noreturn sgi_machine_halt(void) | |||
81 | ArcEnterInteractiveMode(); | 82 | ArcEnterInteractiveMode(); |
82 | } | 83 | } |
83 | 84 | ||
84 | static void power_timeout(unsigned long data) | 85 | static void power_timeout(struct timer_list *unused) |
85 | { | 86 | { |
86 | sgi_machine_power_off(); | 87 | sgi_machine_power_off(); |
87 | } | 88 | } |
88 | 89 | ||
89 | static void blink_timeout(unsigned long data) | 90 | static void blink_timeout(struct timer_list *unused) |
90 | { | 91 | { |
91 | /* XXX fix this for fullhouse */ | 92 | /* XXX fix this for fullhouse */ |
92 | sgi_ioc_reset ^= (SGIOC_RESET_LC0OFF|SGIOC_RESET_LC1OFF); | 93 | sgi_ioc_reset ^= (SGIOC_RESET_LC0OFF|SGIOC_RESET_LC1OFF); |
93 | sgioc->reset = sgi_ioc_reset; | 94 | sgioc->reset = sgi_ioc_reset; |
94 | 95 | ||
95 | mod_timer(&blink_timer, jiffies + data); | 96 | mod_timer(&blink_timer, jiffies + blink_timer_timeout); |
96 | } | 97 | } |
97 | 98 | ||
98 | static void debounce(unsigned long data) | 99 | static void debounce(struct timer_list *unused) |
99 | { | 100 | { |
100 | del_timer(&debounce_timer); | 101 | del_timer(&debounce_timer); |
101 | if (sgint->istat1 & SGINT_ISTAT1_PWR) { | 102 | if (sgint->istat1 & SGINT_ISTAT1_PWR) { |
@@ -128,11 +129,10 @@ static inline void power_button(void) | |||
128 | } | 129 | } |
129 | 130 | ||
130 | machine_state |= MACHINE_SHUTTING_DOWN; | 131 | machine_state |= MACHINE_SHUTTING_DOWN; |
131 | blink_timer.data = POWERDOWN_FREQ; | 132 | blink_timer_timeout = POWERDOWN_FREQ; |
132 | blink_timeout(POWERDOWN_FREQ); | 133 | blink_timeout(&blink_timer); |
133 | 134 | ||
134 | init_timer(&power_timer); | 135 | timer_setup(&power_timer, power_timeout, 0); |
135 | power_timer.function = power_timeout; | ||
136 | power_timer.expires = jiffies + POWERDOWN_TIMEOUT * HZ; | 136 | power_timer.expires = jiffies + POWERDOWN_TIMEOUT * HZ; |
137 | add_timer(&power_timer); | 137 | add_timer(&power_timer); |
138 | } | 138 | } |
@@ -147,8 +147,7 @@ static irqreturn_t panel_int(int irq, void *dev_id) | |||
147 | if (sgint->istat1 & SGINT_ISTAT1_PWR) { | 147 | if (sgint->istat1 & SGINT_ISTAT1_PWR) { |
148 | /* Wait until interrupt goes away */ | 148 | /* Wait until interrupt goes away */ |
149 | disable_irq_nosync(SGI_PANEL_IRQ); | 149 | disable_irq_nosync(SGI_PANEL_IRQ); |
150 | init_timer(&debounce_timer); | 150 | timer_setup(&debounce_timer, debounce, 0); |
151 | debounce_timer.function = debounce; | ||
152 | debounce_timer.expires = jiffies + 5; | 151 | debounce_timer.expires = jiffies + 5; |
153 | add_timer(&debounce_timer); | 152 | add_timer(&debounce_timer); |
154 | } | 153 | } |
@@ -171,8 +170,8 @@ static int panic_event(struct notifier_block *this, unsigned long event, | |||
171 | return NOTIFY_DONE; | 170 | return NOTIFY_DONE; |
172 | machine_state |= MACHINE_PANICED; | 171 | machine_state |= MACHINE_PANICED; |
173 | 172 | ||
174 | blink_timer.data = PANIC_FREQ; | 173 | blink_timer_timeout = PANIC_FREQ; |
175 | blink_timeout(PANIC_FREQ); | 174 | blink_timeout(&blink_timer); |
176 | 175 | ||
177 | return NOTIFY_DONE; | 176 | return NOTIFY_DONE; |
178 | } | 177 | } |
@@ -195,8 +194,7 @@ static int __init reboot_setup(void) | |||
195 | return res; | 194 | return res; |
196 | } | 195 | } |
197 | 196 | ||
198 | init_timer(&blink_timer); | 197 | timer_setup(&blink_timer, blink_timeout, 0); |
199 | blink_timer.function = blink_timeout; | ||
200 | atomic_notifier_chain_register(&panic_notifier_list, &panic_block); | 198 | atomic_notifier_chain_register(&panic_notifier_list, &panic_block); |
201 | 199 | ||
202 | return 0; | 200 | return 0; |
diff --git a/arch/mips/sgi-ip32/ip32-reset.c b/arch/mips/sgi-ip32/ip32-reset.c index b3b442def423..20d8637340be 100644 --- a/arch/mips/sgi-ip32/ip32-reset.c +++ b/arch/mips/sgi-ip32/ip32-reset.c | |||
@@ -38,6 +38,7 @@ | |||
38 | extern struct platform_device ip32_rtc_device; | 38 | extern struct platform_device ip32_rtc_device; |
39 | 39 | ||
40 | static struct timer_list power_timer, blink_timer; | 40 | static struct timer_list power_timer, blink_timer; |
41 | static unsigned long blink_timer_timeout; | ||
41 | static int has_panicked, shutting_down; | 42 | static int has_panicked, shutting_down; |
42 | 43 | ||
43 | static __noreturn void ip32_poweroff(void *data) | 44 | static __noreturn void ip32_poweroff(void *data) |
@@ -71,11 +72,11 @@ static void ip32_machine_restart(char *cmd) | |||
71 | unreachable(); | 72 | unreachable(); |
72 | } | 73 | } |
73 | 74 | ||
74 | static void blink_timeout(unsigned long data) | 75 | static void blink_timeout(struct timer_list *unused) |
75 | { | 76 | { |
76 | unsigned long led = mace->perif.ctrl.misc ^ MACEISA_LED_RED; | 77 | unsigned long led = mace->perif.ctrl.misc ^ MACEISA_LED_RED; |
77 | mace->perif.ctrl.misc = led; | 78 | mace->perif.ctrl.misc = led; |
78 | mod_timer(&blink_timer, jiffies + data); | 79 | mod_timer(&blink_timer, jiffies + blink_timer_timeout); |
79 | } | 80 | } |
80 | 81 | ||
81 | static void ip32_machine_halt(void) | 82 | static void ip32_machine_halt(void) |
@@ -83,7 +84,7 @@ static void ip32_machine_halt(void) | |||
83 | ip32_poweroff(&ip32_rtc_device); | 84 | ip32_poweroff(&ip32_rtc_device); |
84 | } | 85 | } |
85 | 86 | ||
86 | static void power_timeout(unsigned long data) | 87 | static void power_timeout(struct timer_list *unused) |
87 | { | 88 | { |
88 | ip32_poweroff(&ip32_rtc_device); | 89 | ip32_poweroff(&ip32_rtc_device); |
89 | } | 90 | } |
@@ -99,11 +100,10 @@ void ip32_prepare_poweroff(void) | |||
99 | } | 100 | } |
100 | 101 | ||
101 | shutting_down = 1; | 102 | shutting_down = 1; |
102 | blink_timer.data = POWERDOWN_FREQ; | 103 | blink_timer_timeout = POWERDOWN_FREQ; |
103 | blink_timeout(POWERDOWN_FREQ); | 104 | blink_timeout(&blink_timer); |
104 | 105 | ||
105 | init_timer(&power_timer); | 106 | timer_setup(&power_timer, power_timeout, 0); |
106 | power_timer.function = power_timeout; | ||
107 | power_timer.expires = jiffies + POWERDOWN_TIMEOUT * HZ; | 107 | power_timer.expires = jiffies + POWERDOWN_TIMEOUT * HZ; |
108 | add_timer(&power_timer); | 108 | add_timer(&power_timer); |
109 | } | 109 | } |
@@ -121,8 +121,8 @@ static int panic_event(struct notifier_block *this, unsigned long event, | |||
121 | led = mace->perif.ctrl.misc | MACEISA_LED_GREEN; | 121 | led = mace->perif.ctrl.misc | MACEISA_LED_GREEN; |
122 | mace->perif.ctrl.misc = led; | 122 | mace->perif.ctrl.misc = led; |
123 | 123 | ||
124 | blink_timer.data = PANIC_FREQ; | 124 | blink_timer_timeout = PANIC_FREQ; |
125 | blink_timeout(PANIC_FREQ); | 125 | blink_timeout(&blink_timer); |
126 | 126 | ||
127 | return NOTIFY_DONE; | 127 | return NOTIFY_DONE; |
128 | } | 128 | } |
@@ -143,8 +143,7 @@ static __init int ip32_reboot_setup(void) | |||
143 | _machine_halt = ip32_machine_halt; | 143 | _machine_halt = ip32_machine_halt; |
144 | pm_power_off = ip32_machine_halt; | 144 | pm_power_off = ip32_machine_halt; |
145 | 145 | ||
146 | init_timer(&blink_timer); | 146 | timer_setup(&blink_timer, blink_timeout, 0); |
147 | blink_timer.function = blink_timeout; | ||
148 | atomic_notifier_chain_register(&panic_notifier_list, &panic_block); | 147 | atomic_notifier_chain_register(&panic_notifier_list, &panic_block); |
149 | 148 | ||
150 | return 0; | 149 | return 0; |