Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / drivers / usb / class / cdc-acm.c
index 57d6302..210b533 100644 (file)
@@ -293,6 +293,12 @@ static void acm_ctrl_irq(struct urb *urb)
                break;
 
        case USB_CDC_NOTIFY_SERIAL_STATE:
+               if (le16_to_cpu(dr->wLength) != 2) {
+                       dev_dbg(&acm->control->dev,
+                               "%s - malformed serial state\n", __func__);
+                       break;
+               }
+
                tty = tty_port_tty_get(&acm->port);
                newctrl = get_unaligned_le16(data);
 
@@ -323,11 +329,10 @@ static void acm_ctrl_irq(struct urb *urb)
 
        default:
                dev_dbg(&acm->control->dev,
-                       "%s - unknown notification %d received: index %d "
-                       "len %d data0 %d data1 %d\n",
+                       "%s - unknown notification %d received: index %d len %d\n",
                        __func__,
-                       dr->bNotificationType, dr->wIndex,
-                       dr->wLength, data[0], data[1]);
+                       dr->bNotificationType, dr->wIndex, dr->wLength);
+
                break;
        }
 exit:
@@ -916,12 +921,19 @@ static int acm_probe(struct usb_interface *intf,
 
        /* normal quirks */
        quirks = (unsigned long)id->driver_info;
+
+       if (quirks == IGNORE_DEVICE)
+               return -ENODEV;
+
        num_rx_buf = (quirks == SINGLE_RX_URB) ? 1 : ACM_NR;
 
        /* handle quirks deadly to normal probing*/
        if (quirks == NO_UNION_NORMAL) {
                data_interface = usb_ifnum_to_if(usb_dev, 1);
                control_interface = usb_ifnum_to_if(usb_dev, 0);
+               /* we would crash */
+               if (!data_interface || !control_interface)
+                       return -ENODEV;
                goto skip_normal_probe;
        }
 
@@ -1149,7 +1161,6 @@ made_compressed_probe:
        spin_lock_init(&acm->write_lock);
        spin_lock_init(&acm->read_lock);
        mutex_init(&acm->mutex);
-       acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress);
        acm->is_int_ep = usb_endpoint_xfer_int(epread);
        if (acm->is_int_ep)
                acm->bInterval = epread->bInterval;
@@ -1198,14 +1209,14 @@ made_compressed_probe:
                urb->transfer_dma = rb->dma;
                if (acm->is_int_ep) {
                        usb_fill_int_urb(urb, acm->dev,
-                                        acm->rx_endpoint,
+                                        usb_rcvintpipe(usb_dev, epread->bEndpointAddress),
                                         rb->base,
                                         acm->readsize,
                                         acm_read_bulk_callback, rb,
                                         acm->bInterval);
                } else {
                        usb_fill_bulk_urb(urb, acm->dev,
-                                         acm->rx_endpoint,
+                                         usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress),
                                          rb->base,
                                          acm->readsize,
                                          acm_read_bulk_callback, rb);
@@ -1233,6 +1244,8 @@ made_compressed_probe:
                                usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
                                NULL, acm->writesize, acm_write_bulk, snd);
                snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+               if (quirks & SEND_ZERO_PACKET)
+                       snd->urb->transfer_flags |= URB_ZERO_PACKET;
                snd->instance = acm;
        }
 
@@ -1295,6 +1308,11 @@ skip_countries:
 
        acm_table[minor] = acm;
 
+       if (quirks & CLEAR_HALT_CONDITIONS) {
+               usb_clear_halt(usb_dev, usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress));
+               usb_clear_halt(usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress));
+       }
+
        return 0;
 alloc_fail7:
        for (i = 0; i < ACM_NW; i++)
@@ -1528,6 +1546,7 @@ static const struct usb_device_id acm_ids[] = {
        .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
        },
        { USB_DEVICE(0x2184, 0x001c) }, /* GW Instek AFG-2225 */
+       { USB_DEVICE(0x2184, 0x0036) }, /* GW Instek AFG-125 */
        { USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */
        },
        /* Motorola H24 HSPA module: */
@@ -1574,6 +1593,10 @@ static const struct usb_device_id acm_ids[] = {
        .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
        },
 
+       { USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */
+       .driver_info = CLEAR_HALT_CONDITIONS,
+       },
+
        /* Nokia S60 phones expose two ACM channels. The first is
         * a modem and is picked up by the standard AT-command
         * information below. The second is 'vendor-specific' but
@@ -1653,6 +1676,16 @@ static const struct usb_device_id acm_ids[] = {
        .driver_info = NO_DATA_INTERFACE,
        },
 
+       /*Samsung phone in firmware update mode */
+       { USB_DEVICE(0x04e8, 0x685d),
+       .driver_info = IGNORE_DEVICE,
+       },
+
+       /* Exclude Infineon Flash Loader utility */
+       { USB_DEVICE(0x058b, 0x0041),
+       .driver_info = IGNORE_DEVICE,
+       },
+
        /* control interfaces without any protocol set */
        { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
                USB_CDC_PROTO_NONE) },
@@ -1671,6 +1704,10 @@ static const struct usb_device_id acm_ids[] = {
        { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
                USB_CDC_ACM_PROTO_AT_CDMA) },
 
+       { USB_DEVICE(0x1519, 0x0452), /* Intel 7260 modem */
+       .driver_info = SEND_ZERO_PACKET,
+       },
+
        { }
 };