diff options
| -rw-r--r-- | drivers/usb/class/usblp.c | 35 |
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 | ||
| 853 | static 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 | |||
| 865 | static DEVICE_ATTR(ieee1284_id, S_IRUGO, usblp_show_ieee1284_id, NULL); | ||
| 866 | |||
| 853 | static int usblp_probe(struct usb_interface *intf, | 867 | static 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 | ||
| 964 | abort_intfdata: | 978 | abort_intfdata: |
| 965 | usb_set_intfdata (intf, NULL); | 979 | usb_set_intfdata (intf, NULL); |
| 980 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); | ||
| 966 | abort: | 981 | abort: |
| 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; |
