Skip to contentSkip to conversation

cdc_ether fix to support Samsung Galaxy S with Android 2.3.4 again

PATCH New Markus Kolb 1 participant 1 message Jun 30, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cdc_ether fix to support Samsung Galaxy S with Android 2.3.4 again

cdc_ether uses currently the wrong bInterfaceNumber(s).
It uses CDC Union information for bMasterInterface and bSlaveInterface which seems to be wrong. At least there isn't any relation.
I don't know what would be the correct way but with my patch the driver supports the mobile phone again and there should be no malfunction with already supported hardware. For a bug report see
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/796006

drivers/net/usb/cdc_ether.c +20 -0
diff -ru linux-2.6.38/drivers/net/usb/cdc_ether.c linux-2.6.38.patched/drivers/net/usb/cdc_ether.c
@@ -86,6 +86,8 @@
 	struct usb_driver		*driver = driver_of(intf);
 	struct usb_cdc_mdlm_desc	*desc = NULL;
 	struct usb_cdc_mdlm_detail_desc *detail = NULL;
+	int				mapped_master;
+	int				mapped_slave;
 
 	if (sizeof dev->data < sizeof *info)
 		return -EDOM;
@@ -188,6 +190,24 @@
 						info->u->bMasterInterface0);
 			info->data = usb_ifnum_to_if(dev->udev,
 						info->u->bSlaveInterface0);
+			if ((!info->control || !info->data) 
+					&& (info->u->bMasterInterface0 > 0)) {
+				// try with mapping to start with 0
+				mapped_master = (info->u->bMasterInterface0 
+						- ((info->u->bSlaveInterface0 >
+						info->u->bMasterInterface0) ? 
+						info->u->bMasterInterface0 : 
+						info->u->bSlaveInterface0));
+				mapped_slave = (info->u->bSlaveInterface0 
+						- ((info->u->bSlaveInterface0 >
+						info->u->bMasterInterface0) ? 
+						info->u->bMasterInterface0 : 
+						info->u->bSlaveInterface0));
+				info->control = usb_ifnum_to_if(dev->udev,
+						mapped_master);
+				info->data = usb_ifnum_to_if(dev->udev,
+						mapped_slave);
+			}
 			if (!info->control || !info->data) {
 				dev_dbg(&intf->dev,
 					"master #%u/%p slave #%u/%p\n",