aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/class/usblp.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/class/usblp.c')
-rw-r--r--drivers/usb/class/usblp.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 38f905db0d6a..dba4cc026077 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -199,7 +199,7 @@ struct quirk_printer_struct {
199#define USBLP_QUIRK_BIDIR 0x1 /* reports bidir but requires unidirectional mode (no INs/reads) */ 199#define USBLP_QUIRK_BIDIR 0x1 /* reports bidir but requires unidirectional mode (no INs/reads) */
200#define USBLP_QUIRK_USB_INIT 0x2 /* needs vendor USB init string */ 200#define USBLP_QUIRK_USB_INIT 0x2 /* needs vendor USB init string */
201 201
202static struct quirk_printer_struct quirk_printers[] = { 202static const struct quirk_printer_struct quirk_printers[] = {
203 { 0x03f0, 0x0004, USBLP_QUIRK_BIDIR }, /* HP DeskJet 895C */ 203 { 0x03f0, 0x0004, USBLP_QUIRK_BIDIR }, /* HP DeskJet 895C */
204 { 0x03f0, 0x0104, USBLP_QUIRK_BIDIR }, /* HP DeskJet 880C */ 204 { 0x03f0, 0x0104, USBLP_QUIRK_BIDIR }, /* HP DeskJet 880C */
205 { 0x03f0, 0x0204, USBLP_QUIRK_BIDIR }, /* HP DeskJet 815C */ 205 { 0x03f0, 0x0204, USBLP_QUIRK_BIDIR }, /* HP DeskJet 815C */
@@ -301,7 +301,7 @@ static void usblp_bulk_write(struct urb *urb, struct pt_regs *regs)
301 * Get and print printer errors. 301 * Get and print printer errors.
302 */ 302 */
303 303
304static char *usblp_messages[] = { "ok", "out of paper", "off-line", "on fire" }; 304static const char *usblp_messages[] = { "ok", "out of paper", "off-line", "on fire" };
305 305
306static int usblp_check_status(struct usblp *usblp, int err) 306static int usblp_check_status(struct usblp *usblp, int err)
307{ 307{
@@ -438,7 +438,7 @@ static unsigned int usblp_poll(struct file *file, struct poll_table_struct *wait
438 | (!usblp->wcomplete ? 0 : POLLOUT | POLLWRNORM); 438 | (!usblp->wcomplete ? 0 : POLLOUT | POLLWRNORM);
439} 439}
440 440
441static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 441static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
442{ 442{
443 struct usblp *usblp = file->private_data; 443 struct usblp *usblp = file->private_data;
444 int length, err, i; 444 int length, err, i;
@@ -838,7 +838,8 @@ static struct file_operations usblp_fops = {
838 .read = usblp_read, 838 .read = usblp_read,
839 .write = usblp_write, 839 .write = usblp_write,
840 .poll = usblp_poll, 840 .poll = usblp_poll,
841 .ioctl = usblp_ioctl, 841 .unlocked_ioctl = usblp_ioctl,
842 .compat_ioctl = usblp_ioctl,
842 .open = usblp_open, 843 .open = usblp_open,
843 .release = usblp_release, 844 .release = usblp_release,
844}; 845};
@@ -849,6 +850,20 @@ static struct usb_class_driver usblp_class = {
849 .minor_base = USBLP_MINOR_BASE, 850 .minor_base = USBLP_MINOR_BASE,
850}; 851};
851 852
853static ssize_t usblp_show_ieee1284_id(struct device *dev, struct device_attribute *attr, char *buf)
854{
855 struct usb_interface *intf = to_usb_interface(dev);
856 struct usblp *usblp = usb_get_intfdata (intf);
857
858 if (usblp->device_id_string[0] == 0 &&
859 usblp->device_id_string[1] == 0)
860 return 0;
861
862 return sprintf(buf, "%s", usblp->device_id_string+2);
863}
864
865static DEVICE_ATTR(ieee1284_id, S_IRUGO, usblp_show_ieee1284_id, NULL);
866
852static int usblp_probe(struct usb_interface *intf, 867static int usblp_probe(struct usb_interface *intf,
853 const struct usb_device_id *id) 868 const struct usb_device_id *id)
854{ 869{
@@ -933,20 +948,12 @@ static int usblp_probe(struct usb_interface *intf,
933 948
934 /* Retrieve and store the device ID string. */ 949 /* Retrieve and store the device ID string. */
935 usblp_cache_device_id_string(usblp); 950 usblp_cache_device_id_string(usblp);
951 device_create_file(&intf->dev, &dev_attr_ieee1284_id);
936 952
937#ifdef DEBUG 953#ifdef DEBUG
938 usblp_check_status(usblp, 0); 954 usblp_check_status(usblp, 0);
939#endif 955#endif
940 956
941 info("usblp%d: USB %sdirectional printer dev %d "
942 "if %d alt %d proto %d vid 0x%4.4X pid 0x%4.4X",
943 usblp->minor, usblp->bidir ? "Bi" : "Uni", dev->devnum,
944 usblp->ifnum,
945 usblp->protocol[usblp->current_protocol].alt_setting,
946 usblp->current_protocol,
947 le16_to_cpu(usblp->dev->descriptor.idVendor),
948 le16_to_cpu(usblp->dev->descriptor.idProduct));
949
950 usb_set_intfdata (intf, usblp); 957 usb_set_intfdata (intf, usblp);
951 958
952 usblp->present = 1; 959 usblp->present = 1;
@@ -957,11 +964,20 @@ static int usblp_probe(struct usb_interface *intf,
957 goto abort_intfdata; 964 goto abort_intfdata;
958 } 965 }
959 usblp->minor = intf->minor; 966 usblp->minor = intf->minor;
967 info("usblp%d: USB %sdirectional printer dev %d "
968 "if %d alt %d proto %d vid 0x%4.4X pid 0x%4.4X",
969 usblp->minor, usblp->bidir ? "Bi" : "Uni", dev->devnum,
970 usblp->ifnum,
971 usblp->protocol[usblp->current_protocol].alt_setting,
972 usblp->current_protocol,
973 le16_to_cpu(usblp->dev->descriptor.idVendor),
974 le16_to_cpu(usblp->dev->descriptor.idProduct));
960 975
961 return 0; 976 return 0;
962 977
963abort_intfdata: 978abort_intfdata:
964 usb_set_intfdata (intf, NULL); 979 usb_set_intfdata (intf, NULL);
980 device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
965abort: 981abort:
966 if (usblp) { 982 if (usblp) {
967 if (usblp->writebuf) 983 if (usblp->writebuf)
@@ -1156,6 +1172,8 @@ static void usblp_disconnect(struct usb_interface *intf)
1156 BUG (); 1172 BUG ();
1157 } 1173 }
1158 1174
1175 device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
1176
1159 down (&usblp_sem); 1177 down (&usblp_sem);
1160 down (&usblp->sem); 1178 down (&usblp->sem);
1161 usblp->present = 0; 1179 usblp->present = 0;
@@ -1186,7 +1204,6 @@ static struct usb_device_id usblp_ids [] = {
1186MODULE_DEVICE_TABLE (usb, usblp_ids); 1204MODULE_DEVICE_TABLE (usb, usblp_ids);
1187 1205
1188static struct usb_driver usblp_driver = { 1206static struct usb_driver usblp_driver = {
1189 .owner = THIS_MODULE,
1190 .name = "usblp", 1207 .name = "usblp",
1191 .probe = usblp_probe, 1208 .probe = usblp_probe,
1192 .disconnect = usblp_disconnect, 1209 .disconnect = usblp_disconnect,