File usb-rndis-lite-samsung.patch of Package usb-rndis-lite
Index: cdc_ether.c
===================================================================
--- cdc_ether.c (revision 3009)
+++ cdc_ether.c (working copy)
@@ -18,8 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-// #define DEBUG // error path messages, extra info
-// #define VERBOSE // more; success messages
+#define DEBUG // error path messages, extra info
+#define VERBOSE // more; success messages
#include <linux/module.h>
#include <linux/version.h>
Index: usbnet.c
===================================================================
--- usbnet.c (revision 3009)
+++ usbnet.c (working copy)
@@ -30,8 +30,8 @@
* issues can usefully be addressed by this framework.
*/
-// #define DEBUG // error path messages, extra info
-// #define VERBOSE // more; success messages
+#define DEBUG // error path messages, extra info
+#define VERBOSE // more; success messages
#include <linux/module.h>
#include <linux/version.h>
Index: rndis_host.c
===================================================================
--- rndis_host.c (revision 3009)
+++ rndis_host.c (working copy)
@@ -17,8 +17,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-// #define DEBUG // error path messages, extra info
-// #define VERBOSE // more; success messages
+#define DEBUG // error path messages, extra info
+#define VERBOSE // more; success messages
#include <linux/module.h>
#include <linux/version.h>
@@ -275,6 +275,25 @@
// if not an RNDIS status, do like cdc_status(dev,urb) does
}
+//BASTARD HACK: Function ripped 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
@@ -288,11 +307,14 @@
static int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf)
{
struct cdc_state *info = (void *) &dev->data;
+ struct usb_endpoint_descriptor *endpoint;
int master_ifnum;
int retval;
- unsigned count;
- __le32 rsp;
+ unsigned count;
+ __le32 rsp;
u32 xid = 0, msg_len, request_id;
+ char int_buf[128];
+ int maxp, pipe, partial;
/* REVISIT when this gets called from contexts other than probe() or
* disconnect(): either serialize, or dispatch responses on xid
@@ -321,6 +343,29 @@
// we time out and cancel our "get response" requests...
// so, this is fragile. Probably need to poll for status.
+ // FIXME This feels rancid
+ 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);
+
+ 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
*/