diff options
Diffstat (limited to 'drivers/net/wimax/i2400m/usb-rx.c')
-rw-r--r-- | drivers/net/wimax/i2400m/usb-rx.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/drivers/net/wimax/i2400m/usb-rx.c b/drivers/net/wimax/i2400m/usb-rx.c index e494e3774ec0..245587feb8c8 100644 --- a/drivers/net/wimax/i2400m/usb-rx.c +++ b/drivers/net/wimax/i2400m/usb-rx.c | |||
@@ -316,10 +316,15 @@ int i2400mu_rxd(void *_i2400mu) | |||
316 | size_t pending; | 316 | size_t pending; |
317 | int rx_size; | 317 | int rx_size; |
318 | struct sk_buff *rx_skb; | 318 | struct sk_buff *rx_skb; |
319 | unsigned long flags; | ||
319 | 320 | ||
320 | d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu); | 321 | d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu); |
322 | spin_lock_irqsave(&i2400m->rx_lock, flags); | ||
323 | BUG_ON(i2400mu->rx_kthread != NULL); | ||
324 | i2400mu->rx_kthread = current; | ||
325 | spin_unlock_irqrestore(&i2400m->rx_lock, flags); | ||
321 | while (1) { | 326 | while (1) { |
322 | d_printf(2, dev, "TX: waiting for messages\n"); | 327 | d_printf(2, dev, "RX: waiting for messages\n"); |
323 | pending = 0; | 328 | pending = 0; |
324 | wait_event_interruptible( | 329 | wait_event_interruptible( |
325 | i2400mu->rx_wq, | 330 | i2400mu->rx_wq, |
@@ -367,6 +372,9 @@ int i2400mu_rxd(void *_i2400mu) | |||
367 | } | 372 | } |
368 | result = 0; | 373 | result = 0; |
369 | out: | 374 | out: |
375 | spin_lock_irqsave(&i2400m->rx_lock, flags); | ||
376 | i2400mu->rx_kthread = NULL; | ||
377 | spin_unlock_irqrestore(&i2400m->rx_lock, flags); | ||
370 | d_fnend(4, dev, "(i2400mu %p) = %d\n", i2400mu, result); | 378 | d_fnend(4, dev, "(i2400mu %p) = %d\n", i2400mu, result); |
371 | return result; | 379 | return result; |
372 | 380 | ||
@@ -403,18 +411,33 @@ int i2400mu_rx_setup(struct i2400mu *i2400mu) | |||
403 | struct i2400m *i2400m = &i2400mu->i2400m; | 411 | struct i2400m *i2400m = &i2400mu->i2400m; |
404 | struct device *dev = &i2400mu->usb_iface->dev; | 412 | struct device *dev = &i2400mu->usb_iface->dev; |
405 | struct wimax_dev *wimax_dev = &i2400m->wimax_dev; | 413 | struct wimax_dev *wimax_dev = &i2400m->wimax_dev; |
414 | struct task_struct *kthread; | ||
406 | 415 | ||
407 | i2400mu->rx_kthread = kthread_run(i2400mu_rxd, i2400mu, "%s-rx", | 416 | kthread = kthread_run(i2400mu_rxd, i2400mu, "%s-rx", |
408 | wimax_dev->name); | 417 | wimax_dev->name); |
409 | if (IS_ERR(i2400mu->rx_kthread)) { | 418 | /* the kthread function sets i2400mu->rx_thread */ |
410 | result = PTR_ERR(i2400mu->rx_kthread); | 419 | if (IS_ERR(kthread)) { |
420 | result = PTR_ERR(kthread); | ||
411 | dev_err(dev, "RX: cannot start thread: %d\n", result); | 421 | dev_err(dev, "RX: cannot start thread: %d\n", result); |
412 | } | 422 | } |
413 | return result; | 423 | return result; |
414 | } | 424 | } |
415 | 425 | ||
426 | |||
416 | void i2400mu_rx_release(struct i2400mu *i2400mu) | 427 | void i2400mu_rx_release(struct i2400mu *i2400mu) |
417 | { | 428 | { |
418 | kthread_stop(i2400mu->rx_kthread); | 429 | unsigned long flags; |
430 | struct i2400m *i2400m = &i2400mu->i2400m; | ||
431 | struct device *dev = i2400m_dev(i2400m); | ||
432 | struct task_struct *kthread; | ||
433 | |||
434 | spin_lock_irqsave(&i2400m->rx_lock, flags); | ||
435 | kthread = i2400mu->rx_kthread; | ||
436 | i2400mu->rx_kthread = NULL; | ||
437 | spin_unlock_irqrestore(&i2400m->rx_lock, flags); | ||
438 | if (kthread) | ||
439 | kthread_stop(kthread); | ||
440 | else | ||
441 | d_printf(1, dev, "RX: kthread had already exited\n"); | ||
419 | } | 442 | } |
420 | 443 | ||