[PATCH RESEND 2/2] usb: dwc2: Return errors from PHY

Sergei Shtylyov sergei.shtylyov at cogentembedded.com
Wed Nov 11 12:46:48 PST 2015


Hello.

On 11/11/2015 10:36 PM, John Youn wrote:

> When searching for PHYs, any error was treated as if the PHY did not
> exist or was not specified (-ENODEV). Thus the probe function did not
> correctly return error conditions such as -EPROBE_DEFER.
>
> Fixed so that only -ENODEV is ignored and any other error is returned.
>
> Reported-by: Alexander Aring <alex.aring at gmail.com>
> Signed-off-by: John Youn <johnyoun at synopsys.com>
> ---
>   drivers/usb/dwc2/platform.c | 31 ++++++++++++++++++++++++++-----
>   1 file changed, 26 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> index b129c52..0a0e44e 100644
> --- a/drivers/usb/dwc2/platform.c
> +++ b/drivers/usb/dwc2/platform.c
> @@ -214,14 +214,35 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
>   	 */
>   	hsotg->phy = devm_phy_get(hsotg->dev, "usb2-phy");
>   	if (IS_ERR(hsotg->phy)) {
> -		hsotg->phy = NULL;
> +		ret = PTR_ERR(hsotg->phy);
> +		if (ret == -ENODEV) {
> +			hsotg->phy = NULL;
> +		} else if (ret == -EPROBE_DEFER) {
> +			return ret;
> +		} else {
> +			dev_err(hsotg->dev, "error getting phy %d\n", ret);
> +			return ret;
> +		}

    This is asking to be a *switch* statement.

> +	}
> +
> +	if (!hsotg->phy) {
>   		hsotg->uphy = devm_usb_get_phy(hsotg->dev, USB_PHY_TYPE_USB2);
> -		if (IS_ERR(hsotg->uphy))
> -			hsotg->uphy = NULL;
> -		else
> -			hsotg->plat = dev_get_platdata(hsotg->dev);
> +		if (IS_ERR(hsotg->uphy)) {
> +			ret = PTR_ERR(hsotg->uphy);
> +			if (ret == -ENODEV) {
> +				hsotg->uphy = NULL;
> +			} else if (ret == -EPROBE_DEFER) {
> +				return ret;
> +			} else {
> +				dev_err(hsotg->dev, "error getting "
> +					"usb phy %d\n", ret);
> +				return ret;
> +			}

    This too.

[...]

MBR, Sergei




More information about the linux-rpi-kernel mailing list