diff options
Diffstat (limited to 'sound/usb/endpoint.c')
-rw-r--r-- | sound/usb/endpoint.c | 73 |
1 files changed, 6 insertions, 67 deletions
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index e6906901debb..0f647d22cb4a 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c | |||
@@ -414,7 +414,7 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip, | |||
414 | { | 414 | { |
415 | struct list_head *p; | 415 | struct list_head *p; |
416 | struct snd_usb_endpoint *ep; | 416 | struct snd_usb_endpoint *ep; |
417 | int ret, is_playback = direction == SNDRV_PCM_STREAM_PLAYBACK; | 417 | int is_playback = direction == SNDRV_PCM_STREAM_PLAYBACK; |
418 | 418 | ||
419 | mutex_lock(&chip->mutex); | 419 | mutex_lock(&chip->mutex); |
420 | 420 | ||
@@ -434,16 +434,6 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip, | |||
434 | type == SND_USB_ENDPOINT_TYPE_DATA ? "data" : "sync", | 434 | type == SND_USB_ENDPOINT_TYPE_DATA ? "data" : "sync", |
435 | ep_num); | 435 | ep_num); |
436 | 436 | ||
437 | /* select the alt setting once so the endpoints become valid */ | ||
438 | ret = usb_set_interface(chip->dev, alts->desc.bInterfaceNumber, | ||
439 | alts->desc.bAlternateSetting); | ||
440 | if (ret < 0) { | ||
441 | snd_printk(KERN_ERR "%s(): usb_set_interface() failed, ret = %d\n", | ||
442 | __func__, ret); | ||
443 | ep = NULL; | ||
444 | goto __exit_unlock; | ||
445 | } | ||
446 | |||
447 | ep = kzalloc(sizeof(*ep), GFP_KERNEL); | 437 | ep = kzalloc(sizeof(*ep), GFP_KERNEL); |
448 | if (!ep) | 438 | if (!ep) |
449 | goto __exit_unlock; | 439 | goto __exit_unlock; |
@@ -831,9 +821,6 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep) | |||
831 | if (++ep->use_count != 1) | 821 | if (++ep->use_count != 1) |
832 | return 0; | 822 | return 0; |
833 | 823 | ||
834 | if (snd_BUG_ON(!test_bit(EP_FLAG_ACTIVATED, &ep->flags))) | ||
835 | return -EINVAL; | ||
836 | |||
837 | /* just to be sure */ | 824 | /* just to be sure */ |
838 | deactivate_urbs(ep, 0, 1); | 825 | deactivate_urbs(ep, 0, 1); |
839 | wait_clear_urbs(ep); | 826 | wait_clear_urbs(ep); |
@@ -911,9 +898,6 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, | |||
911 | if (snd_BUG_ON(ep->use_count == 0)) | 898 | if (snd_BUG_ON(ep->use_count == 0)) |
912 | return; | 899 | return; |
913 | 900 | ||
914 | if (snd_BUG_ON(!test_bit(EP_FLAG_ACTIVATED, &ep->flags))) | ||
915 | return; | ||
916 | |||
917 | if (--ep->use_count == 0) { | 901 | if (--ep->use_count == 0) { |
918 | deactivate_urbs(ep, force, can_sleep); | 902 | deactivate_urbs(ep, force, can_sleep); |
919 | ep->data_subs = NULL; | 903 | ep->data_subs = NULL; |
@@ -927,42 +911,6 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, | |||
927 | } | 911 | } |
928 | 912 | ||
929 | /** | 913 | /** |
930 | * snd_usb_endpoint_activate: activate an snd_usb_endpoint | ||
931 | * | ||
932 | * @ep: the endpoint to activate | ||
933 | * | ||
934 | * If the endpoint is not currently in use, this functions will select the | ||
935 | * correct alternate interface setting for the interface of this endpoint. | ||
936 | * | ||
937 | * In case of any active users, this functions does nothing. | ||
938 | * | ||
939 | * Returns an error if usb_set_interface() failed, 0 in all other | ||
940 | * cases. | ||
941 | */ | ||
942 | int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep) | ||
943 | { | ||
944 | if (ep->use_count != 0) | ||
945 | return 0; | ||
946 | |||
947 | if (!ep->chip->shutdown && | ||
948 | !test_and_set_bit(EP_FLAG_ACTIVATED, &ep->flags)) { | ||
949 | int ret; | ||
950 | |||
951 | ret = usb_set_interface(ep->chip->dev, ep->iface, ep->alt_idx); | ||
952 | if (ret < 0) { | ||
953 | snd_printk(KERN_ERR "%s() usb_set_interface() failed, ret = %d\n", | ||
954 | __func__, ret); | ||
955 | clear_bit(EP_FLAG_ACTIVATED, &ep->flags); | ||
956 | return ret; | ||
957 | } | ||
958 | |||
959 | return 0; | ||
960 | } | ||
961 | |||
962 | return -EBUSY; | ||
963 | } | ||
964 | |||
965 | /** | ||
966 | * snd_usb_endpoint_deactivate: deactivate an snd_usb_endpoint | 914 | * snd_usb_endpoint_deactivate: deactivate an snd_usb_endpoint |
967 | * | 915 | * |
968 | * @ep: the endpoint to deactivate | 916 | * @ep: the endpoint to deactivate |
@@ -980,24 +928,15 @@ int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep) | |||
980 | if (!ep) | 928 | if (!ep) |
981 | return -EINVAL; | 929 | return -EINVAL; |
982 | 930 | ||
931 | deactivate_urbs(ep, 1, 1); | ||
932 | wait_clear_urbs(ep); | ||
933 | |||
983 | if (ep->use_count != 0) | 934 | if (ep->use_count != 0) |
984 | return 0; | 935 | return 0; |
985 | 936 | ||
986 | if (!ep->chip->shutdown && | 937 | clear_bit(EP_FLAG_ACTIVATED, &ep->flags); |
987 | test_and_clear_bit(EP_FLAG_ACTIVATED, &ep->flags)) { | ||
988 | int ret; | ||
989 | |||
990 | ret = usb_set_interface(ep->chip->dev, ep->iface, 0); | ||
991 | if (ret < 0) { | ||
992 | snd_printk(KERN_ERR "%s(): usb_set_interface() failed, ret = %d\n", | ||
993 | __func__, ret); | ||
994 | return ret; | ||
995 | } | ||
996 | 938 | ||
997 | return 0; | 939 | return 0; |
998 | } | ||
999 | |||
1000 | return -EBUSY; | ||
1001 | } | 940 | } |
1002 | 941 | ||
1003 | /** | 942 | /** |