Fix to previous patch (make CDCHost demo deallocate pipes when an invalid CDC interfa...
authorDean Camera <dean@fourwalledcubicle.com>
Fri, 15 May 2009 08:02:30 +0000 (08:02 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Fri, 15 May 2009 08:02:30 +0000 (08:02 +0000)
Remove the saving of the USB_GetNextDescriptorComp() return value in all host demos, since it went unused anyway; replaced with a simple check against the success error code for clarity.

Demos/Host/CDCHost/ConfigDescriptor.c
Demos/Host/GenericHIDHost/ConfigDescriptor.c
Demos/Host/KeyboardHost/ConfigDescriptor.c
Demos/Host/KeyboardHostWithParser/ConfigDescriptor.c
Demos/Host/MassStorageHost/ConfigDescriptor.c
Demos/Host/MouseHost/ConfigDescriptor.c
Demos/Host/MouseHostWithParser/ConfigDescriptor.c
Demos/Host/StillImageHost/ConfigDescriptor.c
LUFA/ChangeLog.txt

index 29afbfa..faad3cc 100644 (file)
@@ -70,7 +70,8 @@ uint8_t ProcessConfigurationDescriptor(void)
          return InvalidConfigDataReturned;\r
        \r
        /* Get the CDC control interface from the configuration descriptor */\r
-       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextCDCControlInterface))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoCDCInterfaceFound;\r
@@ -81,13 +82,14 @@ uint8_t ProcessConfigurationDescriptor(void)
        {\r
                /* Fetch the next bulk or interrupt endpoint from the current CDC interface */\r
                if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
-                                                  NextInterfaceCDCDataEndpoint))\r
+                                             NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
                {\r
                        /* Check to see if the control interface's notification pipe has been found, if so search for the data interface */\r
                        if (FoundEndpoints & (1 << CDC_NOTIFICATIONPIPE))\r
                        {\r
                                /* Get the next CDC data interface from the configuration descriptor (CDC class has two CDC interfaces) */\r
-                               if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextCDCDataInterface))\r
+                               if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, \r
+                                                             NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
                                {\r
                                        /* Descriptor not found, error out */\r
                                        return NoCDCInterfaceFound;\r
@@ -98,13 +100,17 @@ uint8_t ProcessConfigurationDescriptor(void)
                                /* Clear the found endpoints mask, since any already processed endpoints aren't in the CDC interface we need */\r
                                FoundEndpoints = 0;\r
 \r
-                               /* Disable any already configured endpoints from the invalid CDC interfaces */\r
-                               Endpoint_DisableEndpoint(CDC_NOTIFICATIONPIPE);\r
-                               Endpoint_DisableEndpoint(CDC_DATAPIPE_IN);\r
-                               Endpoint_DisableEndpoint(CDC_DATAPIPE_OUT);\r
+                               /* Disable any already configured pipes from the invalid CDC interfaces */\r
+                               Pipe_SelectPipe(CDC_NOTIFICATIONPIPE);\r
+                               Pipe_DisablePipe();\r
+                               Pipe_SelectPipe(CDC_DATAPIPE_IN);\r
+                               Pipe_DisablePipe();\r
+                               Pipe_SelectPipe(CDC_DATAPIPE_OUT);\r
+                               Pipe_DisablePipe();\r
                        \r
                                /* Get the next CDC control interface from the configuration descriptor (CDC class has two CDC interfaces) */\r
-                               if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextCDCControlInterface))\r
+                               if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                                             NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
                                {\r
                                        /* Descriptor not found, error out */\r
                                        return NoCDCInterfaceFound;\r
@@ -113,7 +119,7 @@ uint8_t ProcessConfigurationDescriptor(void)
 \r
                        /* Fetch the next bulk or interrupt endpoint from the current CDC interface */\r
                        if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
-                                                                                          NextInterfaceCDCDataEndpoint))\r
+                                                     NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
                        {\r
                                /* Descriptor not found, error out */\r
                                return NoEndpointFound;\r
index ef99359..1c0a6b2 100644 (file)
@@ -71,7 +71,8 @@ uint8_t ProcessConfigurationDescriptor(void)
          return InvalidConfigDataReturned;\r
        \r
        /* Get the HID interface from the configuration descriptor */\r
-       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextHIDInterface))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoHIDInterfaceFound;\r
@@ -80,7 +81,8 @@ uint8_t ProcessConfigurationDescriptor(void)
        while (FoundEndpoints != ((1 << HID_DATA_IN_PIPE) | (1 << HID_DATA_OUT_PIPE)))\r
        {\r
                /* Get the next HID interface's data endpoint descriptor */\r
-               if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextInterfaceHIDDataEndpoint))\r
+               if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                             NextInterfaceHIDDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
                {\r
                        /* Not all HID devices have an OUT endpoint - if we've reached the end of the HID descriptor\r
                         * but only found the mandatory IN endpoint, it's safe to continue with the device enumeration */\r
index 303f06d..b0233d9 100644 (file)
@@ -69,7 +69,8 @@ uint8_t ProcessConfigurationDescriptor(void)
          return InvalidConfigDataReturned;\r
        \r
        /* Get the keyboard interface from the configuration descriptor */\r
-       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextKeyboardInterface))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoHIDInterfaceFound;\r
@@ -77,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void)
 \r
        /* Get the keyboard interface's data endpoint descriptor */\r
        if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
