Remove remaining void* descriptor casts in the projects and demos that were not remov...
[pub/USBasp.git] / Demos / Device / Incomplete / Sideshow / Descriptors.c
index f6d16c8..8f4c7c5 100644 (file)
@@ -154,48 +154,50 @@ USB_OSCompatibleIDDescriptor_t PROGMEM DevCompatIDs =
                                 SubCompatibleID: "UNIV1"}
 };
 
-uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
+uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
+                                    const uint8_t wIndex,
+                                    const void** const DescriptorAddress)
 {
        const uint8_t  DescriptorType   = (wValue >> 8);
        const uint8_t  DescriptorNumber = (wValue & 0xFF);
 
-       void*    Address = NULL;
-       uint16_t Size    = NO_DESCRIPTOR;
+       const void* Address = NULL;
+       uint16_t    Size    = NO_DESCRIPTOR;
 
        switch (DescriptorType)
        {
                case DTYPE_Device:
-                       Address = (void*)&DeviceDescriptor;
+                       Address = &DeviceDescriptor;
                        Size    = sizeof(USB_Descriptor_Device_t);
                        break;
                case DTYPE_Configuration:
-                       Address = (void*)&ConfigurationDescriptor;
+                       Address = &ConfigurationDescriptor;
                        Size    = sizeof(USB_Descriptor_Configuration_t);
                        break;
                case DTYPE_String:
                        switch (DescriptorNumber)
                        {
                                case 0x00:
-                                       Address = (void*)&LanguageString;
+                                       Address = &LanguageString;
                                        Size    = pgm_read_byte(&LanguageString.Header.Size);
                                        break;
                                case 0x01:
-                                       Address = (void*)&ManufacturerString;
+                                       Address = &ManufacturerString;
                                        Size    = pgm_read_byte(&ManufacturerString.Header.Size);
                                        break;
                                case 0x02:
-                                       Address = (void*)&ProductString;
+                                       Address = &ProductString;
                                        Size    = pgm_read_byte(&ProductString.Header.Size);
                                        break;
                                case 0x03:
-                                       Address = (void*)&SerialNumberString;
+                                       Address = &SerialNumberString;
                                        Size    = pgm_read_byte(&SerialNumberString.Header.Size);
                                        break;
                                case 0xEE:
-                                       /* A Microsoft-proprietary extention. String address 0xEE is used by Windows for
+                                       /* A Microsoft-proprietary extension. String address 0xEE is used by Windows for
                                           "OS Descriptors", which in this case allows us to indicate that our device is
                                           Sideshow compatible regardless of VID/PID values. */
-                                       Address = (void*)&OSDescriptorString;
+                                       Address = &OSDescriptorString;
                                        Size    = pgm_read_byte(&OSDescriptorString.Header.Size);
                                        break;
                        }
@@ -207,11 +209,12 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex,
        return Size;
 }
 
-bool USB_GetOSFeatureDescriptor(const uint16_t wValue, const uint8_t wIndex,
-                                void** const DescriptorAddress, uint16_t* const DescriptorSize)
+uint16_t USB_GetOSFeatureDescriptor(const uint16_t wValue,
+                                    const uint8_t wIndex,
+                                    const void** const DescriptorAddress)
 {
-       void*    Address = NULL;
-       uint16_t Size    = 0;
+       const void* Address = NULL;
+       uint16_t    Size    = NO_DESCRIPTOR;
 
        /* Check if a device level OS feature descriptor is being requested */
        if (wValue == 0x0000)
@@ -219,18 +222,11 @@ bool USB_GetOSFeatureDescriptor(const uint16_t wValue, const uint8_t wIndex,
                /* Only the Extended Device Compatibility descriptor is supported */
                if (wIndex == EXTENDED_COMPAT_ID_DESCRIPTOR)
                {
-                       Address = (void*)&DevCompatIDs;
+                       Address = &DevCompatIDs;
                        Size    = sizeof(USB_OSCompatibleIDDescriptor_t);
                }
        }
 
-       if (Address != NULL)
-       {
-               *DescriptorAddress = Address;
-               *DescriptorSize    = Size;
-
-               return true;
-       }
-               
-       return false;
-}
\ No newline at end of file
+       *DescriptorAddress = Address;
+       return Size;
+}