DragonFly bugs List (threaded) for 2009-05
DragonFly BSD
DragonFly bugs List (threaded) for 2009-05
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

[issue1324] ugensa.c : need help with patch : tried to add Huawei Mobile E169


From: "Alex Hornung \(via DragonFly issue tracker\)" <sinknull@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 06 May 2009 07:06:46 +0000

Alex Hornung <ahornung@gmail.com> added the comment:

I've been looking a bit into the issue and made a few changes; the diff is
attached. Can you try and see if it helps?

PS: There might be a typo somewhere that doesn't allow to compile; haven't tried
it myself, but if so it should be trivial to fix.

_____________________________________________________
DragonFly issue tracker <bugs@lists.dragonflybsd.org>
<http://bugs.dragonflybsd.org/issue1324>
_____________________________________________________
diff --git a/sys/dev/usbmisc/ugensa/ugensa.c b/sys/dev/usbmisc/ugensa/ugensa.c
index 23cb373..de23af5 100644
--- a/sys/dev/usbmisc/ugensa/ugensa.c
+++ b/sys/dev/usbmisc/ugensa/ugensa.c
@@ -76,7 +76,7 @@ static void ugensa_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
 static void ugensa_get_status(void *, int, u_char *, u_char *);
 static void ugensa_set(void *, int, int, int);
 
-static void ugensa_e220_changemode(usbd_device_handle);
+static int ugensa_e220_changemode(struct usb_attach_arg *);
 
 static device_method_t ugensa_methods[] = {
 	/* Device interface */
@@ -173,28 +173,9 @@ ugensa_match(device_t self)
 
 	if (uaa->iface == NULL)
 		return UMATCH_NONE;
-
-	/*
-	 * Some devices have massstorage interfaces - don't claim ownership
-	 * of these ... in general.
-	 * 
-	 * Some devices (most notably Huawei E220) need special handling
-	 * though. These come up with single umass interface, waiting for
-	 * magic sent to it, detach and attach again with three interfaces.
-	 * We have to claim such mass storage interface to send a magic to
-	 * it.
-	 */
-	id = usbd_get_interface_descriptor(uaa->iface);
-	if (id == NULL || id->bInterfaceClass == UICLASS_MASS) {
-		if ((uaa->vendor == 0x12d1 && uaa->product == 0x1003) ||
-		    (uaa->vendor == 0x12d1 && uaa->product == 0x1004)) {
-			if (uaa->nifaces == 1)
-				return UMATCH_VENDOR_IFACESUBCLASS;
-			else
-				return UMATCH_NONE;
-		} else
-			return UMATCH_NONE;
-	}
+		
+	if (uaa->vendor == 0x12d1)
+		return ugensa_e220_changemode(uaa);
 
 	return (usb_lookup(ugensa_devs, uaa->vendor, uaa->product) != NULL) ?
 	    UMATCH_VENDOR_IFACESUBCLASS : UMATCH_NONE;
@@ -218,13 +199,6 @@ ugensa_attach(device_t self)
 	ucom->sc_iface = uaa->iface;
 
 	id = usbd_get_interface_descriptor(ucom->sc_iface);
-	if (id == NULL || id->bInterfaceClass == UICLASS_MASS) {
-		if ((uaa->vendor == 0x12d1 && uaa->product == 0x1003) ||
-		    (uaa->vendor == 0x12d1 && uaa->product == 0x1004)) {
-			ugensa_e220_changemode(uaa->device);
-		}
-		return ENXIO;
-	}
 
 	sc->sc_iface_no = id->bInterfaceNumber;
 	ucom->sc_bulkin_no = ucom->sc_bulkout_no = -1;
@@ -468,10 +442,19 @@ ugensa_set(void *addr, int portno, int reg, int onoff)
 	(void)usbd_do_request(sc->sc_ucom.sc_udev, &req, 0);
 }
 
-static void
-ugensa_e220_changemode(usbd_device_handle dev)
+static int
+ugensa_e220_changemode(struct usb_attach_arg *uaa)
 {
 	usb_device_request_t req;
+	usbd_device_handle dev;
+	//usb_interface_descriptor_t *id;
+	
+	//id = usbd_get_interface_descriptor(uaa->iface);
+
+	if (uaa->nifaces > 1)
+		return UMATCH_VENDOR_IFACESUBCLASS;
+
+	dev = uaa->device;
 
 	req.bmRequestType = UT_WRITE_DEVICE;
 	req.bRequest = UR_SET_FEATURE;
@@ -480,5 +463,7 @@ ugensa_e220_changemode(usbd_device_handle dev)
 	USETW(req.wLength, 0);
 
 	usbd_do_request(dev, &req, 0);
+	
+	return -1; // from NetBSD: avoid umass to reattach (UMATCH_HIGHEST)
 }
 


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]