mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: "Daniel Brát" <danek.brat@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2 v2] usb: dwc2: Make having a phy optional
Date: Mon, 4 Oct 2021 12:06:54 +0200	[thread overview]
Message-ID: <20211004100654.GO28453@pengutronix.de> (raw)
In-Reply-To: <20210908125853.3353-1-danek.brat@gmail.com>

Hi Daniel,

On Wed, Sep 08, 2021 at 02:58:53PM +0200, Daniel Brát wrote:
> Despite using 'phy_optional_get' to get a 'usb2-phy' inside its probe,
> the driver would fail if it didnt find it. Also, there is no Kconfig
> dependency on 'CONFIG_GENERIC_PHY', so without it defined the phy
> functions are unimplemented and always return -ENOSYS making dwc2 probe
> always fail too.
> The header stub of 'phy_optional_get' was changed to return NULL and
> the dwc2 driver was modified accordingly.
> 
> Signed-off-by: Daniel Brát <danek.brat@gmail.com>
> ---
>  drivers/usb/dwc2/dwc2.c | 27 +++++++++++++++------------
>  include/linux/phy/phy.h |  2 +-
>  2 files changed, 16 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
> index 9893977b8..472a0b7d9 100644
> --- a/drivers/usb/dwc2/dwc2.c
> +++ b/drivers/usb/dwc2/dwc2.c
> @@ -73,19 +73,22 @@ static int dwc2_probe(struct device_d *dev)
>  		goto clk_disable;
>  
>  	dwc2->phy = phy_optional_get(dev, "usb2-phy");
> -	if (IS_ERR(dwc2->phy)) {
> -		ret = PTR_ERR(dwc2->phy);
> -		goto clk_disable;
> +	if (dwc2->phy) {
> +		if (IS_ERR(dwc2->phy)) {
> +			dev_warn(dev, "Couldnt get 'usb2-phy': %s\n",
> +					strerror(PTR_ERR(dwc2->phy)));
> +			goto phy_bypass;
> +		}

You changed the return value of phy_optional_get() to NULL below, so
when phy_optional_get() returns an error we would still have to fail the
probe function here instead of ignoring the error, no?

Sascha

> +
> +		ret = phy_power_on(dwc2->phy);
> +		if (ret)
> +			goto clk_disable;
> +
> +		ret = phy_init(dwc2->phy);
> +		if (ret)
> +			goto phy_power_off;
>  	}
> -
> -	ret = phy_power_on(dwc2->phy);
> -	if (ret)
> -		goto clk_disable;
> -
> -	ret = phy_init(dwc2->phy);
> -	if (ret)
> -		goto phy_power_off;
> -
> +phy_bypass:
>  	ret = dwc2_check_core_version(dwc2);
>  	if (ret)
>  		goto error;
> diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> index 679ce6e42..321e546f9 100644
> --- a/include/linux/phy/phy.h
> +++ b/include/linux/phy/phy.h
> @@ -195,7 +195,7 @@ static inline struct phy *phy_get(struct device_d *dev, const char *string)
>  static inline struct phy *phy_optional_get(struct device_d *dev,
>  					   const char *string)
>  {
> -	return ERR_PTR(-ENOSYS);
> +	return NULL;
>  }
>  
>  static inline struct phy *of_phy_get_by_phandle(struct device_d *dev,
> -- 
> 2.17.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-10-04 10:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08  7:46 [PATCH 0/2] usb: dwc2: fix phy dependecy Daniel Brát
2021-09-08  7:46 ` [PATCH 1/2] usb: dwc2: Make having a phy optional Daniel Brát
2021-09-08  8:50   ` Jules Maselbas
2021-09-08 12:58     ` [PATCH 1/2 v2] " Daniel Brát
2021-10-04 10:06       ` Sascha Hauer [this message]
2021-10-19 16:16       ` Jules Maselbas
2021-10-20  9:07         ` Daniel Brát
2021-10-20  9:48           ` Jules Maselbas
2021-09-08  7:46 ` [PATCH 2/2] ARM: rpi_defconfig: Enable PHY core for dwc2 usb driver Daniel Brát

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211004100654.GO28453@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=danek.brat@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox