> From: Brad Hards [mailto:[EMAIL PROTECTED]]
> 
> "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 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.

Besides Brad's rather full explanation, I thought that Georg's answer
of a few days ago was complete and succinct.  Maybe too succinct?
(a la Alan :)

You can only transfer "extra" data (other than the request/setup packet) in
one direction at a time, right?  So the data pointer either points to
outbound data or to an incoming buffer area, depending on the request,
which you already know about for your device.

And like Georg said, be sure to kmalloc() the data area; don't use local
stack or global/static data areas for this.

HTH.
~Randy


_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
http://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to