Commit ccc1696d authored by Takashi Iwai's avatar Takashi Iwai

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: default avatarTakashi Iwai <tiwai@suse.de>
parent a9bb3626
...@@ -515,33 +515,24 @@ void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep) ...@@ -515,33 +515,24 @@ void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep)
/* /*
* unlink active urbs. * unlink active urbs.
*/ */
static int deactivate_urbs(struct snd_usb_endpoint *ep, bool force, bool can_sleep) static int deactivate_urbs(struct snd_usb_endpoint *ep, bool force)
{ {
unsigned int i; unsigned int i;
int async;
if (!force && ep->chip->shutdown) /* to be sure... */ if (!force && ep->chip->shutdown) /* to be sure... */
return -EBADFD; return -EBADFD;
async = !can_sleep;
clear_bit(EP_FLAG_RUNNING, &ep->flags); clear_bit(EP_FLAG_RUNNING, &ep->flags);
INIT_LIST_HEAD(&ep->ready_playback_urbs); INIT_LIST_HEAD(&ep->ready_playback_urbs);
ep->next_packet_read_pos = 0; ep->next_packet_read_pos = 0;
ep->next_packet_write_pos = 0; ep->next_packet_write_pos = 0;
if (!async && in_interrupt())
return 0;
for (i = 0; i < ep->nurbs; i++) { for (i = 0; i < ep->nurbs; i++) {
if (test_bit(i, &ep->active_mask)) { if (test_bit(i, &ep->active_mask)) {
if (!test_and_set_bit(i, &ep->unlink_mask)) { if (!test_and_set_bit(i, &ep->unlink_mask)) {
struct urb *u = ep->urb[i].urb; struct urb *u = ep->urb[i].urb;
if (async)
usb_unlink_urb(u); usb_unlink_urb(u);
else
usb_kill_urb(u);
} }
} }
} }
...@@ -561,7 +552,7 @@ static void release_urbs(struct snd_usb_endpoint *ep, int force) ...@@ -561,7 +552,7 @@ static void release_urbs(struct snd_usb_endpoint *ep, int force)
ep->prepare_data_urb = NULL; ep->prepare_data_urb = NULL;
/* stop urbs */ /* stop urbs */
deactivate_urbs(ep, force, true); deactivate_urbs(ep, force);
wait_clear_urbs(ep); wait_clear_urbs(ep);
for (i = 0; i < ep->nurbs; i++) 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,7 +828,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep)
return 0; return 0;
/* just to be sure */ /* just to be sure */
deactivate_urbs(ep, false, can_sleep); deactivate_urbs(ep, false);
if (can_sleep) if (can_sleep)
wait_clear_urbs(ep); wait_clear_urbs(ep);
...@@ -891,7 +882,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep) ...@@ -891,7 +882,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep)
__error: __error:
clear_bit(EP_FLAG_RUNNING, &ep->flags); clear_bit(EP_FLAG_RUNNING, &ep->flags);
ep->use_count--; ep->use_count--;
deactivate_urbs(ep, false, false); deactivate_urbs(ep, false);
return -EPIPE; return -EPIPE;
} }
...@@ -915,7 +906,7 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool wait) ...@@ -915,7 +906,7 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool wait)
return; return;
if (--ep->use_count == 0) { if (--ep->use_count == 0) {
deactivate_urbs(ep, false, wait); deactivate_urbs(ep, false);
ep->data_subs = NULL; ep->data_subs = NULL;
ep->sync_slave = NULL; ep->sync_slave = NULL;
ep->retire_data_urb = NULL; ep->retire_data_urb = NULL;
...@@ -946,7 +937,7 @@ int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep) ...@@ -946,7 +937,7 @@ int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep)
if (!ep) if (!ep)
return -EINVAL; return -EINVAL;
deactivate_urbs(ep, true, true); deactivate_urbs(ep, true);
wait_clear_urbs(ep); wait_clear_urbs(ep);
if (ep->use_count != 0) if (ep->use_count != 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment