Greg:

This patch creates a separate subroutine to encapsulate the work required 
in choosing an initial configuration for a device.  In my opinion that 
reflects a policy decision that should be kept apart from all the other 
work involved in creating a new device structure.  The existing code in 
usb_new_device() is simply moved into usb_choose_configuration().

Please apply.

Alan Stern



# This is a BitKeeper generated patch for the following project:
# Project Name: greg k-h's linux 2.5 USB kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.2111  -> 1.2112 
#       drivers/usb/core/usb.c  1.272   -> 1.273  
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/05/24      [EMAIL PROTECTED]       1.2112
# Create a separate subroutine for usb_choose_configuration().
# --------------------------------------------
#
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c    Mon May 24 10:37:01 2004
+++ b/drivers/usb/core/usb.c    Mon May 24 10:37:01 2004
@@ -1066,6 +1066,37 @@
        kfree(buf);
 }
 
+static int usb_choose_configuration(struct usb_device *dev)
+{
+       int c, i;
+
+       c = dev->config[0].desc.bConfigurationValue;
+       if (dev->descriptor.bNumConfigurations != 1) {
+               for (i = 0; i < dev->descriptor.bNumConfigurations; i++) {
+                       struct usb_interface_descriptor *desc;
+
+                       /* heuristic:  Linux is more likely to have class
+                        * drivers, so avoid vendor-specific interfaces.
+                        */
+                       desc = &dev->config[i].intf_cache[0]
+                                       ->altsetting->desc;
+                       if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC)
+                               continue;
+                       /* COMM/2/all is CDC ACM, except 0xff is MSFT RNDIS */
+                       if (desc->bInterfaceClass == USB_CLASS_COMM
+                                       && desc->bInterfaceSubClass == 2
+                                       && desc->bInterfaceProtocol == 0xff)
+                               continue;
+                       c = dev->config[i].desc.bConfigurationValue;
+                       break;
+               }
+               dev_info(&dev->dev,
+                       "configuration #%d chosen from %d choices\n",
+                       c, dev->descriptor.bNumConfigurations);
+       }
+       return c;
+}
+
 /*
  * usb_new_device - perform initial device setup (usbcore-internal)
  * @dev: newly addressed device (in ADDRESS state)
@@ -1087,8 +1118,7 @@
 int usb_new_device(struct usb_device *dev)
 {
        int err;
-       int i;
-       int config;
+       int c;
 
        err = usb_get_configuration(dev);
        if (err < 0) {
@@ -1122,35 +1152,10 @@
         * with the driver core, and lets usb device drivers bind to them.
         * NOTE:  should interact with hub power budgeting.
         */
-       config = dev->config[0].desc.bConfigurationValue;
-       if (dev->descriptor.bNumConfigurations != 1) {
-               for (i = 0; i < dev->descriptor.bNumConfigurations; i++) {
-                       struct usb_interface_descriptor *desc;
-
-                       /* heuristic:  Linux is more likely to have class
-                        * drivers, so avoid vendor-specific interfaces.
-                        */
-                       desc = &dev->config[i].intf_cache[0]
-                                       ->altsetting->desc;
-                       if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC)
-                               continue;
-                       /* COMM/2/all is CDC ACM, except 0xff is MSFT RNDIS */
-                       if (desc->bInterfaceClass == USB_CLASS_COMM
-                                       && desc->bInterfaceSubClass == 2
-                                       && desc->bInterfaceProtocol == 0xff)
-                               continue;
-                       config = dev->config[i].desc.bConfigurationValue;
-                       break;
-               }
-               dev_info(&dev->dev,
-                       "configuration #%d chosen from %d choices\n",
-                       config,
-                       dev->descriptor.bNumConfigurations);
-       }
-       err = usb_set_configuration(dev, config);
+       c = usb_choose_configuration(dev);
+       err = usb_set_configuration(dev, c);
        if (err) {
-               dev_err(&dev->dev, "can't set config #%d, error %d\n",
-                       config, err);
+               dev_err(&dev->dev, "can't set config #%d, error %d\n", c, err);
                device_del(&dev->dev);
                goto fail;
        }



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to