[alsa-devel] [PATCH] ALSA: usb-audio - Capture and duplex support for Digidesign Mbox 1 sound card.

Daniel Mack daniel at zonque.org
Mon Mar 3 22:01:21 CET 2014

Hi Damien,

Thanks for your patch! See my two comments below.

On 01/27/2014 04:02 AM, Damien Zammit wrote:
> On 27/01/14 03:52, Clemens Ladisch wrote:
>>> >> This patch creates a dual endpoint quirk.
>>>> >> >The quirk interface needs a second audioformat struct for this to work
>>>> >> >which I called ".data2".
>> > Couldn't you just let .data point to an array of two structs?
> Thanks Clemens, I have created a new patch using this suggestion.


> +	fp2 = kmemdup((const struct audioformat*)(quirk->data + sizeof(const struct audioformat)), sizeof(*fp2), GFP_KERNEL);
> +	if (!fp2) {
> +		snd_printk(KERN_ERR "cannot memdup 2\n");
> +		return -ENOMEM;
> +	}
> +	if (fp1->nr_rates > MAX_NR_RATES) {
> +		kfree(fp1);
> +		kfree(fp2);

Please do proper error unwinding here with jump labels rather than
open-coding the kfree() calls from multiple places.

Also, I wonder whether a more generic quirk type to set up a dynamic
number of fixed interfaces wouldn't be nicer. IOW, add a field to struct
snd_usb_audio_quirk to denote the number of array members in quirk->data
and call the quirk type QUIRK_AUDIO_FIXED_MULTI_ENDPOINT or something.
Then, rewrite the logic to iterate over the interfaces in a loop. That
might also make the code more readable.


More information about the Alsa-devel mailing list