-                                          NextInterfaceKeyboardDataEndpoint))\r
+                                     NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoEndpointFound;\r
index 9b56823..9cdf6f8 100644 (file)
@@ -49,7 +49,6 @@ uint8_t ProcessConfigurationDescriptor(void)
 {\r
        uint8_t* ConfigDescriptorData;\r
        uint16_t ConfigDescriptorSize;\r
-       uint8_t  ErrorCode;\r
        \r
        /* Get Configuration Descriptor size from the device */\r
        if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)\r
@@ -70,14 +69,16 @@ uint8_t ProcessConfigurationDescriptor(void)
          return InvalidConfigDataReturned;\r
        \r
        /* Get the keyboard interface from the configuration descriptor */\r
-       if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextKeyboardInterface)))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoHIDInterfaceFound;\r
        }\r
        \r
        /* Get the keyboard interface's HID descriptor */\r
-       if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextHID)))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextHID) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoHIDDescriptorFound;\r
@@ -87,8 +88,8 @@ uint8_t ProcessConfigurationDescriptor(void)
        HIDReportSize = DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_HID_t).HIDReportLength;\r
 \r
        /* Get the keyboard interface's data endpoint descriptor */\r
-       if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
-                                                       NextInterfaceKeyboardDataEndpoint)))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoEndpointFound;\r
index 6642e1c..c02f3b0 100644 (file)
@@ -49,7 +49,6 @@ uint8_t ProcessConfigurationDescriptor(void)
 {\r
        uint8_t* ConfigDescriptorData;\r
        uint16_t ConfigDescriptorSize;\r
-       uint8_t  ErrorCode;\r
        uint8_t  FoundEndpoints = 0;\r
        \r
        /* Get Configuration Descriptor size from the device */\r
@@ -71,8 +70,8 @@ uint8_t ProcessConfigurationDescriptor(void)
          return InvalidConfigDataReturned;\r
        \r
        /* Get the mass storage interface from the configuration descriptor */\r
-       if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
-                                                       NextMassStorageInterface)))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextMassStorageInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoInterfaceFound;\r
@@ -82,8 +81,8 @@ uint8_t ProcessConfigurationDescriptor(void)
        while (FoundEndpoints != ((1 << MASS_STORE_DATA_IN_PIPE) | (1 << MASS_STORE_DATA_OUT_PIPE)))\r
        {\r
                /* Fetch the next bulk endpoint from the current mass storage interface */\r
-               if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
-                                                               NextInterfaceBulkDataEndpoint)))\r
+               if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                             NextInterfaceBulkDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
                {\r
                        /* Descriptor not found, error out */\r
                        return NoEndpointFound;\r
index f29eda1..435a4f9 100644 (file)
@@ -69,7 +69,8 @@ uint8_t ProcessConfigurationDescriptor(void)
          return InvalidConfigDataReturned;\r
        \r
        /* Get the mouse interface from the configuration descriptor */\r
-       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextMouseInterface))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoHIDInterfaceFound;\r
@@ -77,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void)
 \r
        /* Get the mouse interface's data endpoint descriptor */\r
        if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
