mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 07:01:23 +00:00
USB: keep track of whether interface sysfs files exist
This patch (as1009) solves the problem of multiple registrations for USB sysfs files in a more satisfying way than the existing code. It simply adds a flag to keep track of whether or not the files have been created; that way the files can be created or removed as needed. Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
This commit is contained in:
parent
5fdcd0396b
commit
7e61559f61
3 changed files with 9 additions and 10 deletions
|
@ -1172,7 +1172,6 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
||||||
struct usb_host_interface *alt;
|
struct usb_host_interface *alt;
|
||||||
int ret;
|
int ret;
|
||||||
int manual = 0;
|
int manual = 0;
|
||||||
int changed;
|
|
||||||
|
|
||||||
if (dev->state == USB_STATE_SUSPENDED)
|
if (dev->state == USB_STATE_SUSPENDED)
|
||||||
return -EHOSTUNREACH;
|
return -EHOSTUNREACH;
|
||||||
|
@ -1212,8 +1211,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 */
|
||||||
changed = (iface->cur_altsetting != alt);
|
if (iface->cur_altsetting != alt && device_is_registered(&iface->dev))
|
||||||
if (changed && device_is_registered(&iface->dev))
|
|
||||||
usb_remove_sysfs_intf_files(iface);
|
usb_remove_sysfs_intf_files(iface);
|
||||||
usb_disable_interface(dev, iface);
|
usb_disable_interface(dev, iface);
|
||||||
|
|
||||||
|
@ -1250,7 +1248,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
||||||
* (Likewise, EP0 never "halts" on well designed devices.)
|
* (Likewise, EP0 never "halts" on well designed devices.)
|
||||||
*/
|
*/
|
||||||
usb_enable_interface(dev, iface);
|
usb_enable_interface(dev, iface);
|
||||||
if (changed && device_is_registered(&iface->dev))
|
if (device_is_registered(&iface->dev))
|
||||||
usb_create_sysfs_intf_files(iface);
|
usb_create_sysfs_intf_files(iface);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1641,12 +1639,6 @@ free_interfaces:
|
||||||
intf->dev.bus_id, ret);
|
intf->dev.bus_id, ret);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The driver's probe method can call usb_set_interface(),
|
|
||||||
* which would mean the interface's sysfs files are already
|
|
||||||
* created. Just in case, we'll remove them first.
|
|
||||||
*/
|
|
||||||
usb_remove_sysfs_intf_files(intf);
|
|
||||||
usb_create_sysfs_intf_files(intf);
|
usb_create_sysfs_intf_files(intf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -735,6 +735,8 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
|
||||||
struct usb_host_interface *alt = intf->cur_altsetting;
|
struct usb_host_interface *alt = intf->cur_altsetting;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
|
if (intf->sysfs_files_created)
|
||||||
|
return 0;
|
||||||
retval = sysfs_create_group(&dev->kobj, &intf_attr_grp);
|
retval = sysfs_create_group(&dev->kobj, &intf_attr_grp);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -746,6 +748,7 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
|
||||||
if (intf->intf_assoc)
|
if (intf->intf_assoc)
|
||||||
retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp);
|
retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp);
|
||||||
usb_create_intf_ep_files(intf, udev);
|
usb_create_intf_ep_files(intf, udev);
|
||||||
|
intf->sysfs_files_created = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,8 +756,11 @@ void usb_remove_sysfs_intf_files(struct usb_interface *intf)
|
||||||
{
|
{
|
||||||
struct device *dev = &intf->dev;
|
struct device *dev = &intf->dev;
|
||||||
|
|
||||||
|
if (!intf->sysfs_files_created)
|
||||||
|
return;
|
||||||
usb_remove_intf_ep_files(intf);
|
usb_remove_intf_ep_files(intf);
|
||||||
device_remove_file(dev, &dev_attr_interface);
|
device_remove_file(dev, &dev_attr_interface);
|
||||||
sysfs_remove_group(&dev->kobj, &intf_attr_grp);
|
sysfs_remove_group(&dev->kobj, &intf_attr_grp);
|
||||||
sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp);
|
sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp);
|
||||||
|
intf->sysfs_files_created = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,7 @@ struct usb_interface {
|
||||||
* bound to */
|
* bound to */
|
||||||
enum usb_interface_condition condition; /* state of binding */
|
enum usb_interface_condition condition; /* state of binding */
|
||||||
unsigned is_active:1; /* the interface is not suspended */
|
unsigned is_active:1; /* the interface is not suspended */
|
||||||
|
unsigned sysfs_files_created:1; /* the sysfs attributes exist */
|
||||||
unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
|
unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
|
||||||
|
|
||||||
struct device dev; /* interface specific device info */
|
struct device dev; /* interface specific device info */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue