aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/core/message.c12
-rw-r--r--drivers/usb/core/sysfs.c6
2 files changed, 8 insertions, 10 deletions
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 316a746e0080..40fd39de5bf9 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1172,7 +1172,6 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1172 struct usb_host_interface *alt; 1172 struct usb_host_interface *alt;
1173 int ret; 1173 int ret;
1174 int manual = 0; 1174 int manual = 0;
1175 int changed;
1176 1175
1177 if (dev->state == USB_STATE_SUSPENDED) 1176 if (dev->state == USB_STATE_SUSPENDED)
1178 return -EHOSTUNREACH; 1177 return -EHOSTUNREACH;
@@ -1212,8 +1211,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1212 */ 1211 */
1213 1212
1214 /* prevent submissions using previous endpoint settings */ 1213 /* prevent submissions using previous endpoint settings */
1215 changed = (iface->cur_altsetting != alt); 1214 if (iface->cur_altsetting != alt && device_is_registered(&iface->dev))
1216 if (changed && device_is_registered(&iface->dev))
1217 usb_remove_sysfs_intf_files(iface); 1215 usb_remove_sysfs_intf_files(iface);
1218 usb_disable_interface(dev, iface); 1216 usb_disable_interface(dev, iface);
1219 1217
@@ -1250,7 +1248,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1250 * (Likewise, EP0 never "halts" on well designed devices.) 1248 * (Likewise, EP0 never "halts" on well designed devices.)
1251 */ 1249 */
1252 usb_enable_interface(dev, iface); 1250 usb_enable_interface(dev, iface);
1253 if (changed && device_is_registered(&iface->dev)) 1251 if (device_is_registered(&iface->dev))
1254 usb_create_sysfs_intf_files(iface); 1252 usb_create_sysfs_intf_files(iface);
1255 1253
1256 return 0; 1254 return 0;
@@ -1641,12 +1639,6 @@ free_interfaces:
1641 intf->dev.bus_id, ret); 1639 intf->dev.bus_id, ret);
1642 continue; 1640 continue;
1643 } 1641 }
1644
1645 /* The driver's probe method can call usb_set_interface(),
1646 * which would mean the interface's sysfs files are already
1647 * created. Just in case, we'll remove them first.
1648 */
1649 usb_remove_sysfs_intf_files(intf);
1650 usb_create_sysfs_intf_files(intf); 1642 usb_create_sysfs_intf_files(intf);
1651 } 1643 }
1652 1644
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index b04afd06e502..32bd130b1eed 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -735,6 +735,8 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
735 struct usb_host_interface *alt = intf->cur_altsetting; 735 struct usb_host_interface *alt = intf->cur_altsetting;
736 int retval; 736 int retval;
737 737
738 if (intf->sysfs_files_created)
739 return 0;
738 retval = sysfs_create_group(&dev->kobj, &intf_attr_grp); 740 retval = sysfs_create_group(&dev->kobj, &intf_attr_grp);
739 if (retval) 741 if (retval)
740 return retval; 742 return retval;
@@ -746,6 +748,7 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
746 if (intf->intf_assoc) 748 if (intf->intf_assoc)
747 retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp); 749 retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp);
748 usb_create_intf_ep_files(intf, udev); 750 usb_create_intf_ep_files(intf, udev);
751 intf->sysfs_files_created = 1;
749 return 0; 752 return 0;
750} 753}
751 754
@@ -753,8 +756,11 @@ void usb_remove_sysfs_intf_files(struct usb_interface *intf)
753{ 756{
754 struct device *dev = &intf->dev; 757 struct device *dev = &intf->dev;
755 758
759 if (!intf->sysfs_files_created)
760 return;
756 usb_remove_intf_ep_files(intf); 761 usb_remove_intf_ep_files(intf);
757 device_remove_file(dev, &dev_attr_interface); 762 device_remove_file(dev, &dev_attr_interface);
758 sysfs_remove_group(&dev->kobj, &intf_attr_grp); 763 sysfs_remove_group(&dev->kobj, &intf_attr_grp);
759 sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp); 764 sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp);
765 intf->sysfs_files_created = 0;
760} 766}