ChangeSet 1.811.1.11, 2002/12/13 09:30:44-08:00, petkan@rakia.dce.bg [PATCH] USB: pegasus: the data for the control requests is now stored in DMA able memory. diff -Nru a/drivers/usb/pegasus.c b/drivers/usb/pegasus.c --- a/drivers/usb/pegasus.c Mon Dec 16 16:34:01 2002 +++ b/drivers/usb/pegasus.c Mon Dec 16 16:34:01 2002 @@ -42,7 +42,7 @@ /* * Version Information */ -#define DRIVER_VERSION "v0.4.27 (2002/11/19)" +#define DRIVER_VERSION "v0.4.28 (2002/12/13)" #define DRIVER_AUTHOR "Petko Manolov " #define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver" @@ -116,9 +116,14 @@ void *data) { int ret; - unsigned char buffer[256]; + char *buffer; DECLARE_WAITQUEUE(wait, current); + buffer = kmalloc(size, GFP_DMA); + if (!buffer) { + warn("%s: looks like we're out of memory", __FUNCTION__); + return -ENOMEM; + } add_wait_queue(&pegasus->ctrl_wait, &wait); set_current_state(TASK_UNINTERRUPTIBLE); while (pegasus->flags & ETH_REGS_CHANGED) @@ -150,6 +155,7 @@ out: remove_wait_queue(&pegasus->ctrl_wait, &wait); memcpy(data, buffer, size); + kfree(buffer); return ret; } @@ -158,9 +164,14 @@ void *data) { int ret; - unsigned char buffer[256]; + char *buffer; DECLARE_WAITQUEUE(wait, current); + buffer = kmalloc(size, GFP_DMA); + if (!buffer) { + warn("%s: looks like we're out of memory", __FUNCTION__); + return -ENOMEM; + } memcpy(buffer, data, size); add_wait_queue(&pegasus->ctrl_wait, &wait); @@ -193,6 +204,7 @@ schedule(); out: remove_wait_queue(&pegasus->ctrl_wait, &wait); + kfree(buffer); return ret; } @@ -200,9 +212,15 @@ static int set_register(pegasus_t * pegasus, u16 indx, u8 data) { int ret; - u16 tmp = data; + char *tmp; DECLARE_WAITQUEUE(wait, current); + tmp = kmalloc(1, GFP_DMA); + if (!tmp) { + warn("%s: looks like we're out of memory", __FUNCTION__); + return -ENOMEM; + } + memcpy(tmp, &data, 1); add_wait_queue(&pegasus->ctrl_wait, &wait); set_current_state(TASK_UNINTERRUPTIBLE); while (pegasus->flags & ETH_REGS_CHANGED) @@ -212,7 +230,7 @@ pegasus->dr.bRequestType = PEGASUS_REQT_WRITE; pegasus->dr.bRequest = PEGASUS_REQ_SET_REG; - pegasus->dr.wValue = cpu_to_le16p(&tmp); + pegasus->dr.wValue = cpu_to_le16p(&data); pegasus->dr.wIndex = cpu_to_le16p(&indx); pegasus->dr.wLength = cpu_to_le16(1); pegasus->ctrl_urb->transfer_buffer_length = 1; @@ -220,7 +238,7 @@ FILL_CONTROL_URB(pegasus->ctrl_urb, pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0), (char *) &pegasus->dr, - &data, 1, ctrl_callback, pegasus); + tmp, 1, ctrl_callback, pegasus); add_wait_queue(&pegasus->ctrl_wait, &wait); set_current_state(TASK_UNINTERRUPTIBLE); @@ -233,6 +251,7 @@ schedule(); out: remove_wait_queue(&pegasus->ctrl_wait, &wait); + kfree(tmp); return ret; }