diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-11-20 12:32:06 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-11-21 05:43:40 -0500 |
commit | a9bb36261ef5c7e25564d5ce8a5129920a29bff9 (patch) | |
tree | 085c83dbf44cc98c77b490ce663bccf3c235a2ea /sound/usb | |
parent | 20d32022a8d8639a33d0e429f2d3c51b527ea362 (diff) |
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>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/endpoint.c | 17 | ||||
-rw-r--r-- | sound/usb/endpoint.h | 5 | ||||
-rw-r--r-- | sound/usb/pcm.c | 25 |
3 files changed, 21 insertions, 26 deletions
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index d7382a5e29bb..4d50bbe2c115 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c | |||
@@ -515,7 +515,7 @@ 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, int force, int can_sleep) | 518 | static int deactivate_urbs(struct snd_usb_endpoint *ep, bool force, bool can_sleep) |
519 | { | 519 | { |
520 | unsigned int i; | 520 | unsigned int i; |
521 | int async; | 521 | int async; |
@@ -561,7 +561,7 @@ static void release_urbs(struct snd_usb_endpoint *ep, int force) | |||
561 | ep->prepare_data_urb = NULL; | 561 | ep->prepare_data_urb = NULL; |
562 | 562 | ||
563 | /* stop urbs */ | 563 | /* stop urbs */ |
564 | deactivate_urbs(ep, force, 1); | 564 | deactivate_urbs(ep, force, true); |
565 | wait_clear_urbs(ep); | 565 | wait_clear_urbs(ep); |
566 | 566 | ||
567 | for (i = 0; i < ep->nurbs; i++) | 567 | for (i = 0; i < ep->nurbs; i++) |
@@ -824,7 +824,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, | |||
824 | * | 824 | * |
825 | * Returns an error if the URB submission failed, 0 in all other cases. | 825 | * Returns an error if the URB submission failed, 0 in all other cases. |
826 | */ | 826 | */ |
827 | int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep) | 827 | int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep) |
828 | { | 828 | { |
829 | int err; | 829 | int err; |
830 | unsigned int i; | 830 | unsigned int i; |
@@ -837,7 +837,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep) | |||
837 | return 0; | 837 | return 0; |
838 | 838 | ||
839 | /* just to be sure */ | 839 | /* just to be sure */ |
840 | deactivate_urbs(ep, 0, can_sleep); | 840 | deactivate_urbs(ep, false, can_sleep); |
841 | if (can_sleep) | 841 | if (can_sleep) |
842 | wait_clear_urbs(ep); | 842 | wait_clear_urbs(ep); |
843 | 843 | ||
@@ -891,7 +891,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep) | |||
891 | __error: | 891 | __error: |
892 | clear_bit(EP_FLAG_RUNNING, &ep->flags); | 892 | clear_bit(EP_FLAG_RUNNING, &ep->flags); |
893 | ep->use_count--; | 893 | ep->use_count--; |
894 | deactivate_urbs(ep, 0, 0); | 894 | deactivate_urbs(ep, false, false); |
895 | return -EPIPE; | 895 | return -EPIPE; |
896 | } | 896 | } |
897 | 897 | ||
@@ -906,8 +906,7 @@ __error: | |||
906 | * | 906 | * |
907 | * Must be balanced to calls of snd_usb_endpoint_start(). | 907 | * Must be balanced to calls of snd_usb_endpoint_start(). |
908 | */ | 908 | */ |
909 | void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, | 909 | void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool wait) |
910 | int force, int can_sleep, int wait) | ||
911 | { | 910 | { |
912 | if (!ep) | 911 | if (!ep) |
913 | return; | 912 | return; |
@@ -916,7 +915,7 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, | |||
916 | return; | 915 | return; |
917 | 916 | ||
918 | if (--ep->use_count == 0) { | 917 | if (--ep->use_count == 0) { |
919 | deactivate_urbs(ep, force, can_sleep); | 918 | deactivate_urbs(ep, false, wait); |
920 | ep->data_subs = NULL; | 919 | ep->data_subs = NULL; |
921 | ep->sync_slave = NULL; | 920 | ep->sync_slave = NULL; |
922 | ep->retire_data_urb = NULL; | 921 | ep->retire_data_urb = NULL; |
@@ -947,7 +946,7 @@ int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep) | |||
947 | if (!ep) | 946 | if (!ep) |
948 | return -EINVAL; | 947 | return -EINVAL; |
949 | 948 | ||
950 | deactivate_urbs(ep, 1, 1); | 949 | deactivate_urbs(ep, true, true); |
951 | wait_clear_urbs(ep); | 950 | wait_clear_urbs(ep); |
952 | 951 | ||
953 | if (ep->use_count != 0) | 952 | if (ep->use_count != 0) |
diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h index 3d4c9705041f..f1e451da9a67 100644 --- a/sound/usb/endpoint.h +++ b/sound/usb/endpoint.h | |||
@@ -16,9 +16,8 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, | |||
16 | struct audioformat *fmt, | 16 | struct audioformat *fmt, |
17 | struct snd_usb_endpoint *sync_ep); | 17 | struct snd_usb_endpoint *sync_ep); |
18 | 18 | ||
19 | int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep); | 19 | int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep); |
20 | void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, | 20 | void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool wait); |
21 | int force, int can_sleep, int wait); | ||
22 | void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep); | 21 | void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep); |
23 | int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); | 22 | int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); |
24 | int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep); | 23 | int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep); |
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index e7329d0449f2..d90604aa5137 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c | |||
@@ -211,7 +211,7 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface, | |||
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||
214 | static int start_endpoints(struct snd_usb_substream *subs, int can_sleep) | 214 | static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep) |
215 | { | 215 | { |
216 | int err; | 216 | int err; |
217 | 217 | ||
@@ -263,16 +263,13 @@ static int start_endpoints(struct snd_usb_substream *subs, int can_sleep) | |||
263 | return 0; | 263 | return 0; |
264 | } | 264 | } |
265 | 265 | ||
266 | static void stop_endpoints(struct snd_usb_substream *subs, | 266 | static void stop_endpoints(struct snd_usb_substream *subs, bool wait) |
267 | int force, int can_sleep, int wait) | ||
268 | { | 267 | { |
269 | if (test_and_clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags)) | 268 | if (test_and_clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags)) |
270 | snd_usb_endpoint_stop(subs->sync_endpoint, | 269 | snd_usb_endpoint_stop(subs->sync_endpoint, wait); |
271 | force, can_sleep, wait); | ||
272 | 270 | ||
273 | if (test_and_clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags)) | 271 | if (test_and_clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags)) |
274 | snd_usb_endpoint_stop(subs->data_endpoint, | 272 | snd_usb_endpoint_stop(subs->data_endpoint, wait); |
275 | force, can_sleep, wait); | ||
276 | } | 273 | } |
277 | 274 | ||
278 | static int deactivate_endpoints(struct snd_usb_substream *subs) | 275 | static int deactivate_endpoints(struct snd_usb_substream *subs) |
@@ -444,7 +441,7 @@ static int configure_endpoint(struct snd_usb_substream *subs) | |||
444 | int ret; | 441 | int ret; |
445 | 442 | ||
446 | /* format changed */ | 443 | /* format changed */ |
447 | stop_endpoints(subs, 0, 0, 0); | 444 | stop_endpoints(subs, false); |
448 | ret = snd_usb_endpoint_set_params(subs->data_endpoint, | 445 | ret = snd_usb_endpoint_set_params(subs->data_endpoint, |
449 | subs->pcm_format, | 446 | subs->pcm_format, |
450 | subs->channels, | 447 | subs->channels, |
@@ -530,7 +527,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) | |||
530 | subs->period_bytes = 0; | 527 | subs->period_bytes = 0; |
531 | down_read(&subs->stream->chip->shutdown_rwsem); | 528 | down_read(&subs->stream->chip->shutdown_rwsem); |
532 | if (!subs->stream->chip->shutdown) { | 529 | if (!subs->stream->chip->shutdown) { |
533 | stop_endpoints(subs, 0, 1, 1); | 530 | stop_endpoints(subs, true); |
534 | deactivate_endpoints(subs); | 531 | deactivate_endpoints(subs); |
535 | } | 532 | } |
536 | up_read(&subs->stream->chip->shutdown_rwsem); | 533 | up_read(&subs->stream->chip->shutdown_rwsem); |
@@ -605,7 +602,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) | |||
605 | /* for playback, submit the URBs now; otherwise, the first hwptr_done | 602 | /* for playback, submit the URBs now; otherwise, the first hwptr_done |
606 | * updates for all URBs would happen at the same time when starting */ | 603 | * updates for all URBs would happen at the same time when starting */ |
607 | if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) | 604 | if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) |
608 | ret = start_endpoints(subs, 1); | 605 | ret = start_endpoints(subs, true); |
609 | 606 | ||
610 | unlock: | 607 | unlock: |
611 | up_read(&subs->stream->chip->shutdown_rwsem); | 608 | up_read(&subs->stream->chip->shutdown_rwsem); |
@@ -1010,7 +1007,7 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction) | |||
1010 | struct snd_usb_stream *as = snd_pcm_substream_chip(substream); | 1007 | struct snd_usb_stream *as = snd_pcm_substream_chip(substream); |
1011 | struct snd_usb_substream *subs = &as->substream[direction]; | 1008 | struct snd_usb_substream *subs = &as->substream[direction]; |
1012 | 1009 | ||
1013 | stop_endpoints(subs, 0, 0, 0); | 1010 | stop_endpoints(subs, false); |
1014 | 1011 | ||
1015 | if (!as->chip->shutdown && subs->interface >= 0) { | 1012 | if (!as->chip->shutdown && subs->interface >= 0) { |
1016 | usb_set_interface(subs->dev, subs->interface, 0); | 1013 | usb_set_interface(subs->dev, subs->interface, 0); |
@@ -1245,7 +1242,7 @@ static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substrea | |||
1245 | subs->running = 1; | 1242 | subs->running = 1; |
1246 | return 0; | 1243 | return 0; |
1247 | case SNDRV_PCM_TRIGGER_STOP: | 1244 | case SNDRV_PCM_TRIGGER_STOP: |
1248 | stop_endpoints(subs, 0, 0, 0); | 1245 | stop_endpoints(subs, false); |
1249 | subs->running = 0; | 1246 | subs->running = 0; |
1250 | return 0; | 1247 | return 0; |
1251 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 1248 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
@@ -1266,7 +1263,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream | |||
1266 | 1263 | ||
1267 | switch (cmd) { | 1264 | switch (cmd) { |
1268 | case SNDRV_PCM_TRIGGER_START: | 1265 | case SNDRV_PCM_TRIGGER_START: |
1269 | err = start_endpoints(subs, 0); | 1266 | err = start_endpoints(subs, false); |
1270 | if (err < 0) | 1267 | if (err < 0) |
1271 | return err; | 1268 | return err; |
1272 | 1269 | ||
@@ -1274,7 +1271,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream | |||
1274 | subs->running = 1; | 1271 | subs->running = 1; |
1275 | return 0; | 1272 | return 0; |
1276 | case SNDRV_PCM_TRIGGER_STOP: | 1273 | case SNDRV_PCM_TRIGGER_STOP: |
1277 | stop_endpoints(subs, 0, 0, 0); | 1274 | stop_endpoints(subs, false); |
1278 | subs->running = 0; | 1275 | subs->running = 0; |
1279 | return 0; | 1276 | return 0; |
1280 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 1277 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |