فهرست منبع

USB: rework sysfs removal of interface files

Removing an interface's sysfs files before unregistering the interface
doesn't work properly, because usb_unbind_interface() will reinstall
altsetting 0 and thereby create new sysfs files.  This patch (as1074)
removes the files after the unregistration is finished.  It's not
quite as clean, but at least it works.

Also, there's no need to check if an interface has been registered
before removing its sysfs files.  If it hasn't been registered then
the files won't have been created, so usb_remove_sysfs_intf_files()
will simply do nothing.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern 17 سال پیش
والد
کامیت
61a5c65789
1فایلهای تغییر یافته به همراه3 افزوده شده و 4 حذف شده
  1. 3 4
      drivers/usb/core/message.c

+ 3 - 4
drivers/usb/core/message.c

@@ -1089,8 +1089,8 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
 				continue;
 				continue;
 			dev_dbg(&dev->dev, "unregistering interface %s\n",
 			dev_dbg(&dev->dev, "unregistering interface %s\n",
 				interface->dev.bus_id);
 				interface->dev.bus_id);
-			usb_remove_sysfs_intf_files(interface);
 			device_del(&interface->dev);
 			device_del(&interface->dev);
+			usb_remove_sysfs_intf_files(interface);
 		}
 		}
 
 
 		/* Now that the interfaces are unbound, nobody should
 		/* Now that the interfaces are unbound, nobody should
@@ -1231,7 +1231,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
 	 */
 	 */
 
 
 	/* prevent submissions using previous endpoint settings */
 	/* prevent submissions using previous endpoint settings */
-	if (iface->cur_altsetting != alt && device_is_registered(&iface->dev))
+	if (iface->cur_altsetting != alt)
 		usb_remove_sysfs_intf_files(iface);
 		usb_remove_sysfs_intf_files(iface);
 	usb_disable_interface(dev, iface);
 	usb_disable_interface(dev, iface);
 
 
@@ -1330,8 +1330,7 @@ int usb_reset_configuration(struct usb_device *dev)
 		struct usb_interface *intf = config->interface[i];
 		struct usb_interface *intf = config->interface[i];
 		struct usb_host_interface *alt;
 		struct usb_host_interface *alt;
 
 
-		if (device_is_registered(&intf->dev))
-			usb_remove_sysfs_intf_files(intf);
+		usb_remove_sysfs_intf_files(intf);
 		alt = usb_altnum_to_altsetting(intf, 0);
 		alt = usb_altnum_to_altsetting(intf, 0);
 
 
 		/* No altsetting 0?  We'll assume the first altsetting.
 		/* No altsetting 0?  We'll assume the first altsetting.