--- a/drivers/net/can/usb/mcba_usb.c +++ b/drivers/net/can/usb/mcba_usb.c @@ -633,6 +633,11 @@ static int mcba_usb_start(struct mcba_pr struct urb *urb = NULL; u8 *buf; dma_addr_t buf_dma; + unsigned int pipe, type; + struct usb_host_endpoint *ep; + unsigned int pipetypes[4] = { + PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT + }; /* create a URB, and a buffer for it */ urb = usb_alloc_urb(0, GFP_KERNEL); @@ -652,8 +657,22 @@ static int mcba_usb_start(struct mcba_pr urb->transfer_dma = buf_dma; + pipe = __create_pipe(priv->udev, MCBA_USB_EP_IN) | USB_DIR_IN; + ep = usb_pipe_endpoint(priv->udev, pipe); + if (!ep) { + err = -EINVAL; + break; + } + type = usb_endpoint_type(&ep->desc); + if (type > 3) { /* out of boundary of pipetypes[type] */ + err = -EINVAL; + break; + } + type = pipetypes[type]; + pipe |= type << 30; + usb_fill_bulk_urb(urb, priv->udev, - usb_rcvbulkpipe(priv->udev, MCBA_USB_EP_IN), + pipe, buf, MCBA_USB_RX_BUFF_SIZE, mcba_usb_read_bulk_callback, priv); urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;