I am trying to create a USB driver for Linux. In this driver I am trying to send a usb_ctrlrequest
to a usb device to get some data back. When i send the request in my Linux driver I get no data back,
but the same request in Windows works fine.
This is the code I am using in my Linux USB driver:
int rv;
struct urb* urb;
struct usb_ctrlrequest* dr;
dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
if (!dr)
return -ENOMEM;
dr->bRequestType = 0xC0;
dr->bRequest = 144;
dr->wValue = cpu_to_le16(0);
dr->wIndex = cpu_to_le16(0x3000);
dr->wLength = cpu_to_le16(0);
urb = usb_alloc_urb(0, GFP_NOIO);
usb_fill_control_urb(urb, device, usb_rcvctrlpipe(device, 0x80), (unsigned char *)dr, 0, 0, usb_api_blocking_completion, NULL);
rv = usb_submit_urb(urb, GFP_NOIO);
When looking at this request in Wireshark it looks like this:
The problem is the field URB Function
has been set to URB_FUNCTION_CONTROL_TRANSFER_EX
.
The same request sent under Windows looks like this, and the device responds correctly.
So what I’m asking is how to send the usb request with the URB Function
field set to URB_FUNCTION_VENDOR_DEVICE
in a Linux device driver?