diff options
Diffstat (limited to 'drivers/usb/core')
| -rw-r--r-- | drivers/usb/core/devices.c | 2 | ||||
| -rw-r--r-- | drivers/usb/core/file.c | 13 | ||||
| -rw-r--r-- | drivers/usb/core/hcd.c | 63 | ||||
| -rw-r--r-- | drivers/usb/core/hcd.h | 2 | ||||
| -rw-r--r-- | drivers/usb/core/hub.c | 2 | ||||
| -rw-r--r-- | drivers/usb/core/inode.c | 13 | ||||
| -rw-r--r-- | drivers/usb/core/sysfs.c | 48 | ||||
| -rw-r--r-- | drivers/usb/core/usb.c | 53 |
8 files changed, 94 insertions, 102 deletions
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index ef0b35731ff0..83e815d3cd52 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c | |||
| @@ -239,7 +239,7 @@ static char *usb_dump_interface_descriptor(char *start, char *end, | |||
| 239 | int setno) | 239 | int setno) |
| 240 | { | 240 | { |
| 241 | const struct usb_interface_descriptor *desc = &intfc->altsetting[setno].desc; | 241 | const struct usb_interface_descriptor *desc = &intfc->altsetting[setno].desc; |
| 242 | char *driver_name = ""; | 242 | const char *driver_name = ""; |
| 243 | 243 | ||
| 244 | if (start > end) | 244 | if (start > end) |
| 245 | return start; | 245 | return start; |
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 38ed2220c9fc..65ca131cc44c 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
| @@ -68,7 +68,7 @@ static struct file_operations usb_fops = { | |||
| 68 | .open = usb_open, | 68 | .open = usb_open, |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | static struct class_simple *usb_class; | 71 | static struct class *usb_class; |
| 72 | 72 | ||
| 73 | int usb_major_init(void) | 73 | int usb_major_init(void) |
| 74 | { | 74 | { |
| @@ -80,9 +80,10 @@ int usb_major_init(void) | |||
| 80 | goto out; | 80 | goto out; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | usb_class = class_simple_create(THIS_MODULE, "usb"); | 83 | usb_class = class_create(THIS_MODULE, "usb"); |
| 84 | if (IS_ERR(usb_class)) { | 84 | if (IS_ERR(usb_class)) { |
| 85 | err("class_simple_create failed for usb devices"); | 85 | error = PTR_ERR(usb_class); |
| 86 | err("class_create failed for usb devices"); | ||
| 86 | unregister_chrdev(USB_MAJOR, "usb"); | 87 | unregister_chrdev(USB_MAJOR, "usb"); |
| 87 | goto out; | 88 | goto out; |
| 88 | } | 89 | } |
| @@ -95,7 +96,7 @@ out: | |||
| 95 | 96 | ||
| 96 | void usb_major_cleanup(void) | 97 | void usb_major_cleanup(void) |
| 97 | { | 98 | { |
| 98 | class_simple_destroy(usb_class); | 99 | class_destroy(usb_class); |
| 99 | devfs_remove("usb"); | 100 | devfs_remove("usb"); |
| 100 | unregister_chrdev(USB_MAJOR, "usb"); | 101 | unregister_chrdev(USB_MAJOR, "usb"); |
| 101 | } | 102 | } |
| @@ -171,7 +172,7 @@ int usb_register_dev(struct usb_interface *intf, | |||
| 171 | ++temp; | 172 | ++temp; |
| 172 | else | 173 | else |
| 173 | temp = name; | 174 | temp = name; |
| 174 | intf->class_dev = class_simple_device_add(usb_class, MKDEV(USB_MAJOR, minor), &intf->dev, "%s", temp); | 175 | intf->class_dev = class_device_create(usb_class, MKDEV(USB_MAJOR, minor), &intf->dev, "%s", temp); |
| 175 | if (IS_ERR(intf->class_dev)) { | 176 | if (IS_ERR(intf->class_dev)) { |
| 176 | spin_lock (&minor_lock); | 177 | spin_lock (&minor_lock); |
| 177 | usb_minors[intf->minor] = NULL; | 178 | usb_minors[intf->minor] = NULL; |
| @@ -220,7 +221,7 @@ void usb_deregister_dev(struct usb_interface *intf, | |||
| 220 | 221 | ||
| 221 | snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base); | 222 | snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base); |
| 222 | devfs_remove (name); | 223 | devfs_remove (name); |
| 223 | class_simple_device_remove(MKDEV(USB_MAJOR, intf->minor)); | 224 | class_device_destroy(usb_class, MKDEV(USB_MAJOR, intf->minor)); |
| 224 | intf->class_dev = NULL; | 225 | intf->class_dev = NULL; |
| 225 | intf->minor = -1; | 226 | intf->minor = -1; |
| 226 | } | 227 | } |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 266e9e06a9f5..0da23732e807 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
| @@ -651,50 +651,45 @@ static int usb_rh_urb_dequeue (struct usb_hcd *hcd, struct urb *urb) | |||
| 651 | /*-------------------------------------------------------------------------*/ | 651 | /*-------------------------------------------------------------------------*/ |
| 652 | 652 | ||
| 653 | /* exported only within usbcore */ | 653 | /* exported only within usbcore */ |
| 654 | struct usb_bus *usb_bus_get (struct usb_bus *bus) | 654 | struct usb_bus *usb_bus_get(struct usb_bus *bus) |
| 655 | { | 655 | { |
| 656 | struct class_device *tmp; | 656 | if (bus) |
| 657 | kref_get(&bus->kref); | ||
| 658 | return bus; | ||
| 659 | } | ||
| 657 | 660 | ||
| 658 | if (!bus) | 661 | static void usb_host_release(struct kref *kref) |
| 659 | return NULL; | 662 | { |
| 663 | struct usb_bus *bus = container_of(kref, struct usb_bus, kref); | ||
| 660 | 664 | ||
| 661 | tmp = class_device_get(&bus->class_dev); | 665 | if (bus->release) |
| 662 | if (tmp) | 666 | bus->release(bus); |
| 663 | return to_usb_bus(tmp); | ||
| 664 | else | ||
| 665 | return NULL; | ||
| 666 | } | 667 | } |
| 667 | 668 | ||
| 668 | /* exported only within usbcore */ | 669 | /* exported only within usbcore */ |
| 669 | void usb_bus_put (struct usb_bus *bus) | 670 | void usb_bus_put(struct usb_bus *bus) |
| 670 | { | 671 | { |
| 671 | if (bus) | 672 | if (bus) |
| 672 | class_device_put(&bus->class_dev); | 673 | kref_put(&bus->kref, usb_host_release); |
| 673 | } | 674 | } |
| 674 | 675 | ||
| 675 | /*-------------------------------------------------------------------------*/ | 676 | /*-------------------------------------------------------------------------*/ |
| 676 | 677 | ||
| 677 | static void usb_host_release(struct class_device *class_dev) | 678 | static struct class *usb_host_class; |
| 678 | { | ||
| 679 | struct usb_bus *bus = to_usb_bus(class_dev); | ||
| 680 | |||
| 681 | if (bus->release) | ||
| 682 | bus->release(bus); | ||
| 683 | } | ||
| 684 | |||
| 685 | static struct class usb_host_class = { | ||
| 686 | .name = "usb_host", | ||
| 687 | .release = &usb_host_release, | ||
| 688 | }; | ||
| 689 | 679 | ||
| 690 | int usb_host_init(void) | 680 | int usb_host_init(void) |
| 691 | { | 681 | { |
| 692 | return class_register(&usb_host_class); | 682 | int retval = 0; |
| 683 | |||
| 684 | usb_host_class = class_create(THIS_MODULE, "usb_host"); | ||
| 685 | if (IS_ERR(usb_host_class)) | ||
| 686 | retval = PTR_ERR(usb_host_class); | ||
| 687 | return retval; | ||
| 693 | } | 688 | } |
| 694 | 689 | ||
| 695 | void usb_host_cleanup(void) | 690 | void usb_host_cleanup(void) |
| 696 | { | 691 | { |
| 697 | class_unregister(&usb_host_class); | 692 | class_destroy(usb_host_class); |
| 698 | } | 693 | } |
| 699 | 694 | ||
| 700 | /** | 695 | /** |
| @@ -719,8 +714,7 @@ static void usb_bus_init (struct usb_bus *bus) | |||
| 719 | 714 | ||
| 720 | INIT_LIST_HEAD (&bus->bus_list); | 715 | INIT_LIST_HEAD (&bus->bus_list); |
| 721 | 716 | ||
| 722 | class_device_initialize(&bus->class_dev); | 717 | kref_init(&bus->kref); |
| 723 | bus->class_dev.class = &usb_host_class; | ||
| 724 | } | 718 | } |
| 725 | 719 | ||
| 726 | /** | 720 | /** |
| @@ -761,7 +755,6 @@ struct usb_bus *usb_alloc_bus (struct usb_operations *op) | |||
| 761 | static int usb_register_bus(struct usb_bus *bus) | 755 | static int usb_register_bus(struct usb_bus *bus) |
| 762 | { | 756 | { |
| 763 | int busnum; | 757 | int busnum; |
| 764 | int retval; | ||
| 765 | 758 | ||
| 766 | down (&usb_bus_list_lock); | 759 | down (&usb_bus_list_lock); |
| 767 | busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1); | 760 | busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1); |
| @@ -774,15 +767,15 @@ static int usb_register_bus(struct usb_bus *bus) | |||
| 774 | return -E2BIG; | 767 | return -E2BIG; |
| 775 | } | 768 | } |
| 776 | 769 | ||
| 777 | snprintf(bus->class_dev.class_id, BUS_ID_SIZE, "usb%d", busnum); | 770 | bus->class_dev = class_device_create(usb_host_class, MKDEV(0,0), bus->controller, "usb%d", busnum); |
| 778 | bus->class_dev.dev = bus->controller; | 771 | if (IS_ERR(bus->class_dev)) { |
| 779 | retval = class_device_add(&bus->class_dev); | ||
| 780 | if (retval) { | ||
| 781 | clear_bit(busnum, busmap.busmap); | 772 | clear_bit(busnum, busmap.busmap); |
| 782 | up(&usb_bus_list_lock); | 773 | up(&usb_bus_list_lock); |
| 783 | return retval; | 774 | return PTR_ERR(bus->class_dev); |
| 784 | } | 775 | } |
| 785 | 776 | ||
| 777 | class_set_devdata(bus->class_dev, bus); | ||
| 778 | |||
| 786 | /* Add it to the local list of buses */ | 779 | /* Add it to the local list of buses */ |
| 787 | list_add (&bus->bus_list, &usb_bus_list); | 780 | list_add (&bus->bus_list, &usb_bus_list); |
| 788 | up (&usb_bus_list_lock); | 781 | up (&usb_bus_list_lock); |
| @@ -820,7 +813,7 @@ static void usb_deregister_bus (struct usb_bus *bus) | |||
| 820 | 813 | ||
| 821 | clear_bit (bus->busnum, busmap.busmap); | 814 | clear_bit (bus->busnum, busmap.busmap); |
| 822 | 815 | ||
| 823 | class_device_del(&bus->class_dev); | 816 | class_device_unregister(bus->class_dev); |
| 824 | } | 817 | } |
| 825 | 818 | ||
| 826 | /** | 819 | /** |
| @@ -1801,7 +1794,7 @@ EXPORT_SYMBOL (usb_remove_hcd); | |||
| 1801 | 1794 | ||
| 1802 | /*-------------------------------------------------------------------------*/ | 1795 | /*-------------------------------------------------------------------------*/ |
| 1803 | 1796 | ||
| 1804 | #if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE) | 1797 | #if defined(CONFIG_USB_MON) |
| 1805 | 1798 | ||
| 1806 | struct usb_mon_operations *mon_ops; | 1799 | struct usb_mon_operations *mon_ops; |
| 1807 | 1800 | ||
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index f67cf1e634fc..325a51656c3f 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h | |||
| @@ -399,7 +399,7 @@ static inline void usbfs_cleanup(void) { } | |||
| 399 | 399 | ||
| 400 | /*-------------------------------------------------------------------------*/ | 400 | /*-------------------------------------------------------------------------*/ |
| 401 | 401 | ||
| 402 | #if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE) | 402 | #if defined(CONFIG_USB_MON) |
| 403 | 403 | ||
| 404 | struct usb_mon_operations { | 404 | struct usb_mon_operations { |
| 405 | void (*urb_submit)(struct usb_bus *bus, struct urb *urb); | 405 | void (*urb_submit)(struct usb_bus *bus, struct urb *urb); |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index d2d648ee8640..a8d879a85d04 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
| @@ -2808,7 +2808,7 @@ static int hub_thread(void *__unused) | |||
| 2808 | do { | 2808 | do { |
| 2809 | hub_events(); | 2809 | hub_events(); |
| 2810 | wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list)); | 2810 | wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list)); |
| 2811 | try_to_freeze(PF_FREEZE); | 2811 | try_to_freeze(); |
| 2812 | } while (!signal_pending(current)); | 2812 | } while (!signal_pending(current)); |
| 2813 | 2813 | ||
| 2814 | pr_debug ("%s: khubd exiting\n", usbcore_name); | 2814 | pr_debug ("%s: khubd exiting\n", usbcore_name); |
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index f9f9561c6bad..c3e3a95d3804 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c | |||
| @@ -453,17 +453,6 @@ static int usbfs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 453 | return 0; | 453 | return 0; |
| 454 | } | 454 | } |
| 455 | 455 | ||
| 456 | static struct dentry * get_dentry(struct dentry *parent, const char *name) | ||
| 457 | { | ||
| 458 | struct qstr qstr; | ||
| 459 | |||
| 460 | qstr.name = name; | ||
| 461 | qstr.len = strlen(name); | ||
| 462 | qstr.hash = full_name_hash(name,qstr.len); | ||
| 463 | return lookup_hash(&qstr,parent); | ||
| 464 | } | ||
| 465 | |||
| 466 | |||
| 467 | /* | 456 | /* |
| 468 | * fs_create_by_name - create a file, given a name | 457 | * fs_create_by_name - create a file, given a name |
| 469 | * @name: name of file | 458 | * @name: name of file |
| @@ -496,7 +485,7 @@ static int fs_create_by_name (const char *name, mode_t mode, | |||
| 496 | 485 | ||
| 497 | *dentry = NULL; | 486 | *dentry = NULL; |
| 498 | down(&parent->d_inode->i_sem); | 487 | down(&parent->d_inode->i_sem); |
| 499 | *dentry = get_dentry (parent, name); | 488 | *dentry = lookup_one_len(name, parent, strlen(name)); |
| 500 | if (!IS_ERR(dentry)) { | 489 | if (!IS_ERR(dentry)) { |
| 501 | if ((mode & S_IFMT) == S_IFDIR) | 490 | if ((mode & S_IFMT) == S_IFDIR) |
| 502 | error = usbfs_mkdir (parent->d_inode, *dentry, mode); | 491 | error = usbfs_mkdir (parent->d_inode, *dentry, mode); |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 4ab50009291d..740cb4c668df 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | /* Active configuration fields */ | 25 | /* Active configuration fields */ |
| 26 | #define usb_actconfig_show(field, multiplier, format_string) \ | 26 | #define usb_actconfig_show(field, multiplier, format_string) \ |
| 27 | static ssize_t show_##field (struct device *dev, char *buf) \ | 27 | static ssize_t show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 28 | { \ | 28 | { \ |
| 29 | struct usb_device *udev; \ | 29 | struct usb_device *udev; \ |
| 30 | struct usb_host_config *actconfig; \ | 30 | struct usb_host_config *actconfig; \ |
| @@ -46,7 +46,7 @@ usb_actconfig_attr (bNumInterfaces, 1, "%2d\n") | |||
| 46 | usb_actconfig_attr (bmAttributes, 1, "%2x\n") | 46 | usb_actconfig_attr (bmAttributes, 1, "%2x\n") |
| 47 | usb_actconfig_attr (bMaxPower, 2, "%3dmA\n") | 47 | usb_actconfig_attr (bMaxPower, 2, "%3dmA\n") |
| 48 | 48 | ||
| 49 | static ssize_t show_configuration_string(struct device *dev, char *buf) | 49 | static ssize_t show_configuration_string(struct device *dev, struct device_attribute *attr, char *buf) |
| 50 | { | 50 | { |
| 51 | struct usb_device *udev; | 51 | struct usb_device *udev; |
| 52 | struct usb_host_config *actconfig; | 52 | struct usb_host_config *actconfig; |
| @@ -69,7 +69,7 @@ static DEVICE_ATTR(configuration, S_IRUGO, show_configuration_string, NULL); | |||
| 69 | usb_actconfig_show(bConfigurationValue, 1, "%u\n"); | 69 | usb_actconfig_show(bConfigurationValue, 1, "%u\n"); |
| 70 | 70 | ||
| 71 | static ssize_t | 71 | static ssize_t |
| 72 | set_bConfigurationValue (struct device *dev, const char *buf, size_t count) | 72 | set_bConfigurationValue (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
| 73 | { | 73 | { |
| 74 | struct usb_device *udev = udev = to_usb_device (dev); | 74 | struct usb_device *udev = udev = to_usb_device (dev); |
| 75 | int config, value; | 75 | int config, value; |
| @@ -87,7 +87,7 @@ static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR, | |||
| 87 | 87 | ||
| 88 | /* String fields */ | 88 | /* String fields */ |
| 89 | #define usb_string_attr(name) \ | 89 | #define usb_string_attr(name) \ |
| 90 | static ssize_t show_##name(struct device *dev, char *buf) \ | 90 | static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ |
| 91 | { \ | 91 | { \ |
| 92 | struct usb_device *udev; \ | 92 | struct usb_device *udev; \ |
| 93 | int len; \ | 93 | int len; \ |
| @@ -107,7 +107,7 @@ usb_string_attr(manufacturer); | |||
| 107 | usb_string_attr(serial); | 107 | usb_string_attr(serial); |
| 108 | 108 | ||
| 109 | static ssize_t | 109 | static ssize_t |
| 110 | show_speed (struct device *dev, char *buf) | 110 | show_speed (struct device *dev, struct device_attribute *attr, char *buf) |
| 111 | { | 111 | { |
| 112 | struct usb_device *udev; | 112 | struct usb_device *udev; |
| 113 | char *speed; | 113 | char *speed; |
| @@ -133,7 +133,7 @@ show_speed (struct device *dev, char *buf) | |||
| 133 | static DEVICE_ATTR(speed, S_IRUGO, show_speed, NULL); | 133 | static DEVICE_ATTR(speed, S_IRUGO, show_speed, NULL); |
| 134 | 134 | ||
| 135 | static ssize_t | 135 | static ssize_t |
| 136 | show_devnum (struct device *dev, char *buf) | 136 | show_devnum (struct device *dev, struct device_attribute *attr, char *buf) |
| 137 | { | 137 | { |
| 138 | struct usb_device *udev; | 138 | struct usb_device *udev; |
| 139 | 139 | ||
| @@ -143,7 +143,7 @@ show_devnum (struct device *dev, char *buf) | |||
| 143 | static DEVICE_ATTR(devnum, S_IRUGO, show_devnum, NULL); | 143 | static DEVICE_ATTR(devnum, S_IRUGO, show_devnum, NULL); |
| 144 | 144 | ||
| 145 | static ssize_t | 145 | static ssize_t |
| 146 | show_version (struct device *dev, char *buf) | 146 | show_version (struct device *dev, struct device_attribute *attr, char *buf) |
| 147 | { | 147 | { |
| 148 | struct usb_device *udev; | 148 | struct usb_device *udev; |
| 149 | u16 bcdUSB; | 149 | u16 bcdUSB; |
| @@ -155,7 +155,7 @@ show_version (struct device *dev, char *buf) | |||
| 155 | static DEVICE_ATTR(version, S_IRUGO, show_version, NULL); | 155 | static DEVICE_ATTR(version, S_IRUGO, show_version, NULL); |
| 156 | 156 | ||
| 157 | static ssize_t | 157 | static ssize_t |
| 158 | show_maxchild (struct device *dev, char *buf) | 158 | show_maxchild (struct device *dev, struct device_attribute *attr, char *buf) |
| 159 | { | 159 | { |
| 160 | struct usb_device *udev; | 160 | struct usb_device *udev; |
| 161 | 161 | ||
| @@ -167,7 +167,7 @@ static DEVICE_ATTR(maxchild, S_IRUGO, show_maxchild, NULL); | |||
| 167 | /* Descriptor fields */ | 167 | /* Descriptor fields */ |
| 168 | #define usb_descriptor_attr_le16(field, format_string) \ | 168 | #define usb_descriptor_attr_le16(field, format_string) \ |
| 169 | static ssize_t \ | 169 | static ssize_t \ |
| 170 | show_##field (struct device *dev, char *buf) \ | 170 | show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 171 | { \ | 171 | { \ |
| 172 | struct usb_device *udev; \ | 172 | struct usb_device *udev; \ |
| 173 | \ | 173 | \ |
| @@ -183,7 +183,7 @@ usb_descriptor_attr_le16(bcdDevice, "%04x\n") | |||
| 183 | 183 | ||
| 184 | #define usb_descriptor_attr(field, format_string) \ | 184 | #define usb_descriptor_attr(field, format_string) \ |
| 185 | static ssize_t \ | 185 | static ssize_t \ |
| 186 | show_##field (struct device *dev, char *buf) \ | 186 | show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 187 | { \ | 187 | { \ |
| 188 | struct usb_device *udev; \ | 188 | struct usb_device *udev; \ |
| 189 | \ | 189 | \ |
| @@ -254,7 +254,7 @@ void usb_remove_sysfs_dev_files (struct usb_device *udev) | |||
| 254 | /* Interface fields */ | 254 | /* Interface fields */ |
| 255 | #define usb_intf_attr(field, format_string) \ | 255 | #define usb_intf_attr(field, format_string) \ |
| 256 | static ssize_t \ | 256 | static ssize_t \ |
| 257 | show_##field (struct device *dev, char *buf) \ | 257 | show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 258 | { \ | 258 | { \ |
| 259 | struct usb_interface *intf = to_usb_interface (dev); \ | 259 | struct usb_interface *intf = to_usb_interface (dev); \ |
| 260 | \ | 260 | \ |
| @@ -269,7 +269,7 @@ usb_intf_attr (bInterfaceClass, "%02x\n") | |||
| 269 | usb_intf_attr (bInterfaceSubClass, "%02x\n") | 269 | usb_intf_attr (bInterfaceSubClass, "%02x\n") |
| 270 | usb_intf_attr (bInterfaceProtocol, "%02x\n") | 270 | usb_intf_attr (bInterfaceProtocol, "%02x\n") |
| 271 | 271 | ||
| 272 | static ssize_t show_interface_string(struct device *dev, char *buf) | 272 | static ssize_t show_interface_string(struct device *dev, struct device_attribute *attr, char *buf) |
| 273 | { | 273 | { |
| 274 | struct usb_interface *intf; | 274 | struct usb_interface *intf; |
| 275 | struct usb_device *udev; | 275 | struct usb_device *udev; |
| @@ -286,36 +286,34 @@ static ssize_t show_interface_string(struct device *dev, char *buf) | |||
| 286 | } | 286 | } |
| 287 | static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); | 287 | static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); |
| 288 | 288 | ||
| 289 | static ssize_t show_modalias(struct device *dev, char *buf) | 289 | static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf) |
| 290 | { | 290 | { |
| 291 | struct usb_interface *intf; | 291 | struct usb_interface *intf; |
| 292 | struct usb_device *udev; | 292 | struct usb_device *udev; |
| 293 | int len; | ||
| 293 | 294 | ||
| 294 | intf = to_usb_interface(dev); | 295 | intf = to_usb_interface(dev); |
| 295 | udev = interface_to_usbdev(intf); | 296 | udev = interface_to_usbdev(intf); |
| 296 | if (udev->descriptor.bDeviceClass == 0) { | ||
| 297 | struct usb_host_interface *alt = intf->cur_altsetting; | ||
| 298 | 297 | ||
| 299 | return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X\n", | 298 | len = sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic", |
| 300 | le16_to_cpu(udev->descriptor.idVendor), | 299 | le16_to_cpu(udev->descriptor.idVendor), |
| 301 | le16_to_cpu(udev->descriptor.idProduct), | 300 | le16_to_cpu(udev->descriptor.idProduct), |
| 302 | le16_to_cpu(udev->descriptor.bcdDevice), | 301 | le16_to_cpu(udev->descriptor.bcdDevice), |
| 303 | udev->descriptor.bDeviceClass, | 302 | udev->descriptor.bDeviceClass, |
| 304 | udev->descriptor.bDeviceSubClass, | 303 | udev->descriptor.bDeviceSubClass, |
| 305 | udev->descriptor.bDeviceProtocol, | 304 | udev->descriptor.bDeviceProtocol); |
| 305 | buf += len; | ||
| 306 | |||
| 307 | if (udev->descriptor.bDeviceClass == 0) { | ||
| 308 | struct usb_host_interface *alt = intf->cur_altsetting; | ||
| 309 | |||
| 310 | return len + sprintf(buf, "%02Xisc%02Xip%02X\n", | ||
| 306 | alt->desc.bInterfaceClass, | 311 | alt->desc.bInterfaceClass, |
| 307 | alt->desc.bInterfaceSubClass, | 312 | alt->desc.bInterfaceSubClass, |
| 308 | alt->desc.bInterfaceProtocol); | 313 | alt->desc.bInterfaceProtocol); |
| 309 | } else { | 314 | } else { |
| 310 | return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*\n", | 315 | return len + sprintf(buf, "*isc*ip*\n"); |
| 311 | le16_to_cpu(udev->descriptor.idVendor), | ||
| 312 | le16_to_cpu(udev->descriptor.idProduct), | ||
| 313 | le16_to_cpu(udev->descriptor.bcdDevice), | ||
| 314 | udev->descriptor.bDeviceClass, | ||
| 315 | udev->descriptor.bDeviceSubClass, | ||
| 316 | udev->descriptor.bDeviceProtocol); | ||
| 317 | } | 316 | } |
| 318 | |||
| 319 | } | 317 | } |
| 320 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); | 318 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); |
| 321 | 319 | ||
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 25cf7e9eccfa..a3c42203213a 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
| @@ -293,7 +293,7 @@ int usb_driver_claim_interface(struct usb_driver *driver, | |||
| 293 | /* if interface was already added, bind now; else let | 293 | /* if interface was already added, bind now; else let |
| 294 | * the future device_add() bind it, bypassing probe() | 294 | * the future device_add() bind it, bypassing probe() |
| 295 | */ | 295 | */ |
| 296 | if (!list_empty (&dev->bus_list)) | 296 | if (klist_node_attached(&dev->knode_bus)) |
| 297 | device_bind_driver(dev); | 297 | device_bind_driver(dev); |
| 298 | 298 | ||
| 299 | return 0; | 299 | return 0; |
| @@ -322,9 +322,15 @@ void usb_driver_release_interface(struct usb_driver *driver, | |||
| 322 | if (!dev->driver || dev->driver != &driver->driver) | 322 | if (!dev->driver || dev->driver != &driver->driver) |
| 323 | return; | 323 | return; |
| 324 | 324 | ||
| 325 | /* don't disconnect from disconnect(), or before dev_add() */ | 325 | /* don't release from within disconnect() */ |
| 326 | if (!list_empty (&dev->driver_list) && !list_empty (&dev->bus_list)) | 326 | if (iface->condition != USB_INTERFACE_BOUND) |
| 327 | return; | ||
| 328 | |||
| 329 | /* release only after device_add() */ | ||
| 330 | if (klist_node_attached(&dev->knode_bus)) { | ||
| 331 | iface->condition = USB_INTERFACE_UNBINDING; | ||
| 327 | device_release_driver(dev); | 332 | device_release_driver(dev); |
| 333 | } | ||
| 328 | 334 | ||
| 329 | dev->driver = NULL; | 335 | dev->driver = NULL; |
| 330 | usb_set_intfdata(iface, NULL); | 336 | usb_set_intfdata(iface, NULL); |
| @@ -462,6 +468,25 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id) | |||
| 462 | return NULL; | 468 | return NULL; |
| 463 | } | 469 | } |
| 464 | 470 | ||
| 471 | |||
| 472 | static int __find_interface(struct device * dev, void * data) | ||
| 473 | { | ||
| 474 | struct usb_interface ** ret = (struct usb_interface **)data; | ||
| 475 | struct usb_interface * intf = *ret; | ||
| 476 | int *minor = (int *)data; | ||
| 477 | |||
| 478 | /* can't look at usb devices, only interfaces */ | ||
| 479 | if (dev->driver == &usb_generic_driver) | ||
| 480 | return 0; | ||
| 481 | |||
| 482 | intf = to_usb_interface(dev); | ||
| 483 | if (intf->minor != -1 && intf->minor == *minor) { | ||
| 484 | *ret = intf; | ||
| 485 | return 1; | ||
| 486 | } | ||
| 487 | return 0; | ||
| 488 | } | ||
| 489 | |||
| 465 | /** | 490 | /** |
| 466 | * usb_find_interface - find usb_interface pointer for driver and device | 491 | * usb_find_interface - find usb_interface pointer for driver and device |
| 467 | * @drv: the driver whose current configuration is considered | 492 | * @drv: the driver whose current configuration is considered |
| @@ -473,26 +498,12 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id) | |||
| 473 | */ | 498 | */ |
| 474 | struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) | 499 | struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) |
| 475 | { | 500 | { |
| 476 | struct list_head *entry; | 501 | struct usb_interface *intf = (struct usb_interface *)(long)minor; |
| 477 | struct device *dev; | 502 | int ret; |
| 478 | struct usb_interface *intf; | ||
| 479 | 503 | ||
| 480 | list_for_each(entry, &drv->driver.devices) { | 504 | ret = driver_for_each_device(&drv->driver, NULL, &intf, __find_interface); |
| 481 | dev = container_of(entry, struct device, driver_list); | ||
| 482 | |||
| 483 | /* can't look at usb devices, only interfaces */ | ||
| 484 | if (dev->driver == &usb_generic_driver) | ||
| 485 | continue; | ||
| 486 | |||
| 487 | intf = to_usb_interface(dev); | ||
| 488 | if (intf->minor == -1) | ||
| 489 | continue; | ||
| 490 | if (intf->minor == minor) | ||
| 491 | return intf; | ||
| 492 | } | ||
| 493 | 505 | ||
| 494 | /* no device found that matches */ | 506 | return ret ? intf : NULL; |
| 495 | return NULL; | ||
| 496 | } | 507 | } |
| 497 | 508 | ||
| 498 | static int usb_device_match (struct device *dev, struct device_driver *drv) | 509 | static int usb_device_match (struct device *dev, struct device_driver *drv) |
