Mark Ellis
Mon, 22 Feb 2010 12:12:19 -0800
From: Mark Ellis <m...@mpellis.org.uk> Certain devices, particularly those with Samsung processors, show difficulties connecting via RNDIS, specifically resulting in -110 errors in driver initialisation.
This patch, resulting from comparisons with an obsolete user mode
driver, overcomes this in all tested cases.
Signed-off-by: Mark Ellis <m...@mpellis.org.uk>
---
diff -Nurp linux-source-2.6.31.orig/drivers/net/usb/rndis_host.c
linux-source-2.6.31/drivers/net/usb/rndis_host.c
--- linux-source-2.6.31.orig/drivers/net/usb/rndis_host.c 2009-09-09
23:13:59.000000000 +0100
+++ linux-source-2.6.31/drivers/net/usb/rndis_host.c 2010-02-16
19:03:12.497106220 +0000
@@ -64,6 +64,25 @@ void rndis_status(struct usbnet *dev, st
}
EXPORT_SYMBOL_GPL(rndis_status);
+/* Function copied from keyspan_remote.c */
+static struct usb_endpoint_descriptor *rndis_get_in_endpoint(struct
usb_host_interface *iface)
+{
+
+ struct usb_endpoint_descriptor *endpoint;
+ int i;
+
+ for (i = 0; i < iface->desc.bNumEndpoints; ++i) {
+ endpoint = &iface->endpoint[i].desc;
+
+ if (usb_endpoint_is_int_in(endpoint)) {
+ /* we found our interrupt in endpoint */
+ return endpoint;
+ }
+ }
+
+ return NULL;
+}
+
/*
* RPC done RNDIS-style. Caller guarantees:
* - message is properly byteswapped
@@ -77,11 +96,14 @@ EXPORT_SYMBOL_GPL(rndis_status);
int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
{
struct cdc_state *info = (void *) &dev->data;
+ struct usb_endpoint_descriptor *endpoint;
int master_ifnum;
int retval;
unsigned count;
__le32 rsp;
u32 xid = 0, msg_len, request_id;
+ char *int_buf = NULL;
+ int maxp, pipe, partial;
/* REVISIT when this gets called from contexts other than probe() or
* disconnect(): either serialize, or dispatch responses on xid
@@ -110,6 +132,38 @@ int rndis_command(struct usbnet *dev, st
// we time out and cancel our "get response" requests...
// so, this is fragile. Probably need to poll for status.
+ /* Certain rndis devices, particularly with Samsung processors,
+ * are problematic. An interrupt message appears to fix this.
+ */
+
+ int_buf = kmalloc(128, GFP_KERNEL);
+ if (!int_buf)
+ return -ENOMEM;
+
+ endpoint = rndis_get_in_endpoint(info->control->cur_altsetting);
+ pipe = usb_rcvintpipe(dev->udev, endpoint->bEndpointAddress);
+ maxp = usb_maxpacket(dev->udev, pipe, usb_pipeout(pipe));
+
+ retval = usb_interrupt_msg(dev->udev,
+ pipe,
+ int_buf,
+ (maxp > 8 ? 8 : maxp),
+ &partial,
+ RNDIS_CONTROL_TIMEOUT_MS);
+ kfree(int_buf);
+
+ dev_dbg(&info->control->dev,
+ "pipe: %d, maxp: %d, partial: %d, retval: %d\n",
+ pipe,
+ maxp,
+ partial,
+ retval);
+
+ /* I /think/ usb_interrupt_msg blocks and returns < 0 for error */
+ if (unlikely(retval < 0))
+ return retval;
+
+
/* ignore status endpoint, just poll the control channel;
* the request probably completed immediately
*/
signature.asc
Description: This is a digitally signed message part
------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev
_______________________________________________ SynCE-Devel mailing list SynCE-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synce-devel