Name

usb_control_msg_recv — Builds a control receive message, sends it off and waits for completion

Synopsis

int usb_control_msg_recv (struct usb_device * dev,
 __u8 endpoint,
 __u8 request,
 __u8 requesttype,
 __u16 value,
 __u16 index,
 void * driver_data,
 __u16 size,
 int timeout,
 gfp_t memflags);
 

Arguments

dev

pointer to the usb device to send the message to

endpoint

endpoint to send the message to

request

USB message request value

requesttype

USB message request type value

value

USB message value

index

USB message index value

driver_data

pointer to the data to be filled in by the message

size

length in bytes of the data to be received

timeout

time in msecs to wait for the message to complete before timing out (if 0 the wait is forever)

memflags

the flags for memory allocation for buffers

Context

!in_interrupt ()

Description

This function sends a control message to a specified endpoint that is expected to fill in a response (i.e. a receive message) and waits for the message to complete, or timeout.

Do not use this function from within an interrupt context. If you need an asynchronous message, or need to send a message from within interrupt context, use usb_submit_urb. If a thread in your driver uses this call, make sure your disconnect method can wait for it to complete. Since you don't have a handle on the URB used, you can't cancel the request.

The data pointer can be made to a reference on the stack, or anywhere else that can be successfully written to. This function does not have the restriction that usb_control_msg has where the data pointer must be to dynamically allocated memory (i.e. memory that can be successfully DMAed to a device).

The whole message must be properly received from the device in order for this function to be successful. If a device returns less than the expected amount of data, then the function will fail. Do not use this for messages where a variable amount of data might be returned.

Return

If successful, 0 is returned, Otherwise, a negative error number.