]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/irda/irda-usb.c
drivers/net/wan: Add missing "space"
[linux-2.6-omap-h63xx.git] / drivers / net / irda / irda-usb.c
index 0ac240ca905b8504d7a9524e532c0a6f5e504608..9081234ab45815c497b8a8a11fdc3a40e2863be5 100644 (file)
@@ -1168,6 +1168,7 @@ static int stir421x_patch_device(struct irda_usb_cb *self)
 static int irda_usb_net_open(struct net_device *netdev)
 {
        struct irda_usb_cb *self;
+       unsigned long flags;
        char    hwname[16];
        int i;
        
@@ -1177,13 +1178,16 @@ static int irda_usb_net_open(struct net_device *netdev)
        self = (struct irda_usb_cb *) netdev->priv;
        IRDA_ASSERT(self != NULL, return -1;);
 
+       spin_lock_irqsave(&self->lock, flags);
        /* Can only open the device if it's there */
        if(!self->present) {
+               spin_unlock_irqrestore(&self->lock, flags);
                IRDA_WARNING("%s(), device not present!\n", __FUNCTION__);
                return -1;
        }
 
        if(self->needspatch) {
+               spin_unlock_irqrestore(&self->lock, flags);
                IRDA_WARNING("%s(), device needs patch\n", __FUNCTION__) ;
                return -EIO ;
        }
@@ -1198,6 +1202,7 @@ static int irda_usb_net_open(struct net_device *netdev)
        /* To do *before* submitting Rx urbs and starting net Tx queue
         * Jean II */
        self->netopen = 1;
+       spin_unlock_irqrestore(&self->lock, flags);
 
        /* 
         * Now that everything should be initialized properly,
@@ -1561,10 +1566,9 @@ static inline struct irda_class_desc *irda_usb_find_class_desc(struct usb_interf
        struct irda_class_desc *desc;
        int ret;
 
-       desc = kmalloc(sizeof (*desc), GFP_KERNEL);
-       if (desc == NULL) 
+       desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+       if (!desc)
                return NULL;
-       memset(desc, 0, sizeof(*desc));
 
        /* USB-IrDA class spec 1.0:
         *      6.1.3: Standard "Get Descriptor" Device Request is not
@@ -1617,7 +1621,7 @@ static int irda_usb_probe(struct usb_interface *intf,
 {
        struct net_device *net;
        struct usb_device *dev = interface_to_usbdev(intf);
-       struct irda_usb_cb *self = NULL;
+       struct irda_usb_cb *self;
        struct usb_host_interface *interface;
        struct irda_class_desc *irda_desc;
        int ret = -ENOMEM;
@@ -1636,7 +1640,6 @@ static int irda_usb_probe(struct usb_interface *intf,
        if (!net) 
                goto err_out;
 
-       SET_MODULE_OWNER(net);
        SET_NETDEV_DEV(net, &intf->dev);
        self = net->priv;
        self->netdev = net;
@@ -1655,7 +1658,7 @@ static int irda_usb_probe(struct usb_interface *intf,
                self->header_length = USB_IRDA_HEADER;
        }
 
-       self->rx_urb = kzalloc(self->max_rx_urb * sizeof(struct urb *),
+       self->rx_urb = kcalloc(self->max_rx_urb, sizeof(struct urb *),
                                GFP_KERNEL);
 
        for (i = 0; i < self->max_rx_urb; i++) {
@@ -1715,7 +1718,7 @@ static int irda_usb_probe(struct usb_interface *intf,
        /* Find IrDA class descriptor */
        irda_desc = irda_usb_find_class_desc(intf);
        ret = -ENODEV;
-       if (irda_desc == NULL)
+       if (!irda_desc)
                goto err_out_3;
 
        if (self->needspatch) {
@@ -1738,15 +1741,13 @@ static int irda_usb_probe(struct usb_interface *intf,
        /* Don't change this buffer size and allocation without doing
         * some heavy and complete testing. Don't ask why :-(
         * Jean II */
-       self->speed_buff = kmalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL);
-       if (self->speed_buff == NULL) 
+       self->speed_buff = kzalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL);
+       if (!self->speed_buff)
                goto err_out_3;
 
-       memset(self->speed_buff, 0, IRDA_USB_SPEED_MTU);
-
        self->tx_buff = kzalloc(IRDA_SKB_MAX_MTU + self->header_length,
                                GFP_KERNEL);
-       if (self->tx_buff == NULL)
+       if (!self->tx_buff)
                goto err_out_4;
 
        ret = irda_usb_open(self);
@@ -1767,12 +1768,11 @@ static int irda_usb_probe(struct usb_interface *intf,
 
                /* replace IrDA class descriptor with what patched device is now reporting */
                irda_desc = irda_usb_find_class_desc (self->usbintf);
-               if (irda_desc == NULL) {
+               if (!irda_desc) {
                        ret = -ENODEV;
                        goto err_out_6;
                }
-               if (self->irda_desc)
-                       kfree (self->irda_desc);
+               kfree(self->irda_desc);
                self->irda_desc = irda_desc;
                irda_usb_init_qos(self);
        }