Skip to content

Commit de6c583

Browse files
jfischer-nonashif
authored andcommitted
usb: fix BOS descriptor registration
Use BOS header structure directly we have access to instead of casting extern const pointers. Fixes: #30330 Signed-off-by: Johann Fischer <[email protected]>
1 parent 2d65d72 commit de6c583

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

subsys/usb/bos.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LOG_MODULE_REGISTER(usb_bos);
1818
extern const uint8_t __usb_bos_desc_start[];
1919
extern const uint8_t __usb_bos_desc_end[];
2020

21-
USB_DEVICE_BOS_DESC_DEFINE_HDR struct usb_bos_descriptor hdr = {
21+
USB_DEVICE_BOS_DESC_DEFINE_HDR struct usb_bos_descriptor bos_hdr = {
2222
.bLength = sizeof(struct usb_bos_descriptor),
2323
.bDescriptorType = USB_BINARY_OBJECT_STORE_DESC,
2424
.wTotalLength = 0, /* should be corrected with register */
@@ -37,19 +37,15 @@ const void *usb_bos_get_header(void)
3737

3838
void usb_bos_fix_total_length(void)
3939
{
40-
struct usb_bos_descriptor *hdr = (void *)__usb_bos_desc_start;
41-
42-
hdr->wTotalLength = usb_bos_get_length();
40+
bos_hdr.wTotalLength = usb_bos_get_length();
4341
}
4442

4543
void usb_bos_register_cap(struct usb_bos_platform_descriptor *desc)
4644
{
47-
struct usb_bos_descriptor *hdr = (void *)__usb_bos_desc_start;
48-
4945
/* Has effect only on first register */
50-
hdr->wTotalLength = usb_bos_get_length();
46+
bos_hdr.wTotalLength = usb_bos_get_length();
5147

52-
hdr->bNumDeviceCaps += 1U;
48+
bos_hdr.bNumDeviceCaps += 1U;
5349
}
5450

5551
int usb_handle_bos(struct usb_setup_packet *setup,

0 commit comments

Comments
 (0)