All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Lloyd <klloyd@sierrawireless.com>
To: gregkh@suse.de, mdharm-usb@one-eyed-alien.net
Cc: linux-usb-users@lists.sourceforge.net,
	usb-storage@lists.one-eyed-alien.net,
	linux-kernel@vger.kernel.org
Subject: [PATCH] usb-storage: Add support for unusual device by Sierra Wireless
Date: Mon, 14 May 2007 14:44:49 -0700	[thread overview]
Message-ID: <4648D851.2030500@sierrawireless.com> (raw)

From: Kevin Lloyd <linux@sierrawireless.com>

This patch is targeted for the 2.6.21.1 kernel source. It adds support
for Sierra Wireless devices with auto-install support to the 
unusual_devices list of the usb-mass storage driver. This requires 
changes to Kconfig, Makefile, usb.c, unusual_devs.h, and the addition 
of sierra_ms.h & sierra_ms.c.

Signed-off-by: Kevin Lloyd <linux@sierrawireless.com>
---
diff -uprN linux-2.6.21.1/drivers/usb/storage/Kconfig linux-2.6.21.1.swoc/drivers/usb/storage/Kconfig
--- linux-2.6.21.1/drivers/usb/storage/Kconfig	2007-04-27 14:49:26.000000000 -0700
+++ linux-2.6.21.1.swoc/drivers/usb/storage/Kconfig	2007-05-14 13:56:41.000000000 -0700
@@ -105,6 +105,13 @@ config USB_STORAGE_SDDR55
 	  Say Y here to include additional code to support the Sandisk SDDR-55
 	  SmartMedia reader in the USB Mass Storage driver.
 
+config USB_STORAGE_SIERRA
+	bool "Sierra Wireless Modem Support"
+	depends on USB_STORAGE
+	help
+	  Say Y here in order to support new Sierra Wireless devices with the
+          auto install feature.
+	  
 config USB_STORAGE_JUMPSHOT
 	bool "Lexar Jumpshot Compact Flash Reader (EXPERIMENTAL)"
 	depends on USB_STORAGE && EXPERIMENTAL
diff -uprN linux-2.6.21.1/drivers/usb/storage/Makefile linux-2.6.21.1.swoc/drivers/usb/storage/Makefile
--- linux-2.6.21.1/drivers/usb/storage/Makefile	2007-04-27 14:49:26.000000000 -0700
+++ linux-2.6.21.1.swoc/drivers/usb/storage/Makefile	2007-05-11 15:56:44.000000000 -0700
@@ -21,6 +21,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_JUM
 usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA)	+= alauda.o
 usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH)	+= onetouch.o
 usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA)	+= karma.o
+usb-storage-obj-$(CONFIG_USB_STORAGE_SIERRA)	+= sierra_ms.o
 
 usb-storage-objs :=	scsiglue.o protocol.o transport.o usb.o \
 			initializers.o $(usb-storage-obj-y)
