Pull asus into release branch
[pandora-kernel.git] / drivers / usb / class / usblp.c
index 24ee8be..6584cf0 100644 (file)
@@ -202,6 +202,7 @@ struct quirk_printer_struct {
 
 #define USBLP_QUIRK_BIDIR      0x1     /* reports bidir but requires unidirectional mode (no INs/reads) */
 #define USBLP_QUIRK_USB_INIT   0x2     /* needs vendor USB init string */
+#define USBLP_QUIRK_BAD_CLASS  0x4     /* descriptor uses vendor-specific Class or SubClass */
 
 static const struct quirk_printer_struct quirk_printers[] = {
        { 0x03f0, 0x0004, USBLP_QUIRK_BIDIR }, /* HP DeskJet 895C */
@@ -217,6 +218,8 @@ static const struct quirk_printer_struct quirk_printers[] = {
        { 0x0409, 0xbef4, USBLP_QUIRK_BIDIR }, /* NEC Picty760 (HP OEM) */
        { 0x0409, 0xf0be, USBLP_QUIRK_BIDIR }, /* NEC Picty920 (HP OEM) */
        { 0x0409, 0xf1be, USBLP_QUIRK_BIDIR }, /* NEC Picty800 (HP OEM) */
+       { 0x0482, 0x0010, USBLP_QUIRK_BIDIR }, /* Kyocera Mita FS 820, by zut <kernel@zut.de> */
+       { 0x04b8, 0x0202, USBLP_QUIRK_BAD_CLASS }, /* Seiko Epson Receipt Printer M129C */
        { 0, 0 }
 };
 
@@ -397,6 +400,9 @@ static int usblp_open(struct inode *inode, struct file *file)
        retval = 0;
 #endif
 
+       retval = usb_autopm_get_interface(intf);
+       if (retval < 0)
+               goto out;
        usblp->used = 1;
        file->private_data = usblp;
 
@@ -441,6 +447,7 @@ static int usblp_release(struct inode *inode, struct file *file)
        usblp->used = 0;
        if (usblp->present) {
                usblp_unlink_urbs(usblp);
+               usb_autopm_put_interface(usblp->intf);
        } else          /* finish cleanup from disconnect */
                usblp_cleanup (usblp);
        mutex_unlock (&usblp_mutex);
@@ -1043,7 +1050,8 @@ static int usblp_select_alts(struct usblp *usblp)
                ifd = &if_alt->altsetting[i];
 
                if (ifd->desc.bInterfaceClass != 7 || ifd->desc.bInterfaceSubClass != 1)
-                       continue;
+                       if (!(usblp->quirks & USBLP_QUIRK_BAD_CLASS))
+                               continue;
 
                if (ifd->desc.bInterfaceProtocol < USBLP_FIRST_PROTOCOL ||
                    ifd->desc.bInterfaceProtocol > USBLP_LAST_PROTOCOL)
@@ -1202,14 +1210,9 @@ static int usblp_suspend (struct usb_interface *intf, pm_message_t message)
 {
        struct usblp *usblp = usb_get_intfdata (intf);
 
-       /* this races against normal access and open */
-       mutex_lock (&usblp_mutex);
-       mutex_lock (&usblp->mut);
        /* we take no more IO */
        usblp->sleeping = 1;
        usblp_unlink_urbs(usblp);
-       mutex_unlock (&usblp->mut);
-       mutex_unlock (&usblp_mutex);
 
        return 0;
 }
@@ -1219,15 +1222,9 @@ static int usblp_resume (struct usb_interface *intf)
        struct usblp *usblp = usb_get_intfdata (intf);
        int r;
 
-       mutex_lock (&usblp_mutex);
-       mutex_lock (&usblp->mut);
-
        usblp->sleeping = 0;
        r = handle_bidir (usblp);
 
-       mutex_unlock (&usblp->mut);
-       mutex_unlock (&usblp_mutex);
-
        return r;
 }
 
@@ -1238,6 +1235,7 @@ static struct usb_device_id usblp_ids [] = {
        { USB_INTERFACE_INFO(7, 1, 1) },
        { USB_INTERFACE_INFO(7, 1, 2) },
        { USB_INTERFACE_INFO(7, 1, 3) },
+       { USB_DEVICE(0x04b8, 0x0202) }, /* Seiko Epson Receipt Printer M129C */
        { }                                             /* Terminating entry */
 };
 
@@ -1250,6 +1248,7 @@ static struct usb_driver usblp_driver = {
        .suspend =      usblp_suspend,
        .resume =       usblp_resume,
        .id_table =     usblp_ids,
+       .supports_autosuspend = 1,
 };
 
 static int __init usblp_init(void)