mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@gmail.com>
To: Tang Bin <tangbin@cmss.chinamobile.com>,
	balbi@kernel.org, gregkh@linuxfoundation.org,
	thierry.reding@gmail.com, jonathanh@nvidia.com
Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Subject: Re: [PATCH] usb: phy: tegra: Use IS_ERR() to check and simplify code
Date: Fri, 11 Sep 2020 11:29:59 +0300	[thread overview]
Message-ID: <d0bd4d4c-0447-6c5f-6dc3-17e5ceae2623@gmail.com> (raw)
In-Reply-To: <20200910115607.11392-1-tangbin@cmss.chinamobile.com>

Hello!

On 10.09.2020 14:56, Tang Bin wrote:

> Use IS_ERR() and PTR_ERR() instead of PTR_ERR_OR_ZERO() to
> simplify code, avoid redundant judgements.
> 
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> ---
>   drivers/usb/phy/phy-tegra-usb.c | 25 ++++++++++---------------
>   1 file changed, 10 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
> index 6153cc35a..3b901429d 100644
> --- a/drivers/usb/phy/phy-tegra-usb.c
> +++ b/drivers/usb/phy/phy-tegra-usb.c
> @@ -1121,10 +1121,9 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
>   		return PTR_ERR(tegra_phy->vbus);
>   
>   	tegra_phy->pll_u = devm_clk_get(&pdev->dev, "pll_u");
> -	err = PTR_ERR_OR_ZERO(tegra_phy->pll_u);
> -	if (err) {
> +	if (IS_ERR(tegra_phy->pll_u)) {
>   		dev_err(&pdev->dev, "Failed to get pll_u clock: %d\n", err);

    'err' should be changed here too...

> -		return err;
> +		return PTR_ERR(tegra_phy->pll_u);
>   	}
>   
>   	phy_type = of_usb_get_phy_mode(np);
> @@ -1135,20 +1134,18 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
>   			return err;
>   
>   		tegra_phy->pad_clk = devm_clk_get(&pdev->dev, "utmi-pads");
> -		err = PTR_ERR_OR_ZERO(tegra_phy->pad_clk);
> -		if (err) {
> +		if (IS_ERR(tegra_phy->pad_clk)) {
>   			dev_err(&pdev->dev,
>   				"Failed to get UTMIP pad clock: %d\n", err);

    Same here.

> -			return err;
> +			return PTR_ERR(tegra_phy->pad_clk);
>   		}
>   
>   		reset = devm_reset_control_get_optional_shared(&pdev->dev,
>   							       "utmi-pads");
> -		err = PTR_ERR_OR_ZERO(reset);
> -		if (err) {
> +		if (IS_ERR(reset)) {
>   			dev_err(&pdev->dev,
>   				"Failed to get UTMI-pads reset: %d\n", err);

    And here.

> -			return err;
> +			return PTR_ERR(reset);
>   		}
>   		tegra_phy->pad_rst = reset;
>   		break;
> @@ -1157,22 +1154,20 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
>   		tegra_phy->is_ulpi_phy = true;
>   
>   		tegra_phy->clk = devm_clk_get(&pdev->dev, "ulpi-link");
> -		err = PTR_ERR_OR_ZERO(tegra_phy->clk);
> -		if (err) {
> +		if (IS_ERR(tegra_phy->clk)) {
>   			dev_err(&pdev->dev,
>   				"Failed to get ULPI clock: %d\n", err);

    And here.

> -			return err;
> +			return PTR_ERR(tegra_phy->clk);
>   		}
>   
>   		gpiod = devm_gpiod_get_from_of_node(&pdev->dev, np,
>   						    "nvidia,phy-reset-gpio",
>   						    0, GPIOD_OUT_HIGH,
>   						    "ulpi_phy_reset_b");
> -		err = PTR_ERR_OR_ZERO(gpiod);
> -		if (err) {
> +		if (IS_ERR(gpiod)) {
>   			dev_err(&pdev->dev,
>   				"Request failed for reset GPIO: %d\n", err);

    And here.

> -			return err;
> +			return PTR_ERR(gpiod);
>   		}
>   		tegra_phy->reset_gpio = gpiod;
>   

    Overall, this patch is broken and not even worth redoing -- the current 
code seems good...

MBR, Sergei

  reply	other threads:[~2020-09-11  8:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10 11:56 Tang Bin
2020-09-11  8:29 ` Sergei Shtylyov [this message]
2020-09-24  7:26 ` Felipe Balbi
2020-09-24 10:21   ` Thierry Reding
2020-09-24 10:37     ` Felipe Balbi
2020-09-28  8:47       ` Tang Bin

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=d0bd4d4c-0447-6c5f-6dc3-17e5ceae2623@gmail.com \
    --to=sergei.shtylyov@gmail.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=tangbin@cmss.chinamobile.com \
    --cc=thierry.reding@gmail.com \
    --cc=zhangshengju@cmss.chinamobile.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

Powered by JetHome