UBUNTU: SAUCE: Added quirk to recognize GE0301 3G modem as an interface.

manoj.iyer at canonical.com manoj.iyer at canonical.com
Tue Apr 7 13:42:27 UTC 2009


ok here you go, I did that to save you from having to scroll though a 
lengthy email. I am also attaching the patches in case thunderbird wraps 
lines :) Here is the cherry pick patch + quirk:

>From 67b10c17b92fdfab1bb9c714f3151cb20aa65361 Mon Sep 17 00:00:00 2001
From: Dan Williams <dcbw at redhat.com>
Date: Sun, 14 Dec 2008 12:39:22 -0500
Subject: [PATCH] USB: unusual dev for Option N.V. ZeroCD modems
  Bug: 348861

Many newer Option mobile broadband devices initially provide a
usb-storage "driver CD" device that's pretty useless on Linux since
any software on it most likely wouldn't be compatible with your
kernel or distro anyway.  Thus, by default just kill the driver
CD device by sending the SCSI 'rezero' command, but allow override
of the default behavior via usb-storage module parameter so users
can keep the ZeroCD device if they really want to.  Inspired by
the Sierra TruInstall patch.

Signed-off-by: Dan Williams <dcbw at redhat.com>
Acked-by: Marcel Holtmann <marcel at holtmann.org>
Cc: Peter Henn <p.henn at option.com
Cc: Denis Joseph Barrow <D.Barow at option.com>
Cc: Alan Stern <stern at rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>
Signed-off-by: Manoj Iyer <manoj.iyer at canonical.com>
---
  drivers/usb/storage/Makefile       |    2 +-
  drivers/usb/storage/option_ms.c    |  147 ++++++++++++++++++++++++++++++++++++
  drivers/usb/storage/option_ms.h    |    4 +
  drivers/usb/storage/unusual_devs.h |   24 ++++++
  drivers/usb/storage/usb.c          |    1 +
  5 files changed, 177 insertions(+), 1 deletions(-)
  create mode 100644 drivers/usb/storage/option_ms.c
  create mode 100644 drivers/usb/storage/option_ms.h

diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
index 7f8beb5..eea6be2 100644
--- a/drivers/usb/storage/Makefile
+++ b/drivers/usb/storage/Makefile
@@ -24,7 +24,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA)	+= karma.o
  usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o

  usb-storage-objs :=	scsiglue.o protocol.o transport.o usb.o \
-			initializers.o sierra_ms.o $(usb-storage-obj-y)
+			initializers.o sierra_ms.o option_ms.o $(usb-storage-obj-y)

  ifneq ($(CONFIG_USB_LIBUSUAL),)
  	obj-$(CONFIG_USB)	+= libusual.o
diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
new file mode 100644
index 0000000..353f922
--- /dev/null
+++ b/drivers/usb/storage/option_ms.c
@@ -0,0 +1,147 @@
+/*
+ * Driver for Option High Speed Mobile Devices.
+ *
+ *   (c) 2008 Dan Williams <dcbw at redhat.com>
+ *
+ * Inspiration taken from sierra_ms.c by Kevin Lloyd <klloyd at sierrawireless.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/usb.h>
+
+#include "usb.h"
+#include "transport.h"
+#include "option_ms.h"
+#include "debug.h"
+
+#define ZCD_FORCE_MODEM			0x01
+#define ZCD_ALLOW_MS 			0x02
+
+static unsigned int option_zero_cd = ZCD_FORCE_MODEM;
+module_param(option_zero_cd, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(option_zero_cd, "ZeroCD mode (1=Force Modem (default),"
+		 " 2=Allow CD-Rom");
+
+#define RESPONSE_LEN 1024
+
+static int option_rezero(struct us_data *us, int ep_in, int ep_out)
+{
+	const unsigned char rezero_msg[] = {
+	  0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12,
+	  0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x01,
+	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+	};
+	char *buffer;
+	int result;
+
+	US_DEBUGP("Option MS: %s", "DEVICE MODE SWITCH\n");
+
+	buffer = kzalloc(RESPONSE_LEN, GFP_KERNEL);
+	if (buffer == NULL)
+		return USB_STOR_TRANSPORT_ERROR;
+
+	memcpy(buffer, rezero_msg, sizeof (rezero_msg));
+	result = usb_stor_bulk_transfer_buf(us,
+			usb_sndbulkpipe(us->pusb_dev, ep_out),
+			buffer, sizeof (rezero_msg), NULL);
+	if (result != USB_STOR_XFER_GOOD) {
+		result = USB_STOR_XFER_ERROR;
+		goto out;
+	}
+
+	/* Some of the devices need to be asked for a response, but we don't
+	 * care what that response is.
+	 */
+	result = usb_stor_bulk_transfer_buf(us,
+			usb_sndbulkpipe(us->pusb_dev, ep_out),
+			buffer, RESPONSE_LEN, NULL);
+	result = USB_STOR_XFER_GOOD;
+
+out:
+	kfree(buffer);
+	return result;
+}
+
+int option_ms_init(struct us_data *us)
+{
+	struct usb_device *udev;
+	struct usb_interface *intf;
+	struct usb_host_interface *iface_desc;
+	struct usb_endpoint_descriptor *endpoint = NULL;
+	u8 ep_in = 0, ep_out = 0;
+	int ep_in_size = 0, ep_out_size = 0;
+	int i, result;
+
+	udev = us->pusb_dev;
+	intf = us->pusb_intf;
+
+	/* Ensure it's really a ZeroCD device; devices that are already
+	 * in modem mode return 0xFF for class, subclass, and protocol.
+	 */
+	if (udev->descriptor.bDeviceClass != 0 ||
+	    udev->descriptor.bDeviceSubClass != 0 ||
+	    udev->descriptor.bDeviceProtocol != 0)
+		return USB_STOR_TRANSPORT_GOOD;
+
+	US_DEBUGP("Option MS: option_ms_init called\n");
+
+	/* Find the right mass storage interface */
+	iface_desc = intf->cur_altsetting;
+	if (iface_desc->desc.bInterfaceClass != 0x8 ||
+	    iface_desc->desc.bInterfaceSubClass != 0x6 ||
+	    iface_desc->desc.bInterfaceProtocol != 0x50) {
+		US_DEBUGP("Option MS: mass storage interface not found, no action "
+		          "required\n");
+		return USB_STOR_TRANSPORT_GOOD;
+	}
+
+	/* Find the mass storage bulk endpoints */
+	for (i = 0; i < iface_desc->desc.bNumEndpoints && (!ep_in_size || !ep_out_size); ++i) {
+		endpoint = &iface_desc->endpoint[i].desc;
+
+		if (usb_endpoint_is_bulk_in(endpoint)) {
+			ep_in = usb_endpoint_num(endpoint);
+			ep_in_size = le16_to_cpu(endpoint->wMaxPacketSize);
+		} else if (usb_endpoint_is_bulk_out(endpoint)) {
+			ep_out = usb_endpoint_num(endpoint);
+			ep_out_size = le16_to_cpu(endpoint->wMaxPacketSize);
+		}
+	}
+
+	/* Can't find the mass storage endpoints */
+	if (!ep_in_size || !ep_out_size) {
+		US_DEBUGP("Option MS: mass storage endpoints not found, no action "
+		          "required\n");
+		return USB_STOR_TRANSPORT_GOOD;
+	}
+
+	/* Force Modem mode */
+	if (option_zero_cd == ZCD_FORCE_MODEM) {
+		US_DEBUGP("Option MS: %s", "Forcing Modem Mode\n");
+		result = option_rezero(us, ep_in, ep_out);
+		if (result != USB_STOR_XFER_GOOD)
+			US_DEBUGP("Option MS: Failed to switch to modem mode.\n");
+		return -EIO;
+	} else if (option_zero_cd == ZCD_ALLOW_MS) {
+		/* Allow Mass Storage mode (keep CD-Rom) */
+		US_DEBUGP("Option MS: %s", "Allowing Mass Storage Mode if device"
+		          " requests it\n");
+	}
+
+	return USB_STOR_TRANSPORT_GOOD;
+}
+
diff --git a/drivers/usb/storage/option_ms.h b/drivers/usb/storage/option_ms.h
new file mode 100644
index 0000000..b6e448c
--- /dev/null
+++ b/drivers/usb/storage/option_ms.h
@@ -0,0 +1,4 @@
+#ifndef _OPTION_MS_H_
+#define _OPTION_MS_H_
+extern int option_ms_init(struct us_data *us);
+#endif
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index f89549f..3cfe0fe 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -846,6 +846,18 @@ UNUSUAL_DEV( 0x05ac, 0x120a, 0x0000, 0x9999,
  		US_SC_DEVICE, US_PR_DEVICE, NULL,
  		US_FL_FIX_CAPACITY ),

+/* Reported by Dan Williams <dcbw at redhat.com>
+ * Option N.V. mobile broadband modems
+ * Ignore driver CD mode and force into modem mode by default.
+ */
+
+/* Globetrotter HSDPA; mass storage shows up as Qualcomm for vendor */
+UNUSUAL_DEV(  0x05c6, 0x1000, 0x0000, 0x9999,
+		"Option N.V.",
+		"Mass Storage",
+		US_SC_DEVICE, US_PR_DEVICE, option_ms_init,
+		0),
+
  #ifdef CONFIG_USB_STORAGE_JUMPSHOT
  UNUSUAL_DEV(  0x05dc, 0x0001, 0x0000, 0x0001,
  		"Lexar",
@@ -1320,6 +1332,18 @@ UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101,
  		US_SC_DEVICE, US_PR_DEVICE, NULL,
  		US_FL_IGNORE_DEVICE ),

