net: use NETDEV_TX_OK instead of 0 in ndo_start_xmit() functions
[linux-2.6-block.git] / drivers / net / irda / irda-usb.c
index 006ba23110dbb0e9247c1f841dd9fc9c0bb502f9..6a1aa7a40fe2f4e807cf463a79cdb970f868ed96 100644 (file)
@@ -389,7 +389,6 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
        s32 speed;
        s16 xbofs;
        int res, mtt;
-       int     err = 1;        /* Failed */
 
        IRDA_DEBUG(4, "%s() on %s\n", __func__, netdev->name);
 
@@ -430,7 +429,6 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
                        irda_usb_change_speed_xbofs(self);
                        netdev->trans_start = jiffies;
                        /* Will netif_wake_queue() in callback */
-                       err = 0;        /* No error */
                        goto drop;
                }
        }
@@ -536,13 +534,13 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
        }
        spin_unlock_irqrestore(&self->lock, flags);
        
-       return 0;
+       return NETDEV_TX_OK;
 
 drop:
        /* Drop silently the skb and exit */
        dev_kfree_skb(skb);
        spin_unlock_irqrestore(&self->lock, flags);
-       return err;             /* Usually 1 */
+       return NETDEV_TX_OK;
 }
 
 /*------------------------------------------------------------------*/
@@ -1859,6 +1857,42 @@ static void irda_usb_disconnect(struct usb_interface *intf)
        IRDA_DEBUG(0, "%s(), USB IrDA Disconnected\n", __func__);
 }
 
+#ifdef CONFIG_PM
+/* USB suspend, so power off the transmitter/receiver */
+static int irda_usb_suspend(struct usb_interface *intf, pm_message_t message)
+{
+       struct irda_usb_cb *self = usb_get_intfdata(intf);
+       int i;
+
+       netif_device_detach(self->netdev);
+
+       if (self->tx_urb != NULL)
+               usb_kill_urb(self->tx_urb);
+       if (self->speed_urb != NULL)
+               usb_kill_urb(self->speed_urb);
+       for (i = 0; i < self->max_rx_urb; i++) {
+               if (self->rx_urb[i] != NULL)
+                       usb_kill_urb(self->rx_urb[i]);
+       }
+       return 0;
+}
+
+/* Coming out of suspend, so reset hardware */
+static int irda_usb_resume(struct usb_interface *intf)
+{
+       struct irda_usb_cb *self = usb_get_intfdata(intf);
+       int i;
+
+       for (i = 0; i < self->max_rx_urb; i++) {
+               if (self->rx_urb[i] != NULL)
+                       usb_submit_urb(self->rx_urb[i], GFP_KERNEL);
+       }
+
+       netif_device_attach(self->netdev);
+       return 0;
+}
+#endif
+
 /*------------------------------------------------------------------*/
 /*
  * USB device callbacks
@@ -1868,6 +1902,10 @@ static struct usb_driver irda_driver = {
        .probe          = irda_usb_probe,
        .disconnect     = irda_usb_disconnect,
        .id_table       = dongles,
+#ifdef CONFIG_PM
+       .suspend        = irda_usb_suspend,
+       .resume         = irda_usb_resume,
+#endif
 };
 
 /************************* MODULE CALLBACKS *************************/