diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-11-21 02:22:52 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-11-21 05:43:54 -0500 |
commit | ccc1696d527d64deb417bfa1ef9e479d10ad4f6b (patch) | |
tree | d28dcb5241cec632d0ff0d8d2fb79528c658f155 /sound/usb | |
parent | a9bb36261ef5c7e25564d5ce8a5129920a29bff9 (diff) |
ALSA: usb-audio: simplify endpoint deactivation code
For further code simplification, drop the conditional call for
usb_kill_urb() with can_wait argument in deactivate_urbs(), and use
only usb_unlink_urb() and wait_clear_urbs() pairs.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/endpoint.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 4d50bbe2c115..6db2143350d3 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c | |||
@@ -515,33 +515,24 @@ void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep) | |||
515 | /* | 515 | /* |
516 | * unlink active urbs. | 516 | * unlink active urbs. |
517 | */ | 517 | */ |
518 | static int deactivate_urbs(struct snd_usb_endpoint *ep, bool force, bool can_sleep) | 518 | static int deactivate_urbs(struct snd_usb_endpoint *ep, bool force) |
519 | { | 519 | { |
520 | unsigned int i; | 520 | unsigned int i; |
521 | int async; | ||
522 | 521 | ||
523 | if (!force && ep->chip->shutdown) /* to be sure... */ | 522 | if (!force && ep->chip->shutdown) /* to be sure... */ |
524 | return -EBADFD; | 523 | return -EBADFD; |
525 | 524 | ||
526 | async = !can_sleep; | ||
527 | |||
528 | clear_bit(EP_FLAG_RUNNING, &ep->flags); | 525 | clear_bit(EP_FLAG_RUNNING, &ep->flags); |
529 | 526 | ||
530 | INIT_LIST_HEAD(&ep->ready_playback_urbs); | 527 | INIT_LIST_HEAD(&ep->ready_playback_urbs); |
531 | ep->next_packet_read_pos = 0; | 528 | ep->next_packet_read_pos = 0; |
532 | ep->next_packet_write_pos = 0; | 529 | ep->next_packet_write_pos = 0; |
533 | 530 | ||
534 | if (!async && in_interrupt()) | ||
535 | return 0; | ||
536 | |||
537 | for (i = 0; i < ep->nurbs; i++) { | 531 | for (i = 0; i < ep->nurbs; i++) { |
538 | if (test_bit(i, &ep->active_mask)) { | 532 | if (test_bit(i, &ep->active_mask)) { |
539 | if (!test_and_set_bit(i, &ep->unlink_mask)) { | 533 | if (!test_and_set_bit(i, &ep->unlink_mask)) { |
540 | struct urb *u = ep->urb[i].urb; | 534 | struct urb *u = ep->urb[i].urb; |
541 | if (async) | 535 | usb_unlink_urb(u); |
542 | usb_unlink_urb(u); | ||
543 | else | ||
544 | usb_kill_urb(u); | ||
545 | } | 536 | } |
546 | } | 537 | } |
547 | } | 538 | } |
@@ -561,7 +552,7 @@ static void release_urbs(struct snd_usb_endpoint *ep, int force) | |||
561 | ep->prepare_data_urb = NULL; | 552 | ep->prepare_data_urb = NULL; |
562 | 553 | ||
563 | /* stop urbs */ | 554 | /* stop urbs */ |
564 | deactivate_urbs(ep, force, true); | 555 | deactivate_urbs(ep, force); |
565 | wait_clear_urbs(ep); | 556 | wait_clear_urbs(ep); |
566 | 557 | ||
567 | for (i = 0; i < ep->nurbs; i++) | 558 | for (i = 0; i < ep->nurbs; i++) |
@@ -837,7 +828,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep) | |||
837 | return 0; | 828 | return 0; |
838 | 829 | ||
839 | /* just to be sure */ | 830 | /* just to be sure */ |
840 | deactivate_urbs(ep, false, can_sleep); | 831 | deactivate_urbs(ep, false); |
841 | if (can_sleep) | 832 | if (can_sleep) |
842 | wait_clear_urbs(ep); | 833 | wait_clear_urbs(ep); |
843 | 834 | ||
@@ -891,7 +882,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep) | |||
891 | __error: | 882 | __error: |
892 | clear_bit(EP_FLAG_RUNNING, &ep->flags); | 883 | clear_bit(EP_FLAG_RUNNING, &ep->flags); |
893 | ep->use_count--; | 884 | ep->use_count--; |
894 | deactivate_urbs(ep, false, false); | 885 | deactivate_urbs(ep, false); |
895 | return -EPIPE; | 886 | return -EPIPE; |
896 | } | 887 | } |
897 | 888 | ||
@@ -915,7 +906,7 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool wait) | |||
915 | return; | 906 | return; |
916 | 907 | ||
917 | if (--ep->use_count == 0) { | 908 | if (--ep->use_count == 0) { |
918 | deactivate_urbs(ep, false, wait); | 909 | deactivate_urbs(ep, false); |
919 | ep->data_subs = NULL; | 910 | ep->data_subs = NULL; |
920 | ep->sync_slave = NULL; | 911 | ep->sync_slave = NULL; |
921 | ep->retire_data_urb = NULL; | 912 | ep->retire_data_urb = NULL; |
@@ -946,7 +937,7 @@ int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep) | |||
946 | if (!ep) | 937 | if (!ep) |
947 | return -EINVAL; | 938 | return -EINVAL; |
948 | 939 | ||
949 | deactivate_urbs(ep, true, true); | 940 | deactivate_urbs(ep, true); |
950 | wait_clear_urbs(ep); | 941 | wait_clear_urbs(ep); |
951 | 942 | ||
952 | if (ep->use_count != 0) | 943 | if (ep->use_count != 0) |