Sorry Greg, but your patch does not work, I tried using usb_bulk_msg()
in the first place but it returns -22 (-EINVAL) this is because the
pipe is not an interrupt pipe.  Using usb_bulk_msg() does work on
another one of my machines, however.

A properly written solution would be a modified version of
usb_bulk_msg, not just a wrapper.

No {} needed for 1 line for statements (or if statements).

>        printk("\n");

I guess I didn't make myself clear. I'm not looking for syntax advice,
this is only a rapid prototype. I'm looking for obvious faults that
may cause deadlock or a kernel panic.

>        complete(&(dev->read_comp));

What does this completion handler do?

It unblocks the read function so it has synchronous support.

       wait_for_completion(&(dev->read_comp) );

What happens if the interrupt completes before you get here?  Hm, maybe
that will be safe, haven't looked at that in a long time, you might want
to verify this.

Good point, I guess I should check the status before doing a wait.  I
figured that the completion would already be complete so
wait_for_completion would return immediately.

Anyone else?

-Paul



On 5/19/06, Greg KH <[EMAIL PROTECTED]> wrote:
On Fri, May 19, 2006 at 03:23:24PM -0700, Greg KH wrote:
> On Fri, May 19, 2006 at 01:21:52AM -0400, Paul Giblock wrote:
> > Hello,  sorry about the last message. I figured it out on my own. I
> > was always sort of surprised that usb_bulk_msg would work fine with
> > interrupt endpoints, so it was just a matter of time until it would
> > not.  Anyways, I solved the problem with a callback and a condition
> > variable.

No, it should work just fine.  Look at the documentation for
usb_bulk_msg().  If something's wrong, let us know so we can fix it.

> Oh crap, we don't have a blocking usb_interrupt_msg() type function do
> we?  I've wanted that for a long time, let me go add that to the core.
> That should do what you need, right?

Well, it is dirt simple, just for completion, here's the patch.

thanks,

greg k-h

---
 drivers/usb/core/message.c |   30 ++++++++++++++++++++++++++++++
 include/linux/usb.h        |    2 ++
 2 files changed, 32 insertions(+)

--- gregkh-2.6.orig/drivers/usb/core/message.c
+++ gregkh-2.6/drivers/usb/core/message.c
@@ -158,6 +158,36 @@ int usb_control_msg(struct usb_device *d


 /**
+ * usb_interrupt_msg - Builds an interrupt urb, sends it off and waits for 
completion
+ * @usb_dev: pointer to the usb device to send the message to
+ * @pipe: endpoint "pipe" to send the message to
+ * @data: pointer to the data to send
+ * @len: length in bytes of the data to send
+ * @actual_length: pointer to a location to put the actual length transferred 
in bytes
+ * @timeout: time in msecs to wait for the message to complete before
+ *     timing out (if 0 the wait is forever)
+ * Context: !in_interrupt ()
+ *
+ * This function sends a simple interrupt message to a specified endpoint and
+ * waits for the message to complete, or timeout.
+ *
+ * If successful, it returns 0, otherwise a negative error number.  The number
+ * of actual bytes transferred will be stored in the actual_length paramater.
+ *
+ * Don't use this function from within an interrupt context, like a bottom half
+ * handler.  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.
+ */
+int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
+                     void *data, int len, int *actual_length, int timeout)
+{
+       return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout);
+}
+
+/**
  *     usb_bulk_msg - Builds a bulk urb, sends it off and waits for completion
  *     @usb_dev: pointer to the usb device to send the message to
  *     @pipe: endpoint "pipe" to send the message to
--- gregkh-2.6.orig/include/linux/usb.h
+++ gregkh-2.6/include/linux/usb.h
@@ -1021,6 +1021,8 @@ void usb_buffer_unmap_sg (struct usb_dev
 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
        __u8 request, __u8 requesttype, __u16 value, __u16 index,
        void *data, __u16 size, int timeout);
+extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
+       void *data, int len, int *actual_length, int timeout);
 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
        void *data, int len, int *actual_length,
        int timeout);



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to