Update of /cvsroot/alsa/alsa-kernel/usb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29722/alsa-kernel/usb
Modified Files: usbaudio.c usbaudio.h usbmixer.c Log Message: use wrapper function for usb_control_msg() to prevent DMA'ing from/to the stack Index: usbaudio.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/usb/usbaudio.c,v retrieving revision 1.97 retrieving revision 1.98 diff -u -r1.97 -r1.98 --- usbaudio.c 7 Apr 2004 17:48:23 -0000 1.97 +++ usbaudio.c 13 Apr 2004 07:56:23 -0000 1.98 @@ -1147,7 +1147,7 @@ /* if endpoint has pitch control, enable it */ if (fmt->attributes & EP_CS_ATTR_PITCH_CONTROL) { data[0] = 1; - if ((err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, + if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, PITCH_CONTROL << 8, ep, data, 1, HZ)) < 0) { snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH\n", @@ -1173,14 +1173,14 @@ data[0] = rate; data[1] = rate >> 8; data[2] = rate >> 16; - if ((err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, + if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, SAMPLING_FREQ_CONTROL << 8, ep, data, 3, HZ)) < 0) { snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep 0x%x\n", dev->devnum, iface, fmt->altsetting, rate, ep); return err; } - if ((err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR, + if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR, USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN, SAMPLING_FREQ_CONTROL << 8, ep, data, 3, HZ)) < 0) { snd_printk(KERN_ERR "%d:%d:%d: cannot get freq at ep 0x%x\n", @@ -1885,6 +1885,32 @@ return NULL; } +/* + * Wrapper for usb_control_msg(). + * Allocates a temp buffer to prevent dmaing from/to the stack. + */ +int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, + __u8 requesttype, __u16 value, __u16 index, void *data, + __u16 size, int timeout) +{ + int err; + void *buf = NULL; + + if (size > 0) { + buf = kmalloc(size, GFP_KERNEL); + if (!buf) + return -ENOMEM; + memcpy(buf, data, size); + } + err = usb_control_msg(dev, pipe, request, requesttype, + value, index, buf, size, timeout); + if (size > 0) { + memcpy(data, buf, size); + kfree(buf); + } + return err; +} + /* * entry point for linux usb interface @@ -2763,7 +2789,7 @@ get_cfg_desc(config)->wTotalLength == EXTIGY_FIRMWARE_SIZE_NEW) { snd_printdd("sending Extigy boot sequence...\n"); /* Send message to force it to reconnect with full interface. */ - err = usb_control_msg(dev, usb_sndctrlpipe(dev,0), + err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev,0), 0x10, 0x43, 0x0001, 0x000a, NULL, 0, HZ); if (err < 0) snd_printdd("error sending boot message: %d\n", err); err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, Index: usbaudio.h =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/usb/usbaudio.h,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- usbaudio.h 29 Mar 2004 12:33:37 -0000 1.29 +++ usbaudio.h 13 Apr 2004 07:56:24 -0000 1.30 @@ -197,6 +197,8 @@ void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype); void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype); +int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout); + int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif); int snd_usb_create_midi_interface(snd_usb_audio_t *chip, struct usb_interface *iface, const snd_usb_audio_quirk_t *quirk); Index: usbmixer.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/usb/usbmixer.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- usbmixer.c 17 Mar 2004 13:08:47 -0000 1.26 +++ usbmixer.c 13 Apr 2004 07:56:34 -0000 1.27 @@ -301,7 +301,7 @@ int timeout = 10; while (timeout-- > 0) { - if (usb_control_msg(cval->chip->dev, usb_rcvctrlpipe(cval->chip->dev, 0), + if (snd_usb_ctl_msg(cval->chip->dev, usb_rcvctrlpipe(cval->chip->dev, 0), request, USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, validx, cval->ctrlif | (cval->id << 8), @@ -339,7 +339,7 @@ buf[0] = value_set & 0xff; buf[1] = (value_set >> 8) & 0xff; while (timeout -- > 0) - if (usb_control_msg(cval->chip->dev, usb_sndctrlpipe(cval->chip->dev, 0), + if (snd_usb_ctl_msg(cval->chip->dev, usb_sndctrlpipe(cval->chip->dev, 0), request, USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, validx, cval->ctrlif | (cval->id << 8), ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Alsa-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-cvslog