aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2005-12-23 11:41:41 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-04 16:51:44 -0500
commita9714c845c0681a203a9ae22aa5165ec72c51d33 (patch)
treef08697d81eca4e6e877b0d3d3561f7f8bf8111e7 /drivers/usb
parent318e479eb7ad9a948c6da381976d258464413816 (diff)
[PATCH] USB: Export IEEE-1284 device id in sysfs for usblp devices
I looked at the userspace code which uses the LPIOC_GET_DEVICE_ID ioctl and I almost went blind. Let's export it in sysfs instead, and just as a string instead of with a big-endian length at the beginning of it. This also prints the message about finding the printer _after_ we know the minor device number it's going to have, rather than reporting all printers as 'usblp0'. Signed-off-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/class/usblp.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 708a292e5a0d..27e9404547f3 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -850,6 +850,20 @@ static struct usb_class_driver usblp_class = {
850 .minor_base = USBLP_MINOR_BASE, 850 .minor_base = USBLP_MINOR_BASE,
851}; 851};
852 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
853static int usblp_probe(struct usb_interface *intf, 867static int usblp_probe(struct usb_interface *intf,
854 const struct usb_device_id *id) 868 const struct usb_device_id *id)
855{ 869{
@@ -934,20 +948,12 @@ static int usblp_probe(struct usb_interface *intf,
934 948
935 /* Retrieve and store the device ID string. */ 949 /* Retrieve and store the device ID string. */
936 usblp_cache_device_id_string(usblp); 950 usblp_cache_device_id_string(usblp);
951 device_create_file(&intf->dev, &dev_attr_ieee1284_id);
937 952
938#ifdef DEBUG 953#ifdef DEBUG
939 usblp_check_status(usblp, 0); 954 usblp_check_status(usblp, 0);
940#endif 955#endif
941 956
942 info("usblp%d: USB %sdirectional printer dev %d "
943 "if %d alt %d proto %d vid 0x%4.4X pid 0x%4.4X",
944 usblp->minor, usblp->bidir ? "Bi" : "Uni", dev->devnum,
945 usblp->ifnum,
946 usblp->protocol[usblp->current_protocol].alt_setting,
947 usblp->current_protocol,
948 le16_to_cpu(usblp->dev->descriptor.idVendor),
949 le16_to_cpu(usblp->dev->descriptor.idProduct));
950
951 usb_set_intfdata (intf, usblp); 957 usb_set_intfdata (intf, usblp);
952 958
953 usblp->present = 1; 959 usblp->present = 1;
@@ -958,11 +964,20 @@ static int usblp_probe(struct usb_interface *intf,
958 goto abort_intfdata; 964 goto abort_intfdata;
959 } 965 }
960 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));
961 975
962 return 0; 976 return 0;
963 977
964abort_intfdata: 978abort_intfdata:
965 usb_set_intfdata (intf, NULL); 979 usb_set_intfdata (intf, NULL);
980 device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
966abort: 981abort:
967 if (usblp) { 982 if (usblp) {
968 if (usblp->writebuf) 983 if (usblp->writebuf)
@@ -1157,6 +1172,8 @@ static void usblp_disconnect(struct usb_interface *intf)
1157 BUG (); 1172 BUG ();
1158 } 1173 }
1159 1174
1175 device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
1176
1160 down (&usblp_sem); 1177 down (&usblp_sem);
1161 down (&usblp->sem); 1178 down (&usblp->sem);
1162 usblp->present = 0; 1179 usblp->present = 0;