On Wed, May 27, 2015 at 07:50:04PM +0800, Li Jun wrote:
> From: Macpaul Lin <macp...@gmail.com>
> 
> Update usb_otg_descriptor for ADP/SRP/HNP features if usb HW has any
> configrations of them.
> 
> Signed-off-by: Macpaul Lin <macp...@gmail.com>
> Signed-off-by: Li Jun <jun...@freescale.com>
> ---
>  drivers/usb/gadget/composite.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 4e3447b..707959c 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -610,6 +610,36 @@ static void device_qual(struct usb_composite_dev *cdev)
>       qual->bRESERVED = 0;
>  }
>  
> +static int usb_gadget_otg_desc_override(struct usb_gadget *gadget,
> +                                     struct usb_configuration *config)
> +{
> +     struct usb_otg_descriptor *otg_desc;
> +
> +     if (!gadget_is_otg(gadget))
> +             return -EOPNOTSUPP;
> +
> +     otg_desc = (struct usb_otg_descriptor *)config->descriptors[0];
> +#ifdef CONFIG_USB_OTG_VERSION
> +#if CONFIG_USB_OTG_VERSION >= 20
> +     otg_desc->bcdOTG = cpu_to_le16(((CONFIG_USB_OTG_VERSION / 10) << 8) +
> +                                             (CONFIG_USB_OTG_VERSION % 10));
> +#endif
> +#endif

See my comments for the 1st patch

> +     /* Override OTG attributes if defined by HW */
> +     if (gadget->adp_support || gadget->hnp_support ||
> +                                     gadget->srp_support) {
> +             otg_desc->bmAttributes = 0;
> +             if (gadget->adp_support)
> +                     otg_desc->bmAttributes |= USB_OTG_ADP;
> +             if (gadget->hnp_support)
> +                     otg_desc->bmAttributes |= USB_OTG_HNP;
> +             if (gadget->srp_support)
> +                     otg_desc->bmAttributes |= USB_OTG_SRP;
> +     }
> +
> +     return 0;
> +}
> +
>  /*-------------------------------------------------------------------------*/
>  
>  static void reset_config(struct usb_composite_dev *cdev)
> @@ -837,6 +867,7 @@ int usb_add_config(struct usb_composite_dev *cdev,
>        */
>       usb_ep_autoconfig_reset(cdev->gadget);
>  
> +     usb_gadget_otg_desc_override(cdev->gadget, config);
>  done:
>       if (status)
>               DBG(cdev, "added config '%s'/%u --> %d\n", config->label,
> -- 
> 1.9.1
> 

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to