USB: cdc-acm: use dev_err to report failed allocations
[cascardo/linux.git] / drivers / usb / class / cdc-acm.c
index f492a7f..c9f8a83 100644 (file)
@@ -297,6 +297,8 @@ static void acm_ctrl_irq(struct urb *urb)
        if (!ACM_READY(acm))
                goto exit;
 
+       usb_mark_last_busy(acm->dev);
+
        data = (unsigned char *)(dr + 1);
        switch (dr->bNotificationType) {
        case USB_CDC_NOTIFY_NETWORK_CONNECTION:
@@ -336,11 +338,10 @@ static void acm_ctrl_irq(struct urb *urb)
                break;
        }
 exit:
-       usb_mark_last_busy(acm->dev);
        retval = usb_submit_urb(urb, GFP_ATOMIC);
        if (retval)
                dev_err(&urb->dev->dev, "%s - usb_submit_urb failed with "
-                       "result %d", __func__, retval);
+                       "result %d\n", __func__, retval);
 }
 
 /* data interface returns incoming bytes, or we got unthrottled */
@@ -354,7 +355,7 @@ static void acm_read_bulk(struct urb *urb)
        dbg("Entering acm_read_bulk with status %d", status);
 
        if (!ACM_READY(acm)) {
-               dev_dbg(&acm->data->dev, "Aborting, acm not ready");
+               dev_dbg(&acm->data->dev, "Aborting, acm not ready\n");
                return;
        }
        usb_mark_last_busy(acm->dev);
@@ -533,6 +534,8 @@ static void acm_softint(struct work_struct *work)
        if (!ACM_READY(acm))
                return;
        tty = tty_port_tty_get(&acm->port);
+       if (!tty)
+               return;
        tty_wakeup(tty);
        tty_kref_put(tty);
 }
@@ -646,8 +649,10 @@ static void acm_port_down(struct acm *acm)
                usb_kill_urb(acm->ctrlurb);
                for (i = 0; i < ACM_NW; i++)
                        usb_kill_urb(acm->wb[i].urb);
+               tasklet_disable(&acm->urb_task);
                for (i = 0; i < nr; i++)
                        usb_kill_urb(acm->ru[i].urb);
+               tasklet_enable(&acm->urb_task);
                acm->control->needs_remote_wakeup = 0;
                usb_autopm_put_interface(acm->control);
        }
@@ -1138,7 +1143,7 @@ made_compressed_probe:
 
        acm = kzalloc(sizeof(struct acm), GFP_KERNEL);
        if (acm == NULL) {
-               dev_dbg(&intf->dev, "out of memory (acm kzalloc)\n");
+               dev_err(&intf->dev, "out of memory (acm kzalloc)\n");
                goto alloc_fail;
        }
 
@@ -1174,19 +1179,19 @@ made_compressed_probe:
 
        buf = usb_alloc_coherent(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);
        if (!buf) {
-               dev_dbg(&intf->dev, "out of memory (ctrl buffer alloc)\n");
+               dev_err(&intf->dev, "out of memory (ctrl buffer alloc)\n");
                goto alloc_fail2;
        }
        acm->ctrl_buffer = buf;
 
        if (acm_write_buffers_alloc(acm) < 0) {
-               dev_dbg(&intf->dev, "out of memory (write buffer alloc)\n");
+               dev_err(&intf->dev, "out of memory (write buffer alloc)\n");
                goto alloc_fail4;
        }
 
        acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL);
        if (!acm->ctrlurb) {
-               dev_dbg(&intf->dev, "out of memory (ctrlurb kmalloc)\n");
+               dev_err(&intf->dev, "out of memory (ctrlurb kmalloc)\n");
                goto alloc_fail5;
        }
        for (i = 0; i < num_rx_buf; i++) {
@@ -1194,7 +1199,7 @@ made_compressed_probe:
 
                rcv->urb = usb_alloc_urb(0, GFP_KERNEL);
                if (rcv->urb == NULL) {
-                       dev_dbg(&intf->dev,
+                       dev_err(&intf->dev,
                                "out of memory (read urbs usb_alloc_urb)\n");
                        goto alloc_fail6;
                }
@@ -1208,7 +1213,7 @@ made_compressed_probe:
                rb->base = usb_alloc_coherent(acm->dev, readsize,
                                GFP_KERNEL, &rb->dma);
                if (!rb->base) {
-                       dev_dbg(&intf->dev,
+                       dev_err(&intf->dev,
                                "out of memory (read bufs usb_alloc_coherent)\n");
                        goto alloc_fail7;
                }
@@ -1218,8 +1223,8 @@ made_compressed_probe:
 
                snd->urb = usb_alloc_urb(0, GFP_KERNEL);
                if (snd->urb == NULL) {
-                       dev_dbg(&intf->dev,
-                               "out of memory (write urbs usb_alloc_urb)");
+                       dev_err(&intf->dev,
+                               "out of memory (write urbs usb_alloc_urb)\n");
                        goto alloc_fail8;
                }