"Jerram, Simon" wrote:
<snip>
> I'm not asking how my device behaves, I wouldn't expect anyone here
> to know that! I'm just asking a fairly basic question on how to
> use the USB subsystem. Perhaps it's so basic that people
> thought it beneath them to document it. ("Oh it should be obvious
> by looking at the code"- it isn't trust me!)
Err, it _is_ documented. You can either generate the documentation files (see
Documentation/kernel-doc-nano-HOWTO.txt), or you can just read the source that
generates it.
In this case, it is in drivers/usb/usb.c:
/**
* usb_control_msg - Builds a control urb, sends it off and waits for
completion
* @dev: pointer to the usb device to send the message to
* @pipe: endpoint "pipe" 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
* @data: pointer to the data to send
* @size: length in bytes of the data to send
* @timeout: time to wait for the message to complete before timing out
(if 0 the wait is forever)
*
* This function sends a simple control message to a specified endpoint
* and waits for the message to complete, or timeout.
*
* If successful, it returns 0, othwise a negative error number.
*
* Don't use this function from within an interrupt context, like a
* bottom half handler. If you need a asyncronous message, or need to
send
* a message from within interrupt context, use usb_submit_urb()
*/
Despite not really liking your somewhat accusatory tone, I am going to try to
explain this further.
the dev argument is normally passed around as part of your device context.
Look at <linux/usb.h> to see the fields, and check some other device drivers
for the relevant code sections.
the pipe argument is almost always the output of a usb_sndctrlpipe() or a
usb_rcvctrlpipe() call. Which one you need depends on whether you are sending
data to the device, or receiving data from the device. Usually you want to
send or receive control messages to the default endpoint, so the arguments are
(dev,0)
the request argument matches bRequest from the USB spec.
the requesttype argument matches bmRequestType from the USB spec. There are
some useful #define's in <linux/usb.h> for constructing the bitmask.
the value argument matches wValue from the USB spec.
the index argument matches wIndex from the USB spec.
the data argument matches the contents of the data stage (if any) for the
transfer. So if you want to transfer 4 bytes to the devices, you allocate 4
bytes (or more) of memory, put the 4 bytes into the memory, and pass a pointer
to those four bytes as the data argument.
size is the number of bytes to be transferred in the data stage (aka wLength
from the USB spec). Set to zero if no data stage.
timeout is in jiffies, and is the time waited from URB submission to getting a
-ETIMEOUT if things go wrong. Normally HZ is a good thing to put in here.
Brad
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
http://lists.sourceforge.net/lists/listinfo/linux-usb-devel