Re: [PATCH v2 04/22] usb: gadget: composite: add USB_DT_OTG request handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi,

On Mon, 8 Jun 2015 23:01:59 +0800
Li Jun <jun.li@xxxxxxxxxxxxx> wrote:

> From: Macpaul Lin <macpaul@xxxxxxxxx>
> 
> Copy usb_otg_descriptor from config's descriptor if host requests
> USB_DT_OTG.
> 
> Signed-off-by: Macpaul Lin <macpaul@xxxxxxxxx>
> Signed-off-by: Li Jun <jun.li@xxxxxxxxxxxxx>
> ---
>  drivers/usb/gadget/composite.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 4e3447b..6b5a0c6 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -1534,6 +1534,27 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
>  				value = min(w_length, (u16) value);
>  			}
>  			break;
> +		case USB_DT_OTG:
> +			if (gadget_is_otg(gadget)) {
> +				struct usb_configuration *config;
> +				int otg_desc_len =
> +					sizeof(struct usb_otg_descriptor);

This evaluates to 5 which is wrong for otg v1.0

> +
> +				if (cdev->config)
> +					config = cdev->config;
> +				else
> +					config = list_first_entry(
> +							&cdev->configs,
> +						struct usb_configuration, list);
> +				if (!config)
> +					goto done;
> +
> +				if (gadget->otg_rev >= 0x0200)
> +					otg_desc_len += sizeof(struct bcdOTG);

This will become 5 + 2 which is wrong for otg v2.0

> +				value = min_t(int, w_length, otg_desc_len);
> +				memcpy(req->buf, config->descriptors[0], value);
> +			}
> +			break;
>  		}
>  		break;
>  

cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux