[U-Boot] [PATCH v2 2/7] dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget

Marek Vasut
2012-07-09T16:34:13Z

Dear Lukasz Majewski,

> Support for f_dfu USB function.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
>
[...]

> +static void handle_getstatus(struct usb_request *req)
> +{
> + struct dfu_status *dstat = (struct dfu_status *)req->buf;
> + struct f_dfu *f_dfu = req->context;
> +
> + switch (f_dfu->dfu_state) {
> + case DFU_STATE_dfuDNLOAD_SYNC:
> + case DFU_STATE_dfuDNBUSY:
> + f_dfu->dfu_state = DFU_STATE_dfuDNLOAD_IDLE;
> + break;
> + case DFU_STATE_dfuMANIFEST_SYNC:
> + break;
> + default:
> + break;
> + }
> +
> + /* send status response */
> + dstat->bStatus = f_dfu->dfu_status;
> + /* FIXME: set dstat->bwPollTimeout */

FIXME? :)

> + dstat->bState = f_dfu->dfu_state;
> + dstat->iString = 0;
> +}

[...]

> +static int
> +dfu_handle(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
> +{
> + struct usb_gadget *gadget = f->config->cdev->gadget;
> + struct usb_request *req = f->config->cdev->req;
> + struct f_dfu *f_dfu = f->config->cdev->req->context;
> + u16 len = le16_to_cpu(ctrl->wLength);
> + u16 w_value = le16_to_cpu(ctrl->wValue);
> + int value = 0;
> + u8 req_type = ctrl->bRequestType & USB_TYPE_MASK;
> +
> + debug("w_value: 0x%x len: 0x%x\n", w_value, len);
> + debug("req_type: 0x%x ctrl->bRequest: 0x%x f_dfu->dfu_state: 0x%x\n",
> + req_type, ctrl->bRequest, f_dfu->dfu_state);
> +
> +
> + if (req_type == USB_TYPE_STANDARD) {
> + if (ctrl->bRequest == USB_REQ_GET_DESCRIPTOR &&
> + (w_value >> 8) == DFU_DT_FUNC) {
> + value = min(len, (u16) sizeof dfu_func);

Does the sizeof really miss braces up here ? …