diff options
| author | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2011-02-06 17:04:39 +0000 |
|---|---|---|
| committer | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2011-02-06 17:04:39 +0000 |
| commit | a60591ed0aa4c7eda33ee064577f7e5235e24157 (patch) | |
| tree | 019a8e1ede3d48d085e9ee91fcbd7c9503ac444f /Bootloaders/CDC/Descriptors.c | |
| parent | d44fa6f203982063934ab0657442214edfc6da08 (diff) | |
Tighten up the Bootloader GetDescriptor() function, as the descriptor size can be extracted from the header after the address has been found.
git-svn-id: http://lufa-lib.googlecode.com/svn/trunk@1654 d5102386-fcda-11dd-9fdb-3debd5008f28
Diffstat (limited to 'Bootloaders/CDC/Descriptors.c')
| -rw-r--r-- | Bootloaders/CDC/Descriptors.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/Bootloaders/CDC/Descriptors.c b/Bootloaders/CDC/Descriptors.c index 5cffe2f6..267c5dca 100644 --- a/Bootloaders/CDC/Descriptors.c +++ b/Bootloaders/CDC/Descriptors.c @@ -206,38 +206,29 @@ 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); + const uint8_t DescriptorType = (wValue >> 8); + const uint8_t DescriptorNumber = (wValue & 0xFF); const void* Address = NULL; - uint16_t Size = NO_DESCRIPTOR; switch (DescriptorType) { case DTYPE_Device: Address = &DeviceDescriptor; - Size = sizeof(USB_Descriptor_Device_t); break; case DTYPE_Configuration: Address = &ConfigurationDescriptor; - Size = sizeof(USB_Descriptor_Configuration_t); break; case DTYPE_String: if (!(DescriptorNumber)) - { - Address = &LanguageString; - Size = LanguageString.Header.Size; - } + Address = &LanguageString; else - { - Address = &ProductString; - Size = ProductString.Header.Size; - } + Address = &ProductString; break; } *DescriptorAddress = Address; - return Size; + return (Address != NULL) ? ((USB_Descriptor_Header_t*)Address)->Size : NO_DESCRIPTOR; } |
