[alsa-devel] [PATCH v2] MIDI driver for Behringer BCD2000 USB device

Mario Kicherer dev at kicherer.org
Thu Feb 6 17:07:36 CET 2014


Thanks, applied most fixes. Further points:

On 05.02.2014 23:32, Daniel Mack wrote:
> Mostly due to:
>
> ERROR: DOS line endings
>
> Did you send the patch using git send-email?

Yes, I only get the two warnings as Takashi. I also moved the
strings in one line as he suggested.

>> +struct bcd2000 {
>> +	struct usb_device *dev;
>> +	struct snd_card *card;
>> +	struct usb_interface *intf;
>> +	int card_index;
>> +	struct snd_pcm *pcm;
>
> Unused?
>
>> +	struct list_head midi_list;
>> +	spinlock_t lock;
>
> Unused?
>
>> +	struct mutex mutex;
>
> That one's also kinda unused (see below)

You're right. The original module had multiple interfaces. Removed.

>> +static DEFINE_MUTEX(devices_mutex);
>> +static unsigned int devices_used;
>> +static struct usb_driver bcd2000_driver;
>> +
>> +
>> +
>> +
>> +
>
> Kill excessive newlines here.

Okay, removed. I find little gaps useful to separate logical parts.

> You could add something like this:
>
> #ifdef CONFIG_SND_DEBUG
> static void bcd2000_midi_hex_dump(const char *prefix,
> 				  const unsigned char *buf, int len)
> {
> 	print_hex_dump(KERN_DEBUG, prefix,
> 		       DUMP_PREFIX_NONE, 16, 1, buf, len, false);
> }
> #else
> static inline void bcd2000_midi_hex_dump(const char *prefix,
> 				  const unsigned char *buf, int len) {}
> #endif
>
> And then just call the function from various places. That would safe you
> the module parameter, the condition check, and an indentation level.

Hm, I removed the CONFIG_ part as the module parameter would allow
me and possible users to debug things spontaneously. But I can use our
approach if you think it would be better nonetheless?

>> +		/* safety check */
>> +		if (bcd2k->midi_cmd_offset + tocopy < BUFSIZE &&
>> +				buf_offset + tocopy < len) {
>> +			memcpy(&bcd2k->midi_cmd_buf[bcd2k->midi_cmd_offset],
>> +				&buf[buf_offset], tocopy);
>> +		} else {
>> +			snd_printk(KERN_ERR PREFIX "access violation in %s\n",
>> +					__func__);
>
> You want to drop the entire packet here, right?

Hm, I'm not sure. A "return" after the snd_printk would do, right?

Thank you very much!
Mario


More information about the Alsa-devel mailing list