USB: Ignore storage device in modem mode on DWN-652
authorPascal Terjan <pterjan@mandriva.com>
Thu, 16 Apr 2009 17:00:45 +0000 (19:00 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 16 Jun 2009 04:44:41 +0000 (21:44 -0700)
D-Link DWN-652 in Modem mode exposes 3 interfaces
- First one is the USB storage one
- Second one is for both control and connection
- Third one is unknown

This patch avoids usb-storage trying to switch again when already in
modem mode, and exposes only 2 ttyUSB instead of 3 by not attaching
to the storage interface

Signed-off-by: Pascal Terjan <pterjan@mandriva.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/serial/option.c
drivers/usb/storage/option_ms.c
drivers/usb/storage/unusual_devs.h

index 648c481..f11672a 100644 (file)
@@ -43,6 +43,8 @@
 #include <linux/usb/serial.h>
 
 /* Function prototypes */
+static int  option_probe(struct usb_serial *serial,
+                       const struct usb_device_id *id);
 static int  option_open(struct tty_struct *tty, struct usb_serial_port *port,
                                                        struct file *filp);
 static void option_close(struct usb_serial_port *port);
@@ -555,6 +557,7 @@ static struct usb_serial_driver option_1port_device = {
        .usb_driver        = &option_driver,
        .id_table          = option_ids,
        .num_ports         = 1,
+       .probe             = option_probe,
        .open              = option_open,
        .close             = option_close,
        .dtr_rts           = option_dtr_rts,
@@ -631,6 +634,18 @@ static void __exit option_exit(void)
 module_init(option_init);
 module_exit(option_exit);
 
+static int option_probe(struct usb_serial *serial,
+                       const struct usb_device_id *id)
+{
+       /* D-Link DWM 652 still exposes CD-Rom emulation interface in modem mode */
+       if (serial->dev->descriptor.idVendor == DLINK_VENDOR_ID &&
+               serial->dev->descriptor.idProduct == DLINK_PRODUCT_DWM_652 &&
+               serial->interface->cur_altsetting->desc.bInterfaceClass == 0x8)
+               return -ENODEV;
+
+       return 0;
+}
+
 static void option_set_termios(struct tty_struct *tty,
                struct usb_serial_port *port, struct ktermios *old_termios)
 {
index 353f922..126ea34 100644 (file)
@@ -94,7 +94,8 @@ int option_ms_init(struct us_data *us)
         */
        if (udev->descriptor.bDeviceClass != 0 ||
            udev->descriptor.bDeviceSubClass != 0 ||
-           udev->descriptor.bDeviceProtocol != 0)
+           udev->descriptor.bDeviceProtocol != 0 ||
+           udev->actconfig->desc.bNumInterfaces == 3)
                return USB_STOR_TRANSPORT_GOOD;
 
        US_DEBUGP("Option MS: option_ms_init called\n");
index 4b8b690..1b9c5dd 100644 (file)
@@ -1385,7 +1385,7 @@ UNUSUAL_DEV(  0x10d6, 0x2200, 0x0100, 0x0100,
 UNUSUAL_DEV(  0x1186, 0x3e04, 0x0000, 0x0000,
            "D-Link",
            "USB Mass Storage",
-           US_SC_DEVICE, US_PR_DEVICE, option_ms_init, 0),
+           US_SC_DEVICE, US_PR_DEVICE, option_ms_init, US_FL_IGNORE_DEVICE),
 
 /* Reported by Kevin Lloyd <linux@sierrawireless.com>
  * Entry is needed for the initializer function override,