diff -uprN linux-2.6.21.1/drivers/usb/storage/sierra_ms.c linux-2.6.21.1.swoc/drivers/usb/storage/sierra_ms.c
--- linux-2.6.21.1/drivers/usb/storage/sierra_ms.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.6.21.1.swoc/drivers/usb/storage/sierra_ms.c	2007-05-14 13:55:38.000000000 -0700
@@ -0,0 +1,82 @@
+/* Driver for Sierra Wireless devices with auto-install support
+ *
+ * First release
+ *
+ * Current development and maintenance by:
+ *   (C) 2007 Kevin Lloyd <linux@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, 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 <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+
+#include "usb.h"
+#include "transport.h"
+#include "protocol.h"
+#include "scsiglue.h"
+#include "debug.h"
+#include "sierra_ms.h"
+
+
+int sierra_ms_init(struct us_data *us)
+{
+	int retval, retries;
+	signed long delay_t;
+	US_DEBUGP("sierra_ms: sierra_ms_init called\n");
+	
+	delay_t = 2;
+	retries = 3;
+	while (retries)
+	{
+		schedule_timeout_uninterruptible(delay_t*HZ);
+		retval = sierra_ms_change_mode(us, SWIMS_SET_MODE_Modem);
+		if (retval == -ETIMEDOUT || retval == -ETIME) {
+			US_DEBUGP("sierra_ms: Command timed out.\n");
+			retries--;
+		}
+		else if (retval < 0) {
+			/* something prevented us from registering this driver */
+			err("sierra_ms: Error sending change mode command (%d).\n", retval);
+			retries--;
+		}
+		else
+			retries=0;
+	}
+	return retval;
+}
+
+int sierra_ms_change_mode(struct us_data *us, SWIMS_SET_MODE_VALUE
+		eSocMode)
+{
+	int result;
+	unsigned char *blankArray;
+	blankArray = kmalloc(0, GFP_KERNEL);
+
+	US_DEBUGP("sierra_ms: attempting to change modes.\n");
+
+	result = usb_stor_control_msg(us, us->send_ctrl_pipe,
+				SWIMS_USB_REQUEST_SetMode,
+				SWIMS_USB_REQUEST_TYPE_SetMode,
+				eSocMode,
+				SWIMS_USB_INDEX_SetMode,
+				blankArray,
+				0,
+				5*HZ);
+
+	return result;
+}
+
diff -uprN linux-2.6.21.1/drivers/usb/storage/sierra_ms.h linux-2.6.21.1.swoc/drivers/usb/storage/sierra_ms.h
--- linux-2.6.21.1/drivers/usb/storage/sierra_ms.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.6.21.1.swoc/drivers/usb/storage/sierra_ms.h	2007-05-14 13:55:45.000000000 -0700
@@ -0,0 +1,41 @@
+/* Header File for Sierra Wireless auto-install driver
+ *
+ * First release
+ *
+ * Current development and maintenance by:
+ *   (c) 2000 In-System Design, Inc. (support@in-system.com)
+ *
+ * See sierra_ms.c for more information.
+ *
+ * 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, 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.
+*/
+
+#ifndef _SIERRA_MS_H
+#define _SIERRA_MS_H
+
+#define USB_sierra_ms_VENDOR_ID		0x1199
+#define USB_sierra_ms_PRODUCT_ID	0x0fff
+
+#define SWIMS_USB_REQUEST_SetMode	0x0B
+#define SWIMS_USB_REQUEST_TYPE_SetMode	0x40
+#define SWIMS_USB_INDEX_SetMode		0x0000
+#define SWIMS_SET_MODE_Modem		0x0001
+
+typedef __u16  SWIMS_SET_MODE_VALUE;
+
+extern int sierra_ms_init(struct us_data *us);
+int sierra_ms_change_mode(struct us_data *us, SWIMS_SET_MODE_VALUE eSocMode);
+
+#endif
diff -uprN linux-2.6.21.1/drivers/usb/storage/unusual_devs.h linux-2.6.21.1.swoc/drivers/usb/storage/unusual_devs.h
--- linux-2.6.21.1/drivers/usb/storage/unusual_devs.h	2007-04-27 14:49:26.000000000 -0700
+++ linux-2.6.21.1.swoc/drivers/usb/storage/unusual_devs.h	2007-05-11 15:56:44.000000000 -0700
@@ -1361,6 +1361,17 @@ UNUSUAL_DEV(  0x1019, 0x0c55, 0x0000, 0x
 		US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init,
 		0 ),
 
+/* Reported by Kevin Lloyd <linux@sierrawireless.com>
+ * Entry is needed for the initializer function override, 
+ * which instructs the device to load as a modem
+ * device.
+ */
+UNUSUAL_DEV(  0x1199, 0x0fff, 0x0000, 0x9999,
+		"Sierra Wireless",
+		"USB MMC Storage",
+		US_SC_DEVICE, US_PR_DEVICE, sierra_ms_init, 
+		0),
+
 /* Reported by Jaco Kroon <jaco@kroon.co.za>
  * The usb-storage module found on the Digitech GNX4 (and supposedly other
  * devices) misbehaves and causes a bunch of invalid I/O errors.
diff -uprN linux-2.6.21.1/drivers/usb/storage/usb.c linux-2.6.21.1.swoc/drivers/usb/storage/usb.c
--- linux-2.6.21.1/drivers/usb/storage/usb.c	2007-04-27 14:49:26.000000000 -0700
+++ linux-2.6.21.1.swoc/drivers/usb/storage/usb.c	2007-05-11 15:56:44.000000000 -0700
@@ -101,6 +101,10 @@
 #ifdef CONFIG_USB_STORAGE_KARMA
 #include "karma.h"
 #endif
+#ifdef CONFIG_USB_STORAGE_SIERRA
+#include "sierra_ms.h"
+#endif
+
 
 /* Some informational data */
 MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>");



             reply	other threads:[~2007-05-14 21:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-14 21:44 Kevin Lloyd [this message]
2007-05-14 22:19 ` [PATCH] usb-storage: Add support for unusual device by Sierra Wireless Pete Zaitcev
2007-05-14 22:59 ` Daniel Drake
2007-05-14 23:10   ` Kevin Lloyd
2007-05-14 23:27     ` Daniel Drake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4648D851.2030500@sierrawireless.com \
    --to=klloyd@sierrawireless.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-users@lists.sourceforge.net \
    --cc=mdharm-usb@one-eyed-alien.net \
    --cc=usb-storage@lists.one-eyed-alien.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.