[PATCH] cdc_ether fix to support Samsung Galaxy S with Android 2.3.4again

From: Markus Kolb
Date: Thu Jun 30 2011 - 15:29:56 EST


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

diff -ru linux-2.6.38/drivers/net/usb/cdc_ether.c linux-2.6.38.patched/drivers/net/usb/cdc_ether.c
--- linux-2.6.38/drivers/net/usb/cdc_ether.c 2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38.patched/drivers/net/usb/cdc_ether.c 2011-06-30 18:48:29.749287600 +0200
@@ -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",