ALSA: usb-audio: simplify snd_usb_endpoint_start/stop arguments
Reduce the redundant arguments for snd_usb_endpoint_start() and snd_usb_endpoint_stop(). Also replaced from int to bool. No functional changes by this commit. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
@@ -515,7 +515,7 @@ 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, int force, int can_sleep)
|
static int deactivate_urbs(struct snd_usb_endpoint *ep, bool force, bool can_sleep)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int async;
|
int async;
|
||||||
@@ -561,7 +561,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, 1);
|
deactivate_urbs(ep, force, true);
|
||||||
wait_clear_urbs(ep);
|
wait_clear_urbs(ep);
|
||||||
|
|
||||||
for (i = 0; i < ep->nurbs; i++)
|
for (i = 0; i < ep->nurbs; i++)
|
||||||
@@ -824,7 +824,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
|
|||||||
*
|
*
|
||||||
* Returns an error if the URB submission failed, 0 in all other cases.
|
* Returns an error if the URB submission failed, 0 in all other cases.
|
||||||
*/
|
*/
|
||||||
int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep)
|
int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -837,7 +837,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* just to be sure */
|
/* just to be sure */
|
||||||
deactivate_urbs(ep, 0, can_sleep);
|
deactivate_urbs(ep, false, can_sleep);
|
||||||
if (can_sleep)
|
if (can_sleep)
|
||||||
wait_clear_urbs(ep);
|
wait_clear_urbs(ep);
|
||||||
|
|
||||||
@@ -891,7 +891,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int 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, 0, 0);
|
deactivate_urbs(ep, false, false);
|
||||||
return -EPIPE;
|
return -EPIPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -906,8 +906,7 @@ __error:
|
|||||||
*
|
*
|
||||||
* Must be balanced to calls of snd_usb_endpoint_start().
|
* Must be balanced to calls of snd_usb_endpoint_start().
|
||||||
*/
|
*/
|
||||||
void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep,
|
void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool wait)
|
||||||
int force, int can_sleep, int wait)
|
|
||||||
{
|
{
|
||||||
if (!ep)
|
if (!ep)
|
||||||
return;
|
return;
|
||||||
@@ -916,7 +915,7 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (--ep->use_count == 0) {
|
if (--ep->use_count == 0) {
|
||||||
deactivate_urbs(ep, force, can_sleep);
|
deactivate_urbs(ep, false, wait);
|
||||||
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;
|
||||||
@@ -947,7 +946,7 @@ int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep)
|
|||||||
if (!ep)
|
if (!ep)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
deactivate_urbs(ep, 1, 1);
|
deactivate_urbs(ep, true, true);
|
||||||
wait_clear_urbs(ep);
|
wait_clear_urbs(ep);
|
||||||
|
|
||||||
if (ep->use_count != 0)
|
if (ep->use_count != 0)
|
||||||
|
@@ -16,9 +16,8 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
|
|||||||
struct audioformat *fmt,
|
struct audioformat *fmt,
|
||||||
struct snd_usb_endpoint *sync_ep);
|
struct snd_usb_endpoint *sync_ep);
|
||||||
|
|
||||||
int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep);
|
int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep);
|
||||||
void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep,
|
void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool wait);
|
||||||
int force, int can_sleep, int wait);
|
|
||||||
void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep);
|
void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep);
|
||||||
int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep);
|
int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep);
|
||||||
int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep);
|
int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep);
|
||||||
|
@@ -211,7 +211,7 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int start_endpoints(struct snd_usb_substream *subs, int can_sleep)
|
static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@@ -263,16 +263,13 @@ static int start_endpoints(struct snd_usb_substream *subs, int can_sleep)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stop_endpoints(struct snd_usb_substream *subs,
|
static void stop_endpoints(struct snd_usb_substream *subs, bool wait)
|
||||||
int force, int can_sleep, int wait)
|
|
||||||
{
|
{
|
||||||
if (test_and_clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags))
|
if (test_and_clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags))
|
||||||
snd_usb_endpoint_stop(subs->sync_endpoint,
|
snd_usb_endpoint_stop(subs->sync_endpoint, wait);
|
||||||
force, can_sleep, wait);
|
|
||||||
|
|
||||||
if (test_and_clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags))
|
if (test_and_clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags))
|
||||||
snd_usb_endpoint_stop(subs->data_endpoint,
|
snd_usb_endpoint_stop(subs->data_endpoint, wait);
|
||||||
force, can_sleep, wait);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int deactivate_endpoints(struct snd_usb_substream *subs)
|
static int deactivate_endpoints(struct snd_usb_substream *subs)
|
||||||
@@ -444,7 +441,7 @@ static int configure_endpoint(struct snd_usb_substream *subs)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* format changed */
|
/* format changed */
|
||||||
stop_endpoints(subs, 0, 0, 0);
|
stop_endpoints(subs, false);
|
||||||
ret = snd_usb_endpoint_set_params(subs->data_endpoint,
|
ret = snd_usb_endpoint_set_params(subs->data_endpoint,
|
||||||
subs->pcm_format,
|
subs->pcm_format,
|
||||||
subs->channels,
|
subs->channels,
|
||||||
@@ -530,7 +527,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
|
|||||||
subs->period_bytes = 0;
|
subs->period_bytes = 0;
|
||||||
down_read(&subs->stream->chip->shutdown_rwsem);
|
down_read(&subs->stream->chip->shutdown_rwsem);
|
||||||
if (!subs->stream->chip->shutdown) {
|
if (!subs->stream->chip->shutdown) {
|
||||||
stop_endpoints(subs, 0, 1, 1);
|
stop_endpoints(subs, true);
|
||||||
deactivate_endpoints(subs);
|
deactivate_endpoints(subs);
|
||||||
}
|
}
|
||||||
up_read(&subs->stream->chip->shutdown_rwsem);
|
up_read(&subs->stream->chip->shutdown_rwsem);
|
||||||
@@ -605,7 +602,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
|
|||||||
/* for playback, submit the URBs now; otherwise, the first hwptr_done
|
/* for playback, submit the URBs now; otherwise, the first hwptr_done
|
||||||
* updates for all URBs would happen at the same time when starting */
|
* updates for all URBs would happen at the same time when starting */
|
||||||
if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK)
|
if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK)
|
||||||
ret = start_endpoints(subs, 1);
|
ret = start_endpoints(subs, true);
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
up_read(&subs->stream->chip->shutdown_rwsem);
|
up_read(&subs->stream->chip->shutdown_rwsem);
|
||||||
@@ -1010,7 +1007,7 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction)
|
|||||||
struct snd_usb_stream *as = snd_pcm_substream_chip(substream);
|
struct snd_usb_stream *as = snd_pcm_substream_chip(substream);
|
||||||
struct snd_usb_substream *subs = &as->substream[direction];
|
struct snd_usb_substream *subs = &as->substream[direction];
|
||||||
|
|
||||||
stop_endpoints(subs, 0, 0, 0);
|
stop_endpoints(subs, false);
|
||||||
|
|
||||||
if (!as->chip->shutdown && subs->interface >= 0) {
|
if (!as->chip->shutdown && subs->interface >= 0) {
|
||||||
usb_set_interface(subs->dev, subs->interface, 0);
|
usb_set_interface(subs->dev, subs->interface, 0);
|
||||||
@@ -1245,7 +1242,7 @@ static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substrea
|
|||||||
subs->running = 1;
|
subs->running = 1;
|
||||||
return 0;
|
return 0;
|
||||||
case SNDRV_PCM_TRIGGER_STOP:
|
case SNDRV_PCM_TRIGGER_STOP:
|
||||||
stop_endpoints(subs, 0, 0, 0);
|
stop_endpoints(subs, false);
|
||||||
subs->running = 0;
|
subs->running = 0;
|
||||||
return 0;
|
return 0;
|
||||||
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||||
@@ -1266,7 +1263,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream
|
|||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SNDRV_PCM_TRIGGER_START:
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
err = start_endpoints(subs, 0);
|
err = start_endpoints(subs, false);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@@ -1274,7 +1271,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream
|
|||||||
subs->running = 1;
|
subs->running = 1;
|
||||||
return 0;
|
return 0;
|
||||||
case SNDRV_PCM_TRIGGER_STOP:
|
case SNDRV_PCM_TRIGGER_STOP:
|
||||||
stop_endpoints(subs, 0, 0, 0);
|
stop_endpoints(subs, false);
|
||||||
subs->running = 0;
|
subs->running = 0;
|
||||||
return 0;
|
return 0;
|
||||||
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||||
|
Reference in New Issue
Block a user