ChangeSet 1.2000.6.21, 2004/10/20 16:37:08-07:00, [EMAIL PROTECTED]

[PATCH] USB: USB fixes for non-cache-coherent processors

I posted this before, but didn't see any discussion.

This patch fixes a couple of places where the usb subsystem
DMAs to/from local (stack) variables.  This doesn't work on
non-cache-coherent processors.  I'm testing on PPC 4xx systems.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


 drivers/usb/class/audio.c  |   13 +++++++++++--
 drivers/usb/core/message.c |   16 +++++++++++++---
 2 files changed, 24 insertions(+), 5 deletions(-)


diff -Nru a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c
--- a/drivers/usb/class/audio.c 2004-10-22 16:13:49 -07:00
+++ b/drivers/usb/class/audio.c 2004-10-22 16:13:49 -07:00
@@ -3119,12 +3119,18 @@
 {
        struct usb_device *dev = state->s->usbdev;
        struct mixerchannel *ch;
-       unsigned char buf[2];
+       unsigned char *buf;
        __s16 v1;
        unsigned int v2, v3;
 
        if (!state->nrmixch || state->nrmixch > SOUND_MIXER_NRDEVICES)
                return;
+       buf = kmalloc(sizeof(*buf) * 2, GFP_KERNEL);
+       if (!buf) {
+               printk(KERN_ERR "prepmixch: out of memory\n") ;
+               return;
+       }
+
        ch = &state->mixch[state->nrmixch-1];
        switch (ch->selector) {
        case 0:  /* mixer unit request */
@@ -3236,13 +3242,16 @@
        default:
                goto err;
        }
-       return;
 
+ freebuf:
+       kfree(buf);
+       return;
  err:
        printk(KERN_ERR "usbaudio: mixer request device %u if %u unit %u ch %u 
selector %u failed\n", 
               dev->devnum, state->ctrlif, ch->unitid, ch->chnum, ch->selector);
        if (state->nrmixch)
                state->nrmixch--;
+       goto freebuf;
 }
 
 
diff -Nru a/drivers/usb/core/message.c b/drivers/usb/core/message.c
--- a/drivers/usb/core/message.c        2004-10-22 16:13:49 -07:00
+++ b/drivers/usb/core/message.c        2004-10-22 16:13:49 -07:00
@@ -823,9 +823,19 @@
  */
 int usb_get_status(struct usb_device *dev, int type, int target, void *data)
 {
-       return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-               USB_REQ_GET_STATUS, USB_DIR_IN | type, 0, target, data, 2,
-               HZ * USB_CTRL_GET_TIMEOUT);
+       int ret;
+       u16 *status = kmalloc(sizeof(*status), GFP_KERNEL);
+
+       if (!status)
+               return -ENOMEM;
+
+       ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+               USB_REQ_GET_STATUS, USB_DIR_IN | type, 0, target, status,
+               sizeof(*status), HZ * USB_CTRL_GET_TIMEOUT);
+
+       *(u16 *)data = *status;
+       kfree(status);
+       return ret;
 }
 
 /**



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to