-                                     NextInterfaceMouseDataEndpoint))\r
+                                     NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoEndpointFound;\r
index 486a0c7..c008523 100644 (file)
@@ -49,7 +49,6 @@ uint8_t ProcessConfigurationDescriptor(void)
 {\r
        uint8_t* ConfigDescriptorData;\r
        uint16_t ConfigDescriptorSize;\r
-       uint8_t  ErrorCode;\r
        \r
        /* Get Configuration Descriptor size from the device */\r
        if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)\r
@@ -70,14 +69,16 @@ uint8_t ProcessConfigurationDescriptor(void)
          return InvalidConfigDataReturned;\r
        \r
        /* Get the mouse interface from the configuration descriptor */\r
-       if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextMouseInterface)))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoHIDInterfaceFound;\r
        }\r
        \r
        /* Get the mouse interface's HID descriptor */\r
-       if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextHID)))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextHID) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoHIDDescriptorFound;\r
@@ -87,8 +88,8 @@ uint8_t ProcessConfigurationDescriptor(void)
        HIDReportSize = DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_HID_t).HIDReportLength;\r
 \r
        /* Get the mouse interface's data endpoint descriptor */\r
-       if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
-                                                       NextInterfaceMouseDataEndpoint)))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoEndpointFound;\r
index 5e2916b..b58dfb8 100644 (file)
@@ -70,7 +70,8 @@ uint8_t ProcessConfigurationDescriptor(void)
          return InvalidConfigDataReturned;\r
        \r
        /* Get the Still Image interface from the configuration descriptor */\r
-       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextStillImageInterface))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextStillImageInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoInterfaceFound;\r
@@ -81,7 +82,7 @@ uint8_t ProcessConfigurationDescriptor(void)
        {\r
                /* Fetch the next endpoint from the current Still Image interface */\r
                if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
-                                                  NextSImageInterfaceDataEndpoint))\r
+                                             NextSImageInterfaceDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
                {\r
                        /* Descriptor not found, error out */\r
                        return NoEndpointFound;\r
index 69a60f1..d17c758 100644 (file)
   *\r
   *  - Fixed bug in RNDISEthernet and DualCDC demos not using the correct USB_ControlRequest structure for control request data\r
   *  - Fixed documentation showing incorrect USB mode support on the supported AVRs list\r
-  *  - Fixed RNDISEthernet not working under Linux due to Linux requiring an "optional" request which was unhandled\r
+  *  - Fixed RNDISEthernet not working under Linux due to Linux requiring an "optional" RNDIS request which was unhandled\r
   *  - Fixed Mouse and Keyboard device demos not acting in accordance with the HID specification for idle periods (thanks to Brian Dickman)\r
   *  - Removed support for endpoint/pipe non-control interrupts; these did not act in the way users expected, and had many subtle issues\r
   *  - Fixed Device Mode not handling Set Feature and Clear Feature Chapter 9 requests that are addressed to the device (thanks to Brian Dickman)\r
   *  - Moved control endpoint interrupt handling into the library itself, enable via the new INTERRUPT_CONTROL_ENDPOINT token\r
-  *  - Fixed CDCHost not clearing configured endpoints and resetting configured endpoints mask when a partially enumerated invalid CDC\r
+  *  - Fixed CDCHost not clearing configured pipes and resetting configured pipes mask when a partially enumerated invalid CDC\r
   *    interface is skipped\r
   *\r
   *\r