diff options
author | Eldad Zack <eldad@fogrefinery.com> | 2013-08-03 04:50:19 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-08-06 04:50:15 -0400 |
commit | f34d0650133389c76e22e9f27e57b74ed9e2c042 (patch) | |
tree | 2caad03be10a05bb7a2b1f421f4af5f09db60b11 /sound/usb | |
parent | a60945fd08e45fceca9e3525d70e080f7ad60a4e (diff) |
ALSA: usb-audio: reverse condition logic in set_sync_endpoint
Reverse logic on the conditions required to qualify for a sync endpoint
and remove one level of indendation.
Signed-off-by: Eldad Zack <eldad@fogrefinery.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/pcm.c | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 0016f28039f2..c31dbdc09178 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c | |||
@@ -419,49 +419,52 @@ static int set_sync_endpoint(struct snd_usb_substream *subs, | |||
419 | if (err < 0) | 419 | if (err < 0) |
420 | return err; | 420 | return err; |
421 | 421 | ||
422 | if (((is_playback && attr == USB_ENDPOINT_SYNC_ASYNC) || | 422 | if (altsd->bNumEndpoints < 2) |
423 | (!is_playback && attr == USB_ENDPOINT_SYNC_ADAPTIVE)) && | 423 | return 0; |
424 | altsd->bNumEndpoints >= 2) { | ||
425 | /* check sync-pipe endpoint */ | ||
426 | /* ... and check descriptor size before accessing bSynchAddress | ||
427 | because there is a version of the SB Audigy 2 NX firmware lacking | ||
428 | the audio fields in the endpoint descriptors */ | ||
429 | if ((get_endpoint(alts, 1)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_ISOC || | ||
430 | (get_endpoint(alts, 1)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE && | ||
431 | get_endpoint(alts, 1)->bSynchAddress != 0 && | ||
432 | !implicit_fb)) { | ||
433 | snd_printk(KERN_ERR "%d:%d:%d : invalid sync pipe. bmAttributes %02x, bLength %d, bSynchAddress %02x\n", | ||
434 | dev->devnum, fmt->iface, fmt->altsetting, | ||
435 | get_endpoint(alts, 1)->bmAttributes, | ||
436 | get_endpoint(alts, 1)->bLength, | ||
437 | get_endpoint(alts, 1)->bSynchAddress); | ||
438 | return -EINVAL; | ||
439 | } | ||
440 | ep = get_endpoint(alts, 1)->bEndpointAddress; | ||
441 | if (!implicit_fb && | ||
442 | get_endpoint(alts, 0)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE && | ||
443 | (( is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress | USB_DIR_IN)) || | ||
444 | (!is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress & ~USB_DIR_IN)))) { | ||
445 | snd_printk(KERN_ERR "%d:%d:%d : invalid sync pipe. is_playback %d, ep %02x, bSynchAddress %02x\n", | ||
446 | dev->devnum, fmt->iface, fmt->altsetting, | ||
447 | is_playback, ep, get_endpoint(alts, 0)->bSynchAddress); | ||
448 | return -EINVAL; | ||
449 | } | ||
450 | |||
451 | implicit_fb = (get_endpoint(alts, 1)->bmAttributes & USB_ENDPOINT_USAGE_MASK) | ||
452 | == USB_ENDPOINT_USAGE_IMPLICIT_FB; | ||
453 | 424 | ||
454 | subs->sync_endpoint = snd_usb_add_endpoint(subs->stream->chip, | 425 | if ((is_playback && attr != USB_ENDPOINT_SYNC_ASYNC) || |
455 | alts, ep, !subs->direction, | 426 | (!is_playback && attr != USB_ENDPOINT_SYNC_ADAPTIVE)) |
456 | implicit_fb ? | 427 | return 0; |
457 | SND_USB_ENDPOINT_TYPE_DATA : | ||
458 | SND_USB_ENDPOINT_TYPE_SYNC); | ||
459 | if (!subs->sync_endpoint) | ||
460 | return -EINVAL; | ||
461 | 428 | ||
462 | subs->data_endpoint->sync_master = subs->sync_endpoint; | 429 | /* check sync-pipe endpoint */ |
430 | /* ... and check descriptor size before accessing bSynchAddress | ||
431 | because there is a version of the SB Audigy 2 NX firmware lacking | ||
432 | the audio fields in the endpoint descriptors */ | ||
433 | if ((get_endpoint(alts, 1)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_ISOC || | ||
434 | (get_endpoint(alts, 1)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE && | ||
435 | get_endpoint(alts, 1)->bSynchAddress != 0 && | ||
436 | !implicit_fb)) { | ||
437 | snd_printk(KERN_ERR "%d:%d:%d : invalid sync pipe. bmAttributes %02x, bLength %d, bSynchAddress %02x\n", | ||
438 | dev->devnum, fmt->iface, fmt->altsetting, | ||
439 | get_endpoint(alts, 1)->bmAttributes, | ||
440 | get_endpoint(alts, 1)->bLength, | ||
441 | get_endpoint(alts, 1)->bSynchAddress); | ||
442 | return -EINVAL; | ||
443 | } | ||
444 | ep = get_endpoint(alts, 1)->bEndpointAddress; | ||
445 | if (!implicit_fb && | ||
446 | get_endpoint(alts, 0)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE && | ||
447 | ((is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress | USB_DIR_IN)) || | ||
448 | (!is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress & ~USB_DIR_IN)))) { | ||
449 | snd_printk(KERN_ERR "%d:%d:%d : invalid sync pipe. is_playback %d, ep %02x, bSynchAddress %02x\n", | ||
450 | dev->devnum, fmt->iface, fmt->altsetting, | ||
451 | is_playback, ep, get_endpoint(alts, 0)->bSynchAddress); | ||
452 | return -EINVAL; | ||
463 | } | 453 | } |
464 | 454 | ||
455 | implicit_fb = (get_endpoint(alts, 1)->bmAttributes & USB_ENDPOINT_USAGE_MASK) | ||
456 | == USB_ENDPOINT_USAGE_IMPLICIT_FB; | ||
457 | |||
458 | subs->sync_endpoint = snd_usb_add_endpoint(subs->stream->chip, | ||
459 | alts, ep, !subs->direction, | ||
460 | implicit_fb ? | ||
461 | SND_USB_ENDPOINT_TYPE_DATA : | ||
462 | SND_USB_ENDPOINT_TYPE_SYNC); | ||
463 | if (!subs->sync_endpoint) | ||
464 | return -EINVAL; | ||
465 | |||
466 | subs->data_endpoint->sync_master = subs->sync_endpoint; | ||
467 | |||
465 | return 0; | 468 | return 0; |
466 | } | 469 | } |
467 | 470 | ||