From: Greg KH To: bjornw@axis.com Cc: dev-etrax@axis.com, linux-usb-devel@lists.sourceforge.net Subject: [PATCH] USB CRIS host controller usb_submit_urb() changes Hi, The USB group is working on changing the parameters used in the usb_submit_urb() function in the 2.5 tree. My initial patch for the main USB controller drivers and all USB drivers can be found at: http://marc.theaimsgroup.com/?l=linux-usb-devel&m=101289040332621 Because of this change, the CRIS usb-host driver also needs to be modified. Below is my attempt at this change. The patch is against 2.5.3. Please let me know if you have any problems with this patch. thanks, greg k-h diff -Nru a/arch/cris/drivers/usb-host.c b/arch/cris/drivers/usb-host.c --- a/arch/cris/drivers/usb-host.c Tue Feb 5 08:44:22 2002 +++ b/arch/cris/drivers/usb-host.c Tue Feb 5 08:44:22 2002 @@ -210,12 +210,12 @@ static void etrax_usb_free_epid(char epid); static void cleanup_sb(USB_SB_Desc_t *sb); -static int etrax_usb_do_ctrl_hw_add(struct urb *urb, char epid, char maxlen); -static int etrax_usb_do_bulk_hw_add(struct urb *urb, char epid, char maxlen); +static int etrax_usb_do_ctrl_hw_add(struct urb *urb, char epid, char maxlen, int mem_flags); +static int etrax_usb_do_bulk_hw_add(struct urb *urb, char epid, char maxlen, int mem_flags); -static int etrax_usb_submit_ctrl_urb(struct urb *urb); +static int etrax_usb_submit_ctrl_urb(struct urb *urb, int mem_flags); -static int etrax_usb_submit_urb(struct urb *urb); +static int etrax_usb_submit_urb(struct urb *urb, int mem_flags); static int etrax_usb_unlink_urb(struct urb *urb); static int etrax_usb_get_frame_number(struct usb_device *usb_dev); static int etrax_usb_allocate_dev(struct usb_device *usb_dev); @@ -512,7 +512,7 @@ } while (tmp_ep != first_ep); } -static int etrax_usb_submit_intr_urb(struct urb *urb) +static int etrax_usb_submit_intr_urb(struct urb *urb, mem_flags) { USB_EP_Desc_t *tmp_ep; USB_EP_Desc_t *first_ep; @@ -556,7 +556,7 @@ } /* Ok, now we got valid endpoint, lets insert some traffic */ - urb_priv = (etrax_urb_priv_t *)kmalloc(sizeof(etrax_urb_priv_t), GFP_KERNEL); + urb_priv = (etrax_urb_priv_t *)kmalloc(sizeof(etrax_urb_priv_t), mem_flags); urb_priv->first_sb = 0; urb_priv->rx_offset = 0; urb_priv->eot = 0; @@ -591,9 +591,9 @@ USB_SB_Desc_t *traffic_sb; traffic_ep = (USB_EP_Desc_t *) - kmem_cache_alloc(usb_desc_cache, GFP_KERNEL); + kmem_cache_alloc(usb_desc_cache, mem_flags); traffic_sb = (USB_SB_Desc_t *) - kmem_cache_alloc(usb_desc_cache, GFP_KERNEL); + kmem_cache_alloc(usb_desc_cache, mem_flags); traffic_ep->hw_len = 0; traffic_ep->command = IO_FIELD(USB_EP_command, epid, epid) | @@ -904,7 +904,7 @@ return -1; } -static int etrax_usb_submit_bulk_urb(struct urb *urb) +static int etrax_usb_submit_bulk_urb(struct urb *urb, int mem_flags) { char epid; char devnum; @@ -954,7 +954,7 @@ /* If this is the first URB, add the URB and do HW add */ URB_List[epid] = urb; restore_flags(flags); - etrax_usb_do_bulk_hw_add(urb, epid, maxlen); + etrax_usb_do_bulk_hw_add(urb, epid, maxlen, mem_flags); } DBFEXIT; @@ -962,7 +962,7 @@ return 0; } -static int etrax_usb_do_bulk_hw_add(struct urb *urb, char epid, char maxlen) +static int etrax_usb_do_bulk_hw_add(struct urb *urb, char epid, char maxlen, int mem_flags) { USB_SB_Desc_t *sb_desc_1; @@ -973,8 +973,8 @@ DBFENTER; - urb_priv = kmalloc(sizeof(etrax_urb_priv_t), GFP_KERNEL); - sb_desc_1 = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_KERNEL); + urb_priv = kmalloc(sizeof(etrax_urb_priv_t), mem_flags); + sb_desc_1 = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, mem_flags); if (usb_pipeout(urb->pipe)) { @@ -1135,7 +1135,8 @@ if (URB_List[epid]) { etrax_usb_do_bulk_hw_add(URB_List[epid], epid, usb_maxpacket(URB_List[epid]->dev, URB_List[epid]->pipe, - usb_pipeout(URB_List[epid]->pipe))); + usb_pipeout(URB_List[epid]->pipe)), + GFP_KERNEL); } #if 1 else { @@ -1159,7 +1160,7 @@ /* ---------------------------------------------------------------------------- */ -static int etrax_usb_submit_ctrl_urb(struct urb *urb) +static int etrax_usb_submit_ctrl_urb(struct urb *urb, int mem_flags) { char epid; char devnum; @@ -1209,7 +1210,7 @@ /* If this is the first URB, add the URB and do HW add */ URB_List[epid] = urb; restore_flags(flags); - etrax_usb_do_ctrl_hw_add(urb, epid, maxlen); + etrax_usb_do_ctrl_hw_add(urb, epid, maxlen, mem_flags); } DBFEXIT; @@ -1217,7 +1218,7 @@ return 0; } -static int etrax_usb_do_ctrl_hw_add(struct urb *urb, char epid, char maxlen) +static int etrax_usb_do_ctrl_hw_add(struct urb *urb, char epid, char maxlen, int mem_flags) { USB_SB_Desc_t *sb_desc_1; USB_SB_Desc_t *sb_desc_2; @@ -1231,9 +1232,9 @@ DBFENTER; - urb_priv = kmalloc(sizeof(etrax_urb_priv_t), GFP_KERNEL); - sb_desc_1 = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_KERNEL); - sb_desc_2 = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_KERNEL); + urb_priv = kmalloc(sizeof(etrax_urb_priv_t), mem_flags); + sb_desc_1 = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, mem_flags); + sb_desc_2 = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, mem_flags); if (!(sb_desc_1 && sb_desc_2)) { panic("kmem_cache_alloc in ctrl_hw_add gave NULL pointers !!!\n"); @@ -1257,7 +1258,7 @@ if (urb->transfer_buffer) { dbg_ctrl("This OUT transfer has an extra data stage"); - sb_desc_3 = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_KERNEL); + sb_desc_3 = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, mem_flags); sb_desc_1->next = virt_to_phys(sb_desc_3); @@ -1285,7 +1286,7 @@ dbg_ctrl("transfer_buffer_length = %d", urb->transfer_buffer_length); dbg_ctrl("rem is calculated to %d", urb->transfer_buffer_length % maxlen); - sb_desc_3 = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_KERNEL); + sb_desc_3 = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, mem_flags); sb_desc_2->sw_len = urb->transfer_buffer_length ? (urb->transfer_buffer_length - 1) / maxlen + 1 : 0; @@ -1358,7 +1359,7 @@ DBFEXIT; } -static int etrax_usb_submit_urb(struct urb *urb) +static int etrax_usb_submit_urb(struct urb *urb, int mem_flags) { etrax_hc_t *hc; int rval = -EINVAL; @@ -1375,10 +1376,10 @@ rval = etrax_rh_submit_urb(urb); } else if (usb_pipetype(urb->pipe) == PIPE_CONTROL) { - rval = etrax_usb_submit_ctrl_urb(urb); + rval = etrax_usb_submit_ctrl_urb(urb, mem_flags); } else if (usb_pipetype(urb->pipe) == PIPE_BULK) { - rval = etrax_usb_submit_bulk_urb(urb); + rval = etrax_usb_submit_bulk_urb(urb, mem_flags); } else if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { int bustime; @@ -1389,7 +1390,7 @@ rval = bustime; } else { usb_claim_bandwidth(urb->dev, urb, bustime, 0); - rval = etrax_usb_submit_intr_urb(urb); + rval = etrax_usb_submit_intr_urb(urb, mem_flags); } } @@ -1683,7 +1684,8 @@ if (URB_List[epid]) { etrax_usb_do_ctrl_hw_add(URB_List[epid], epid, usb_maxpacket(URB_List[epid]->dev, URB_List[epid]->pipe, - usb_pipeout(URB_List[epid]->pipe))); + usb_pipeout(URB_List[epid]->pipe)), + GFP_KERNEL); } #if 1 else {