From 7efaaa9a91de291dbc124bc88d9f99219c260dc9 Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Sun, 5 Apr 2009 18:19:19 +0000 Subject: MFp4 //depot/projects/usb@159811 First patch in a series of memory save patches. Submitted by: Hans Petter Selasky --- sys/dev/usb/usb_request.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'sys/dev/usb/usb_request.c') diff --git a/sys/dev/usb/usb_request.c b/sys/dev/usb/usb_request.c index 37e276176793..78671eaece5c 100644 --- a/sys/dev/usb/usb_request.c +++ b/sys/dev/usb/usb_request.c @@ -832,6 +832,40 @@ usb2_req_get_string_desc(struct usb2_device *udev, struct mtx *mtx, void *sdesc, UDESC_STRING, string_index, 0)); } +/*------------------------------------------------------------------------* + * usb2_req_get_config_desc_ptr + * + * This function is used in device side mode to retrieve the pointer + * to the generated config descriptor. This saves allocating space for + * an additional config descriptor when setting the configuration. + * + * Returns: + * 0: Success + * Else: Failure + *------------------------------------------------------------------------*/ +usb2_error_t +usb2_req_get_config_desc_ptr(struct usb2_device *udev, + struct usb2_config_descriptor **ppcd, uint8_t config_index) +{ + uint16_t len; + + struct usb2_device_request req; + + if (udev->flags.usb2_mode != USB_MODE_DEVICE) + return (USB_ERR_INVAL); + + req.bmRequestType = UT_READ_CLASS_DEVICE; + req.bRequest = UR_GET_DESCRIPTOR; + USETW2(req.wValue, UDESC_CONFIG, config_index); + USETW(req.wIndex, 0); + USETW(req.wLength, 0); + + (usb2_temp_get_desc_p) (udev, &req, + __DECONST(const void **, ppcd), &len); + + return (*ppcd ? USB_ERR_NORMAL_COMPLETION : USB_ERR_INVAL); +} + /*------------------------------------------------------------------------* * usb2_req_get_config_desc * -- cgit v1.2.3