Skip to content
Permalink
Browse files

usb: merge all request handler buffers

Now that we have merged the class and vendor request buffers into the
USB device code, we can also merge the standard request buffer. We just
need to ensure it is at least 8 bytes, by using the range option in
Kconfig. The 64KiB limit is arbitrary.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
  • Loading branch information...
aurel32 authored and nashif committed Nov 2, 2018
1 parent 819e749 commit 327f61076a5211a404aff80a7a5d6e9cf5b2a536
Showing with 11 additions and 12 deletions.
  1. +3 −2 subsys/usb/Kconfig
  2. +8 −10 subsys/usb/usb_device.c
@@ -58,8 +58,9 @@ config USB_COMPOSITE_DEVICE
Enable composite USB device driver.

config USB_REQUEST_BUFFER_SIZE
int "Set buffer size for Class and Vendor request handlers"
default 256 if USB_DEVICE_NETWORK_RNDIS
int "Set buffer size for Standard, Class and Vendor request handlers"
range 256 65536 if USB_DEVICE_NETWORK_RNDIS
range 8 65536
default 64

config USB_DEVICE_SOF
@@ -156,10 +156,8 @@ static struct usb_dev_priv {
usb_request_handler req_handlers[MAX_NUM_REQ_HANDLERS];
/** Array of installed request data pointers */
u8_t *data_store[MAX_NUM_REQ_HANDLERS];
/* Buffer used for storing standard usb request data */
u8_t std_req_data[MAX_STD_REQ_MSG_SIZE];
/* Buffer used for storing class and vendor request data */
u8_t class_vendor_req_data[CONFIG_USB_REQUEST_BUFFER_SIZE];
/* Buffer used for storing standard, class and vendor request data */
u8_t req_data[CONFIG_USB_REQUEST_BUFFER_SIZE];

/** Variable to check whether the usb has been enabled */
bool enabled;
@@ -1040,20 +1038,20 @@ int usb_set_config(struct usb_cfg_data *config)
/* register standard request handler */
usb_register_request_handler(REQTYPE_TYPE_STANDARD,
usb_handle_standard_request,
usb_dev.std_req_data);
usb_dev.req_data);

/* register class request handlers for each interface*/
if (config->interface.class_handler != NULL) {
usb_register_request_handler(REQTYPE_TYPE_CLASS,
config->interface.class_handler,
usb_dev.class_vendor_req_data);
usb_dev.req_data);
}

/* register vendor request handler */
if (config->interface.vendor_handler || usb_os_desc_enabled()) {
usb_register_request_handler(REQTYPE_TYPE_VENDOR,
usb_handle_vendor_request,
usb_dev.class_vendor_req_data);
usb_dev.req_data);

if (config->interface.vendor_handler) {
usb_dev.vendor_req_handler =
@@ -1655,17 +1653,17 @@ static int usb_composite_init(struct device *dev)
/* register standard request handler */
usb_register_request_handler(REQTYPE_TYPE_STANDARD,
&(usb_handle_standard_request),
usb_dev.std_req_data);
usb_dev.req_data);

/* register class request handlers for each interface*/
usb_register_request_handler(REQTYPE_TYPE_CLASS,
class_handler,
usb_dev.class_vendor_req_data);
usb_dev.req_data);

/* register vendor request handlers */
usb_register_request_handler(REQTYPE_TYPE_VENDOR,
vendor_handler,
usb_dev.class_vendor_req_data);
usb_dev.req_data);

/* register class request handlers for each interface*/
usb_register_custom_req_handler(custom_handler);

0 comments on commit 327f610

Please sign in to comment.
You can’t perform that action at this time.