Merge branch 'master' into upstream-fixes
[sfrench/cifs-2.6.git] / drivers / usb / class / usblp.c
index d34848ac30b0a9571db2dd6cd596cdf139b5c8df..a161d70e1e42c3af7800581ec182333739f1ef27 100644 (file)
@@ -55,6 +55,7 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/lp.h>
+#include <linux/mutex.h>
 #undef DEBUG
 #include <linux/usb.h>
 
@@ -223,7 +224,7 @@ static int usblp_cache_device_id_string(struct usblp *usblp);
 
 /* forward reference to make our lives easier */
 static struct usb_driver usblp_driver;
-static DECLARE_MUTEX(usblp_sem);       /* locks the existence of usblp's */
+static DEFINE_MUTEX(usblp_mutex);      /* locks the existence of usblp's */
 
 /*
  * Functions for usblp control messages.
@@ -270,7 +271,7 @@ static int proto_bias = -1;
  * URB callback.
  */
 
-static void usblp_bulk_read(struct urb *urb, struct pt_regs *regs)
+static void usblp_bulk_read(struct urb *urb)
 {
        struct usblp *usblp = urb->context;
 
@@ -287,7 +288,7 @@ unplug:
        wake_up_interruptible(&usblp->wait);
 }
 
-static void usblp_bulk_write(struct urb *urb, struct pt_regs *regs)
+static void usblp_bulk_write(struct urb *urb)
 {
        struct usblp *usblp = urb->context;
 
@@ -351,7 +352,7 @@ static int usblp_open(struct inode *inode, struct file *file)
        if (minor < 0)
                return -ENODEV;
 
-       down (&usblp_sem);
+       mutex_lock (&usblp_mutex);
 
        retval = -ENODEV;
        intf = usb_find_interface(&usblp_driver, minor);
@@ -399,7 +400,7 @@ static int usblp_open(struct inode *inode, struct file *file)
                }
        }
 out:
-       up (&usblp_sem);
+       mutex_unlock (&usblp_mutex);
        return retval;
 }
 
@@ -425,13 +426,13 @@ static int usblp_release(struct inode *inode, struct file *file)
 {
        struct usblp *usblp = file->private_data;
 
-       down (&usblp_sem);
+       mutex_lock (&usblp_mutex);
        usblp->used = 0;
        if (usblp->present) {
                usblp_unlink_urbs(usblp);
        } else          /* finish cleanup from disconnect */
                usblp_cleanup (usblp);
-       up (&usblp_sem);
+       mutex_unlock (&usblp_mutex);
        return 0;
 }
 
@@ -812,7 +813,7 @@ static unsigned int usblp_quirks (__u16 vendor, __u16 product)
        return 0;
 }
 
-static struct file_operations usblp_fops = {
+static const struct file_operations usblp_fops = {
        .owner =        THIS_MODULE,
        .read =         usblp_read,
        .write =        usblp_write,
@@ -926,7 +927,9 @@ static int usblp_probe(struct usb_interface *intf,
 
        /* Retrieve and store the device ID string. */
        usblp_cache_device_id_string(usblp);
-       device_create_file(&intf->dev, &dev_attr_ieee1284_id);
+       retval = device_create_file(&intf->dev, &dev_attr_ieee1284_id);
+       if (retval)
+               goto abort_intfdata;
 
 #ifdef DEBUG
        usblp_check_status(usblp, 0);
@@ -1020,18 +1023,13 @@ static int usblp_select_alts(struct usblp *usblp)
                for (e = 0; e < ifd->desc.bNumEndpoints; e++) {
                        epd = &ifd->endpoint[e].desc;
 
-                       if ((epd->bmAttributes&USB_ENDPOINT_XFERTYPE_MASK)!=
-                           USB_ENDPOINT_XFER_BULK)
-                               continue;
-
-                       if (!(epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK)) {
+                       if (usb_endpoint_is_bulk_out(epd))
                                if (!epwrite)
                                        epwrite = epd;
 
-                       } else {
+                       if (usb_endpoint_is_bulk_in(epd))
                                if (!epread)
                                        epread = epd;
-                       }
                }
 
                /* Ignore buggy hardware without the right endpoints. */
@@ -1152,7 +1150,7 @@ static void usblp_disconnect(struct usb_interface *intf)
 
        device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
 
-       down (&usblp_sem);
+       mutex_lock (&usblp_mutex);
        down (&usblp->sem);
        usblp->present = 0;
        usb_set_intfdata (intf, NULL);
@@ -1166,7 +1164,7 @@ static void usblp_disconnect(struct usb_interface *intf)
 
        if (!usblp->used)
                usblp_cleanup (usblp);
-       up (&usblp_sem);
+       mutex_unlock (&usblp_mutex);
 }
 
 static struct usb_device_id usblp_ids [] = {