Fix to previous patch (make CDCHost demo deallocate pipes when an invalid CDC interface is skipped).

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.
This commit is contained in:
Dean Camera 2009-05-15 08:02:30 +00:00
parent fabfdd454a
commit 76d5e99bb8
9 changed files with 46 additions and 34 deletions

View file

@ -70,7 +70,8 @@ uint8_t ProcessConfigurationDescriptor(void)
return InvalidConfigDataReturned;
/* Get the CDC control interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextCDCControlInterface))
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{
/* Descriptor not found, error out */
return NoCDCInterfaceFound;
@ -81,13 +82,14 @@ uint8_t ProcessConfigurationDescriptor(void)
{
/* Fetch the next bulk or interrupt endpoint from the current CDC interface */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceCDCDataEndpoint))
NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{
/* Check to see if the control interface's notification pipe has been found, if so search for the data interface */
if (FoundEndpoints & (1 << CDC_NOTIFICATIONPIPE))
{
/* Get the next CDC data interface from the configuration descriptor (CDC class has two CDC interfaces) */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextCDCDataInterface))
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{
/* Descriptor not found, error out */
return NoCDCInterfaceFound;
@ -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 */
FoundEndpoints = 0;
/* Disable any already configured endpoints from the invalid CDC interfaces */
Endpoint_DisableEndpoint(CDC_NOTIFICATIONPIPE);
Endpoint_DisableEndpoint(CDC_DATAPIPE_IN);
Endpoint_DisableEndpoint(CDC_DATAPIPE_OUT);
/* Disable any already configured pipes from the invalid CDC interfaces */
Pipe_SelectPipe(CDC_NOTIFICATIONPIPE);
Pipe_DisablePipe();
Pipe_SelectPipe(CDC_DATAPIPE_IN);
Pipe_DisablePipe();
Pipe_SelectPipe(CDC_DATAPIPE_OUT);
Pipe_DisablePipe();
/* Get the next CDC control interface from the configuration descriptor (CDC class has two CDC interfaces) */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextCDCControlInterface))
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{
/* Descriptor not found, error out */
return NoCDCInterfaceFound;
@ -113,7 +119,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Fetch the next bulk or interrupt endpoint from the current CDC interface */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceCDCDataEndpoint))
NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{
/* Descriptor not found, error out */
return NoEndpointFound;