diff options
author | Dave Chapman <dave@dchapman.com> | 2007-08-27 22:07:36 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2007-08-27 22:07:36 +0000 |
commit | 03745f4ed33f9dadc16bfc0e26472203e33b43cf (patch) | |
tree | c5ba1df703895f67f72eaca7776eaf65b191ce31 /firmware/usbstack/core/config.c | |
parent | a6d52a8305ba355aeeef17a0648d40e6e4f8fa70 (diff) | |
download | rockbox-03745f4ed33f9dadc16bfc0e26472203e33b43cf.tar.gz rockbox-03745f4ed33f9dadc16bfc0e26472203e33b43cf.zip |
Cosmetic changes only - tab, whitespace and brace policing
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14484 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usbstack/core/config.c')
-rw-r--r-- | firmware/usbstack/core/config.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/firmware/usbstack/core/config.c b/firmware/usbstack/core/config.c index a05a508bf9..277156d0d9 100644 --- a/firmware/usbstack/core/config.c +++ b/firmware/usbstack/core/config.c | |||
@@ -23,58 +23,58 @@ | |||
23 | #include <string.h> | 23 | #include <string.h> |
24 | #include "usbstack/core.h" | 24 | #include "usbstack/core.h" |
25 | 25 | ||
26 | static int usb_descriptor_fillbuf(void* buf, unsigned buflen, struct usb_descriptor_header** src) { | 26 | static int usb_descriptor_fillbuf(void* buf, unsigned buflen, struct usb_descriptor_header** src) |
27 | 27 | { | |
28 | uint8_t* dest = buf; | 28 | uint8_t* dest = buf; |
29 | 29 | ||
30 | if (!src) { | 30 | if (!src) { |
31 | return -EINVAL; | 31 | return -EINVAL; |
32 | } | 32 | } |
33 | 33 | ||
34 | /* fill buffer from src[] until null descriptor ptr */ | 34 | /* fill buffer from src[] until null descriptor ptr */ |
35 | for (; 0 != *src; src++) { | 35 | for (; 0 != *src; src++) { |
36 | unsigned len = (*src)->bLength; | 36 | unsigned len = (*src)->bLength; |
37 | 37 | ||
38 | logf("len: %d", len); | 38 | logf("len: %d", len); |
39 | 39 | ||
40 | if (len > buflen) | 40 | if (len > buflen) |
41 | return -EINVAL; | 41 | return -EINVAL; |
42 | memcpy(dest, *src, len); | 42 | memcpy(dest, *src, len); |
43 | buflen -= len; | 43 | buflen -= len; |
44 | dest += len; | 44 | dest += len; |
45 | } | 45 | } |
46 | return dest - (uint8_t *)buf; | 46 | return dest - (uint8_t *)buf; |
47 | } | 47 | } |
48 | 48 | ||
49 | int usb_stack_configdesc(const struct usb_config_descriptor* config, void* buf, unsigned length, struct usb_descriptor_header** desc) { | 49 | int usb_stack_configdesc(const struct usb_config_descriptor* config, void* buf, unsigned length, struct usb_descriptor_header** desc) |
50 | 50 | { | |
51 | struct usb_config_descriptor* cp = buf; | 51 | struct usb_config_descriptor* cp = buf; |
52 | int len; | 52 | int len; |
53 | |||
54 | if (length < USB_DT_CONFIG_SIZE || !desc) { | ||
55 | return -EINVAL; | ||
56 | } | ||
57 | |||
58 | /* config descriptor first */ | ||
59 | *cp = *config; | ||
60 | |||
61 | /* then interface/endpoint/class/vendor/... */ | ||
62 | len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (uint8_t*)buf, length - USB_DT_CONFIG_SIZE, desc); | ||
63 | |||
64 | if (len < 0) { | ||
65 | return len; | ||
66 | } | ||
53 | 67 | ||
54 | if (length < USB_DT_CONFIG_SIZE || !desc) { | 68 | len += USB_DT_CONFIG_SIZE; |
55 | return -EINVAL; | 69 | if (len > 0xffff) { |
56 | } | 70 | return -EINVAL; |
57 | 71 | } | |
58 | /* config descriptor first */ | ||
59 | *cp = *config; | ||
60 | 72 | ||
61 | /* then interface/endpoint/class/vendor/... */ | 73 | /* patch up the config descriptor */ |
62 | len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (uint8_t*)buf, length - USB_DT_CONFIG_SIZE, desc); | 74 | cp->bLength = USB_DT_CONFIG_SIZE; |
63 | 75 | cp->bDescriptorType = USB_DT_CONFIG; | |
64 | if (len < 0) { | 76 | cp->wTotalLength = len; |
65 | return len; | 77 | cp->bmAttributes |= USB_CONFIG_ATT_ONE; |
66 | } | ||
67 | |||
68 | len += USB_DT_CONFIG_SIZE; | ||
69 | if (len > 0xffff) { | ||
70 | return -EINVAL; | ||
71 | } | ||
72 | 78 | ||
73 | /* patch up the config descriptor */ | 79 | return len; |
74 | cp->bLength = USB_DT_CONFIG_SIZE; | ||
75 | cp->bDescriptorType = USB_DT_CONFIG; | ||
76 | cp->wTotalLength = len; | ||
77 | cp->bmAttributes |= USB_CONFIG_ATT_ONE; | ||
78 | |||
79 | return len; | ||
80 | } | 80 | } |