+/* Reported by Dan Williams <dcbw at redhat.com>
+ * Option N.V. mobile broadband modems
+ * Ignore driver CD mode and force into modem mode by default.
+ */
+
+/* iCON 225 */
+UNUSUAL_DEV(  0x0af0, 0x6971, 0x0000, 0x9999,
+		"Option N.V.",
+		"Mass Storage",
+		US_SC_DEVICE, US_PR_DEVICE, option_ms_init,
+		0),
+
  /* Reported by F. Aben <f.aben at option.com>
   * This device (wrongly) has a vendor-specific device descriptor.
   * The entry is needed so usb-storage can bind to it's mass-storage
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index ceb8ac3..2841391 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -103,6 +103,7 @@
  #include "cypress_atacb.h"
  #endif
  #include "sierra_ms.h"
+#include "option_ms.h"

  /* Some informational data */
  MODULE_AUTHOR("Matthew Dharm <mdharm-usb at one-eyed-alien.net>");
-- 
1.6.0.4

>From b56fd284d0900a5dd334f6ecafd936a57e1c1376 Mon Sep 17 00:00:00 2001
From: Manoj Iyer <manoj.iyer at canonical.com>
Date: Mon, 6 Apr 2009 10:58:49 -0500
Subject: [PATCH] UBUNTU: SAUCE: Added quirk to recognize GE0301 3G modem as an interface.

OriginalAuthor: Timo Aaltonen <tjaalton at ubuntu.com>
Bug: # 348861

Signed-off-by: Manoj Iyer <manoj.iyer at canonical.com>
---
  drivers/usb/storage/unusual_devs.h |    7 +++++++
  1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 3cfe0fe..2ba7176 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1344,6 +1344,13 @@ UNUSUAL_DEV(  0x0af0, 0x6971, 0x0000, 0x9999,
  		US_SC_DEVICE, US_PR_DEVICE, option_ms_init,
  		0),

+/* Reported by Timo Aaltonen <tjaalton at ubuntu.com> */
+UNUSUAL_DEV( 0x0af0, 0x7011, 0x0000, 0x9999,
+		"Option",
+		"Mass Storage",
+		US_SC_DEVICE, US_PR_DEVICE, option_ms_init,
+		0 ),
+
  /* Reported by F. Aben <f.aben at option.com>
   * This device (wrongly) has a vendor-specific device descriptor.
   * The entry is needed so usb-storage can bind to it's mass-storage
-- 
1.6.0.4

Cheers
--- manjo

On Tue, 7 Apr 2009, Stefan Bader wrote:

> Manoj, chickened out with this one and used only git pull request (or 
> included output of it), which leaves it to the reviewer to look into his 
> repo. From an educational viewpoint I should actually take back my ACK to NAK 
> it and wait for a propper review email...
>
> Stefan
>
> Bryan Wu wrote:
>> Manoj Iyer wrote:
>>> Cherry picked 281b064f237205053ef1874ffc77b9211265af4c and patched 
>>> drivers/usb/storage/unusual_devs.h according to patch posted by Timo 
>>> Aaltonen.
>>> 
>>> This patch was tested by the originator of the bug, and reported to work.
>>> 
>>> The following changes since commit 
>>> 585806e2d8ed99b5b973f395b3df534dae1ed73a:
>>>    Alistair John Strachan (1):
>>>          hwmon: (abituguru3) Match partial DMI board name strings
>>> 
>>> are available in the git repository at:
>>>
>>>    git://kernel.ubuntu.com/manjo/ubuntu-jaunty.git lp348861
>>> 
>>> Dan Williams (1):
>>>        USB: unusual dev for Option N.V. ZeroCD modems
>>> 
>>> Manoj Iyer (1):
>>>        UBUNTU: SAUCE: Added quirk to recognize GE0301 3G modem as an 
>>> interface.
>>>
>>>   drivers/usb/storage/Makefile       |    2 +-
>>>   drivers/usb/storage/option_ms.c    |  147 
>>> ++++++++++++++++++++++++++++++++++++
>>>   drivers/usb/storage/option_ms.h    |    4 +
>>>   drivers/usb/storage/unusual_devs.h |   31 ++++++++
>>>   drivers/usb/storage/usb.c          |    1 +
>>>   5 files changed, 184 insertions(+), 1 deletions(-)
>>>   create mode 100644 drivers/usb/storage/option_ms.c
>>>   create mode 100644 drivers/usb/storage/option_ms.h
>>> 
>>> 
>>> Cheers
>>> --- manjo
>>> 
>> 
>> Manoj,
>> 
>> Did you send out this email via git send-email command, Manoj? It was 
>> word-wrapped in my Thunderbird email client.
>> And where is the real patch email? This is a cover letter for git 
>> request-pull, IMHO.
>> 
>> Thanks
>> -Bryan
>> 
>
>
> -- 
>
> When all other means of communication fail, try words!
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-UBUNTU-SAUCE-Added-quirk-to-recognize-GE0301-3G-mo.patch
Type: text/x-diff
Size: 1208 bytes
Desc: 
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20090407/d481dbc0/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-USB-unusual-dev-for-Option-N.V.-ZeroCD-modems.patch
Type: text/x-diff
Size: 9281 bytes
Desc: 
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20090407/d481dbc0/attachment-0001.patch>


More information about the kernel-team mailing list