diff options
author | Kees Cook <keescook@chromium.org> | 2017-10-24 04:45:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-24 23:03:56 -0400 |
commit | 8dbd05ff5c4e50a3e5b1ed4089c2d0b4210379c6 (patch) | |
tree | add8add0f85ad0b91d5191d0a16f0367c526a372 | |
parent | 9c3b57518363577d4e2ea1964ef4fa03e100beaa (diff) |
net: ax25: 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.
Cc: Joerg Reuter <jreuter@yaina.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: linux-hams@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ax25/af_ax25.c | 7 | ||||
-rw-r--r-- | net/ax25/ax25_ds_timer.c | 9 | ||||
-rw-r--r-- | net/ax25/ax25_timer.c | 41 |
3 files changed, 27 insertions, 30 deletions
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index f3f9d18891de..06eac1f50c5e 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
@@ -268,9 +268,9 @@ void ax25_destroy_socket(ax25_cb *); | |||
268 | /* | 268 | /* |
269 | * Handler for deferred kills. | 269 | * Handler for deferred kills. |
270 | */ | 270 | */ |
271 | static void ax25_destroy_timer(unsigned long data) | 271 | static void ax25_destroy_timer(struct timer_list *t) |
272 | { | 272 | { |
273 | ax25_cb *ax25=(ax25_cb *)data; | 273 | ax25_cb *ax25 = from_timer(ax25, t, dtimer); |
274 | struct sock *sk; | 274 | struct sock *sk; |
275 | 275 | ||
276 | sk=ax25->sk; | 276 | sk=ax25->sk; |
@@ -326,8 +326,7 @@ void ax25_destroy_socket(ax25_cb *ax25) | |||
326 | if (ax25->sk != NULL) { | 326 | if (ax25->sk != NULL) { |
327 | if (sk_has_allocations(ax25->sk)) { | 327 | if (sk_has_allocations(ax25->sk)) { |
328 | /* Defer: outstanding buffers */ | 328 | /* Defer: outstanding buffers */ |
329 | setup_timer(&ax25->dtimer, ax25_destroy_timer, | 329 | timer_setup(&ax25->dtimer, ax25_destroy_timer, 0); |
330 | (unsigned long)ax25); | ||
331 | ax25->dtimer.expires = jiffies + 2 * HZ; | 330 | ax25->dtimer.expires = jiffies + 2 * HZ; |
332 | add_timer(&ax25->dtimer); | 331 | add_timer(&ax25->dtimer); |
333 | } else { | 332 | } else { |
diff --git a/net/ax25/ax25_ds_timer.c b/net/ax25/ax25_ds_timer.c index 5fb2104b7304..e9d11313d45b 100644 --- a/net/ax25/ax25_ds_timer.c +++ b/net/ax25/ax25_ds_timer.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | 31 | ||
32 | static void ax25_ds_timeout(unsigned long); | 32 | static void ax25_ds_timeout(struct timer_list *); |
33 | 33 | ||
34 | /* | 34 | /* |
35 | * Add DAMA slave timeout timer to timer list. | 35 | * Add DAMA slave timeout timer to timer list. |
@@ -41,8 +41,7 @@ static void ax25_ds_timeout(unsigned long); | |||
41 | 41 | ||
42 | void ax25_ds_setup_timer(ax25_dev *ax25_dev) | 42 | void ax25_ds_setup_timer(ax25_dev *ax25_dev) |
43 | { | 43 | { |
44 | setup_timer(&ax25_dev->dama.slave_timer, ax25_ds_timeout, | 44 | timer_setup(&ax25_dev->dama.slave_timer, ax25_ds_timeout, 0); |
45 | (unsigned long)ax25_dev); | ||
46 | } | 45 | } |
47 | 46 | ||
48 | void ax25_ds_del_timer(ax25_dev *ax25_dev) | 47 | void ax25_ds_del_timer(ax25_dev *ax25_dev) |
@@ -66,9 +65,9 @@ void ax25_ds_set_timer(ax25_dev *ax25_dev) | |||
66 | * Silently discard all (slave) connections in case our master forgot us... | 65 | * Silently discard all (slave) connections in case our master forgot us... |
67 | */ | 66 | */ |
68 | 67 | ||
69 | static void ax25_ds_timeout(unsigned long arg) | 68 | static void ax25_ds_timeout(struct timer_list *t) |
70 | { | 69 | { |
71 | ax25_dev *ax25_dev = (struct ax25_dev *) arg; | 70 | ax25_dev *ax25_dev = from_timer(ax25_dev, t, dama.slave_timer); |
72 | ax25_cb *ax25; | 71 | ax25_cb *ax25; |
73 | 72 | ||
74 | if (ax25_dev == NULL || !ax25_dev->dama.slave) | 73 | if (ax25_dev == NULL || !ax25_dev->dama.slave) |
diff --git a/net/ax25/ax25_timer.c b/net/ax25/ax25_timer.c index 23a6f38a80bf..c47b7ee1e4da 100644 --- a/net/ax25/ax25_timer.c +++ b/net/ax25/ax25_timer.c | |||
@@ -33,20 +33,19 @@ | |||
33 | #include <linux/mm.h> | 33 | #include <linux/mm.h> |
34 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
35 | 35 | ||
36 | static void ax25_heartbeat_expiry(unsigned long); | 36 | static void ax25_heartbeat_expiry(struct timer_list *); |
37 | static void ax25_t1timer_expiry(unsigned long); | 37 | static void ax25_t1timer_expiry(struct timer_list *); |
38 | static void ax25_t2timer_expiry(unsigned long); | 38 | static void ax25_t2timer_expiry(struct timer_list *); |
39 | static void ax25_t3timer_expiry(unsigned long); | 39 | static void ax25_t3timer_expiry(struct timer_list *); |
40 | static void ax25_idletimer_expiry(unsigned long); | 40 | static void ax25_idletimer_expiry(struct timer_list *); |
41 | 41 | ||
42 | void ax25_setup_timers(ax25_cb *ax25) | 42 | void ax25_setup_timers(ax25_cb *ax25) |
43 | { | 43 | { |
44 | setup_timer(&ax25->timer, ax25_heartbeat_expiry, (unsigned long)ax25); | 44 | timer_setup(&ax25->timer, ax25_heartbeat_expiry, 0); |
45 | setup_timer(&ax25->t1timer, ax25_t1timer_expiry, (unsigned long)ax25); | 45 | timer_setup(&ax25->t1timer, ax25_t1timer_expiry, 0); |
46 | setup_timer(&ax25->t2timer, ax25_t2timer_expiry, (unsigned long)ax25); | 46 | timer_setup(&ax25->t2timer, ax25_t2timer_expiry, 0); |
47 | setup_timer(&ax25->t3timer, ax25_t3timer_expiry, (unsigned long)ax25); | 47 | timer_setup(&ax25->t3timer, ax25_t3timer_expiry, 0); |
48 | setup_timer(&ax25->idletimer, ax25_idletimer_expiry, | 48 | timer_setup(&ax25->idletimer, ax25_idletimer_expiry, 0); |
49 | (unsigned long)ax25); | ||
50 | } | 49 | } |
51 | 50 | ||
52 | void ax25_start_heartbeat(ax25_cb *ax25) | 51 | void ax25_start_heartbeat(ax25_cb *ax25) |
@@ -120,10 +119,10 @@ unsigned long ax25_display_timer(struct timer_list *timer) | |||
120 | 119 | ||
121 | EXPORT_SYMBOL(ax25_display_timer); | 120 | EXPORT_SYMBOL(ax25_display_timer); |
122 | 121 | ||
123 | static void ax25_heartbeat_expiry(unsigned long param) | 122 | static void ax25_heartbeat_expiry(struct timer_list *t) |
124 | { | 123 | { |
125 | int proto = AX25_PROTO_STD_SIMPLEX; | 124 | int proto = AX25_PROTO_STD_SIMPLEX; |
126 | ax25_cb *ax25 = (ax25_cb *)param; | 125 | ax25_cb *ax25 = from_timer(ax25, t, timer); |
127 | 126 | ||
128 | if (ax25->ax25_dev) | 127 | if (ax25->ax25_dev) |
129 | proto = ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]; | 128 | proto = ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]; |
@@ -145,9 +144,9 @@ static void ax25_heartbeat_expiry(unsigned long param) | |||
145 | } | 144 | } |
146 | } | 145 | } |
147 | 146 | ||
148 | static void ax25_t1timer_expiry(unsigned long param) | 147 | static void ax25_t1timer_expiry(struct timer_list *t) |
149 | { | 148 | { |
150 | ax25_cb *ax25 = (ax25_cb *)param; | 149 | ax25_cb *ax25 = from_timer(ax25, t, t1timer); |
151 | 150 | ||
152 | switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { | 151 | switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { |
153 | case AX25_PROTO_STD_SIMPLEX: | 152 | case AX25_PROTO_STD_SIMPLEX: |
@@ -164,9 +163,9 @@ static void ax25_t1timer_expiry(unsigned long param) | |||
164 | } | 163 | } |
165 | } | 164 | } |
166 | 165 | ||
167 | static void ax25_t2timer_expiry(unsigned long param) | 166 | static void ax25_t2timer_expiry(struct timer_list *t) |
168 | { | 167 | { |
169 | ax25_cb *ax25 = (ax25_cb *)param; | 168 | ax25_cb *ax25 = from_timer(ax25, t, t2timer); |
170 | 169 | ||
171 | switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { | 170 | switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { |
172 | case AX25_PROTO_STD_SIMPLEX: | 171 | case AX25_PROTO_STD_SIMPLEX: |
@@ -183,9 +182,9 @@ static void ax25_t2timer_expiry(unsigned long param) | |||
183 | } | 182 | } |
184 | } | 183 | } |
185 | 184 | ||
186 | static void ax25_t3timer_expiry(unsigned long param) | 185 | static void ax25_t3timer_expiry(struct timer_list *t) |
187 | { | 186 | { |
188 | ax25_cb *ax25 = (ax25_cb *)param; | 187 | ax25_cb *ax25 = from_timer(ax25, t, t3timer); |
189 | 188 | ||
190 | switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { | 189 | switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { |
191 | case AX25_PROTO_STD_SIMPLEX: | 190 | case AX25_PROTO_STD_SIMPLEX: |
@@ -204,9 +203,9 @@ static void ax25_t3timer_expiry(unsigned long param) | |||
204 | } | 203 | } |
205 | } | 204 | } |
206 | 205 | ||
207 | static void ax25_idletimer_expiry(unsigned long param) | 206 | static void ax25_idletimer_expiry(struct timer_list *t) |
208 | { | 207 | { |
209 | ax25_cb *ax25 = (ax25_cb *)param; | 208 | ax25_cb *ax25 = from_timer(ax25, t, idletimer); |
210 | 209 | ||
211 | switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { | 210 | switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { |
212 | case AX25_PROTO_STD_SIMPLEX: | 211 | case AX25_PROTO_STD_SIMPLEX: |