diff options
Diffstat (limited to 'drivers/uwb/neh.c')
-rw-r--r-- | drivers/uwb/neh.c | 72 |
1 files changed, 33 insertions, 39 deletions
diff --git a/drivers/uwb/neh.c b/drivers/uwb/neh.c index 9b4eb64327ac..0af8916d9bef 100644 --- a/drivers/uwb/neh.c +++ b/drivers/uwb/neh.c | |||
@@ -86,8 +86,6 @@ | |||
86 | #include <linux/err.h> | 86 | #include <linux/err.h> |
87 | 87 | ||
88 | #include "uwb-internal.h" | 88 | #include "uwb-internal.h" |
89 | #define D_LOCAL 0 | ||
90 | #include <linux/uwb/debug.h> | ||
91 | 89 | ||
92 | /* | 90 | /* |
93 | * UWB Radio Controller Notification/Event Handle | 91 | * UWB Radio Controller Notification/Event Handle |
@@ -254,7 +252,6 @@ error_kzalloc: | |||
254 | 252 | ||
255 | static void __uwb_rc_neh_rm(struct uwb_rc *rc, struct uwb_rc_neh *neh) | 253 | static void __uwb_rc_neh_rm(struct uwb_rc *rc, struct uwb_rc_neh *neh) |
256 | { | 254 | { |
257 | del_timer(&neh->timer); | ||
258 | __uwb_rc_ctx_put(rc, neh); | 255 | __uwb_rc_ctx_put(rc, neh); |
259 | list_del(&neh->list_node); | 256 | list_del(&neh->list_node); |
260 | } | 257 | } |
@@ -275,6 +272,7 @@ void uwb_rc_neh_rm(struct uwb_rc *rc, struct uwb_rc_neh *neh) | |||
275 | __uwb_rc_neh_rm(rc, neh); | 272 | __uwb_rc_neh_rm(rc, neh); |
276 | spin_unlock_irqrestore(&rc->neh_lock, flags); | 273 | spin_unlock_irqrestore(&rc->neh_lock, flags); |
277 | 274 | ||
275 | del_timer_sync(&neh->timer); | ||
278 | uwb_rc_neh_put(neh); | 276 | uwb_rc_neh_put(neh); |
279 | } | 277 | } |
280 | 278 | ||
@@ -349,7 +347,7 @@ struct uwb_rc_neh *uwb_rc_neh_lookup(struct uwb_rc *rc, | |||
349 | } | 347 | } |
350 | 348 | ||
351 | 349 | ||
352 | /** | 350 | /* |
353 | * Process notifications coming from the radio control interface | 351 | * Process notifications coming from the radio control interface |
354 | * | 352 | * |
355 | * @rc: UWB Radio Control Interface descriptor | 353 | * @rc: UWB Radio Control Interface descriptor |
@@ -401,23 +399,6 @@ void uwb_rc_notif(struct uwb_rc *rc, struct uwb_rceb *rceb, ssize_t size) | |||
401 | uwb_evt->notif.size = size; | 399 | uwb_evt->notif.size = size; |
402 | uwb_evt->notif.rceb = rceb; | 400 | uwb_evt->notif.rceb = rceb; |
403 | 401 | ||
404 | switch (le16_to_cpu(rceb->wEvent)) { | ||
405 | /* Trap some vendor specific events | ||
406 | * | ||
407 | * FIXME: move this to handling in ptc-est, where we | ||
408 | * register a NULL event handler for these two guys | ||
409 | * using the Intel IDs. | ||
410 | */ | ||
411 | case 0x0103: | ||
412 | dev_info(dev, "FIXME: DEVICE ADD\n"); | ||
413 | return; | ||
414 | case 0x0104: | ||
415 | dev_info(dev, "FIXME: DEVICE RM\n"); | ||
416 | return; | ||
417 | default: | ||
418 | break; | ||
419 | } | ||
420 | |||
421 | uwbd_event_queue(uwb_evt); | 402 | uwbd_event_queue(uwb_evt); |
422 | } | 403 | } |
423 | 404 | ||
@@ -438,9 +419,10 @@ static void uwb_rc_neh_grok_event(struct uwb_rc *rc, struct uwb_rceb *rceb, size | |||
438 | rceb->bEventContext, size); | 419 | rceb->bEventContext, size); |
439 | } else { | 420 | } else { |
440 | neh = uwb_rc_neh_lookup(rc, rceb); | 421 | neh = uwb_rc_neh_lookup(rc, rceb); |
441 | if (neh) | 422 | if (neh) { |
423 | del_timer_sync(&neh->timer); | ||
442 | uwb_rc_neh_cb(neh, rceb, size); | 424 | uwb_rc_neh_cb(neh, rceb, size); |
443 | else | 425 | } else |
444 | dev_warn(dev, "event 0x%02x/%04x/%02x (%zu bytes): nobody cared\n", | 426 | dev_warn(dev, "event 0x%02x/%04x/%02x (%zu bytes): nobody cared\n", |
445 | rceb->bEventType, le16_to_cpu(rceb->wEvent), | 427 | rceb->bEventType, le16_to_cpu(rceb->wEvent), |
446 | rceb->bEventContext, size); | 428 | rceb->bEventContext, size); |
@@ -495,8 +477,6 @@ void uwb_rc_neh_grok(struct uwb_rc *rc, void *buf, size_t buf_size) | |||
495 | size_t size, real_size, event_size; | 477 | size_t size, real_size, event_size; |
496 | int needtofree; | 478 | int needtofree; |
497 | 479 | ||
498 | d_fnstart(3, dev, "(rc %p buf %p %zu buf_size)\n", rc, buf, buf_size); | ||
499 | d_printf(2, dev, "groking event block: %zu bytes\n", buf_size); | ||
500 | itr = buf; | 480 | itr = buf; |
501 | size = buf_size; | 481 | size = buf_size; |
502 | while (size > 0) { | 482 | while (size > 0) { |
@@ -544,10 +524,7 @@ void uwb_rc_neh_grok(struct uwb_rc *rc, void *buf, size_t buf_size) | |||
544 | 524 | ||
545 | itr += real_size; | 525 | itr += real_size; |
546 | size -= real_size; | 526 | size -= real_size; |
547 | d_printf(2, dev, "consumed %zd bytes, %zu left\n", | ||
548 | event_size, size); | ||
549 | } | 527 | } |
550 | d_fnend(3, dev, "(rc %p buf %p %zu buf_size) = void\n", rc, buf, buf_size); | ||
551 | } | 528 | } |
552 | EXPORT_SYMBOL_GPL(uwb_rc_neh_grok); | 529 | EXPORT_SYMBOL_GPL(uwb_rc_neh_grok); |
553 | 530 | ||
@@ -562,16 +539,22 @@ EXPORT_SYMBOL_GPL(uwb_rc_neh_grok); | |||
562 | */ | 539 | */ |
563 | void uwb_rc_neh_error(struct uwb_rc *rc, int error) | 540 | void uwb_rc_neh_error(struct uwb_rc *rc, int error) |
564 | { | 541 | { |
565 | struct uwb_rc_neh *neh, *next; | 542 | struct uwb_rc_neh *neh; |
566 | unsigned long flags; | 543 | unsigned long flags; |
567 | 544 | ||
568 | BUG_ON(error >= 0); | 545 | for (;;) { |
569 | spin_lock_irqsave(&rc->neh_lock, flags); | 546 | spin_lock_irqsave(&rc->neh_lock, flags); |
570 | list_for_each_entry_safe(neh, next, &rc->neh_list, list_node) { | 547 | if (list_empty(&rc->neh_list)) { |
548 | spin_unlock_irqrestore(&rc->neh_lock, flags); | ||
549 | break; | ||
550 | } | ||
551 | neh = list_first_entry(&rc->neh_list, struct uwb_rc_neh, list_node); | ||
571 | __uwb_rc_neh_rm(rc, neh); | 552 | __uwb_rc_neh_rm(rc, neh); |
553 | spin_unlock_irqrestore(&rc->neh_lock, flags); | ||
554 | |||
555 | del_timer_sync(&neh->timer); | ||
572 | uwb_rc_neh_cb(neh, NULL, error); | 556 | uwb_rc_neh_cb(neh, NULL, error); |
573 | } | 557 | } |
574 | spin_unlock_irqrestore(&rc->neh_lock, flags); | ||
575 | } | 558 | } |
576 | EXPORT_SYMBOL_GPL(uwb_rc_neh_error); | 559 | EXPORT_SYMBOL_GPL(uwb_rc_neh_error); |
577 | 560 | ||
@@ -583,10 +566,14 @@ static void uwb_rc_neh_timer(unsigned long arg) | |||
583 | unsigned long flags; | 566 | unsigned long flags; |
584 | 567 | ||
585 | spin_lock_irqsave(&rc->neh_lock, flags); | 568 | spin_lock_irqsave(&rc->neh_lock, flags); |
586 | __uwb_rc_neh_rm(rc, neh); | 569 | if (neh->context) |
570 | __uwb_rc_neh_rm(rc, neh); | ||
571 | else | ||
572 | neh = NULL; | ||
587 | spin_unlock_irqrestore(&rc->neh_lock, flags); | 573 | spin_unlock_irqrestore(&rc->neh_lock, flags); |
588 | 574 | ||
589 | uwb_rc_neh_cb(neh, NULL, -ETIMEDOUT); | 575 | if (neh) |
576 | uwb_rc_neh_cb(neh, NULL, -ETIMEDOUT); | ||
590 | } | 577 | } |
591 | 578 | ||
592 | /** Initializes the @rc's neh subsystem | 579 | /** Initializes the @rc's neh subsystem |
@@ -605,12 +592,19 @@ void uwb_rc_neh_create(struct uwb_rc *rc) | |||
605 | void uwb_rc_neh_destroy(struct uwb_rc *rc) | 592 | void uwb_rc_neh_destroy(struct uwb_rc *rc) |
606 | { | 593 | { |
607 | unsigned long flags; | 594 | unsigned long flags; |
608 | struct uwb_rc_neh *neh, *next; | 595 | struct uwb_rc_neh *neh; |
609 | 596 | ||
610 | spin_lock_irqsave(&rc->neh_lock, flags); | 597 | for (;;) { |
611 | list_for_each_entry_safe(neh, next, &rc->neh_list, list_node) { | 598 | spin_lock_irqsave(&rc->neh_lock, flags); |
599 | if (list_empty(&rc->neh_list)) { | ||
600 | spin_unlock_irqrestore(&rc->neh_lock, flags); | ||
601 | break; | ||
602 | } | ||
603 | neh = list_first_entry(&rc->neh_list, struct uwb_rc_neh, list_node); | ||
612 | __uwb_rc_neh_rm(rc, neh); | 604 | __uwb_rc_neh_rm(rc, neh); |
605 | spin_unlock_irqrestore(&rc->neh_lock, flags); | ||
606 | |||
607 | del_timer_sync(&neh->timer); | ||
613 | uwb_rc_neh_put(neh); | 608 | uwb_rc_neh_put(neh); |
614 | } | 609 | } |
615 | spin_unlock_irqrestore(&rc->neh_lock, flags); | ||
616 | } | 610 | } |