[PATCH] usbcore: endpoint attributes track altsetting changes

This patch (as588) fixes the way endpoint attribute files are registered
and unregistered.  Now they will correctly track along with altsetting
changes.  This fixes bugzilla entry #5467.

In a separate but related change, when a usb_reset_configuration call
fails, the device state is not changed to USB_STATE_ADDRESS.  In the
first place, failure means that we don't know what the state is, not
that we know the device is unconfigured.  In the second place, doing
this can potentially lead to a memory leak, since usbcore might not
realize there still is a current configuration that needs to be
destroyed.

Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>

---
commit 0e6c8e8db508fcb292836b23d039649c5de29090
tree 5a65aa48c6dbc5c81d1665802d4e632c64b850e3
parent be69e5b1900a19a545becda822b18d6f09168ba5
author Alan Stern <[EMAIL PROTECTED]> Mon, 24 Oct 2005 15:33:03 -0400
committer Greg Kroah-Hartman <[EMAIL PROTECTED]> Fri, 28 Oct 2005 16:47:51 -0700

 drivers/usb/core/message.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 574d0d4..5ad0d5e 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1149,6 +1149,8 @@ int usb_set_interface(struct usb_device 
         */
 
        /* prevent submissions using previous endpoint settings */
+       if (device_is_registered(&iface->dev))
+               usb_remove_sysfs_intf_files(iface);
        usb_disable_interface(dev, iface);
 
        iface->cur_altsetting = alt;
@@ -1184,6 +1186,8 @@ int usb_set_interface(struct usb_device 
         * (Likewise, EP0 never "halts" on well designed devices.)
         */
        usb_enable_interface(dev, iface);
+       if (device_is_registered(&iface->dev))
+               usb_create_sysfs_intf_files(iface);
 
        return 0;
 }
@@ -1233,10 +1237,8 @@ int usb_reset_configuration(struct usb_d
                        USB_REQ_SET_CONFIGURATION, 0,
                        config->desc.bConfigurationValue, 0,
                        NULL, 0, USB_CTRL_SET_TIMEOUT);
-       if (retval < 0) {
-               usb_set_device_state(dev, USB_STATE_ADDRESS);
+       if (retval < 0)
                return retval;
-       }
 
        dev->toggle[0] = dev->toggle[1] = 0;
 
@@ -1245,6 +1247,8 @@ int usb_reset_configuration(struct usb_d
                struct usb_interface *intf = config->interface[i];
                struct usb_host_interface *alt;
 
+               if (device_is_registered(&intf->dev))
+                       usb_remove_sysfs_intf_files(intf);
                alt = usb_altnum_to_altsetting(intf, 0);
 
                /* No altsetting 0?  We'll assume the first altsetting.
@@ -1257,6 +1261,8 @@ int usb_reset_configuration(struct usb_d
 
                intf->cur_altsetting = alt;
                usb_enable_interface(dev, intf);
+               if (device_is_registered(&intf->dev))
+                       usb_create_sysfs_intf_files(intf);
        }
        return 0;
 }



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to