Re: [PATCH 1/2] usb: dwc3: adapt to use dr_mode device tree helper

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

 



Hi,

On 07/06/2013 03:52 PM, Ruchika Kharwar wrote:
> This patch adapts the dwc3 to use the device tree helper
> "of_usb_get_dr_mode" for the mode of operation of the dwc3 instance
> being probed.
> 
> Signed-off-by: Ruchika Kharwar <ruchika@xxxxxx>
> ---
>  drivers/usb/dwc3/core.c |   51 +++++++++++++++++++++++++----------------------
>  drivers/usb/dwc3/core.h |    5 -----
>  2 files changed, 27 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index c35d49d..7b98e4f 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -517,14 +517,17 @@ static int dwc3_probe(struct platform_device *pdev)
>  	}
>  
>  	if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
> -		mode = DWC3_MODE_HOST;
> +		mode = USB_DR_MODE_HOST;
>  	else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
> -		mode = DWC3_MODE_DEVICE;
> +		mode = USB_DR_MODE_PERIPHERAL;
>  	else
> -		mode = DWC3_MODE_DRD;
> +		mode = of_usb_get_dr_mode(node);

You need to check if "node" is not NULL before using of_usb_get_dr_mode.

Also what would happen if DT passes a mode which can't be supported due to
missing device driver? e.g. DT passes mode = "host" whereas HOST is not enabled.

You need to catch these invalid configuration cases and report an error to
the user.

> +
> +	if (mode == USB_DR_MODE_UNKNOWN)
> +		mode = USB_DR_MODE_OTG;
>  
>  	switch (mode) {
> -	case DWC3_MODE_DEVICE:
> +	case USB_DR_MODE_PERIPHERAL:
>  		dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
>  		ret = dwc3_gadget_init(dwc);
>  		if (ret) {

cheers,
-roger

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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux