public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>, Jens Axboe <axboe@kernel.dk>,
	Philipp Zabel <p.zabel@pengutronix.de>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Allison Randal <allison@lohutok.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] ata: brcm: fix reset controller API usage
Date: Tue, 7 Jan 2020 14:52:56 -0800	[thread overview]
Message-ID: <6fb53662-ebdb-55de-c470-0aa1c447bbd0@gmail.com> (raw)
In-Reply-To: <20200107221506.2731280-2-arnd@arndb.de>

On 1/7/20 2:15 PM, Arnd Bergmann wrote:
> While fixing another issue in this driver I noticed it uses
> IS_ERR_OR_NULL(), which is almost always a mistake.
> 
> Change the driver to use the proper devm_reset_control_get_optional()
> interface instead and remove the checks except for the one that
> checks for a failure in that function.
> 
> Fixes: 2b2c47d9e1fe ("ata: ahci_brcm: Allow optional reset controller to be used")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

This is nearly equivalent to:

https://lore.kernel.org/lkml/20200107183022.26224-2-f.fainelli@gmail.com/

which was just submitted this morning. Thanks!

> ---
>  drivers/ata/ahci_brcm.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/ata/ahci_brcm.c b/drivers/ata/ahci_brcm.c
> index 239333d11b88..7ac1141c6ad0 100644
> --- a/drivers/ata/ahci_brcm.c
> +++ b/drivers/ata/ahci_brcm.c
> @@ -352,8 +352,7 @@ static int brcm_ahci_suspend(struct device *dev)
>  	else
>  		ret = 0;
>  
> -	if (!IS_ERR_OR_NULL(priv->rcdev))
> -		reset_control_assert(priv->rcdev);
> +	reset_control_assert(priv->rcdev);
>  
>  	return ret;
>  }
> @@ -365,8 +364,7 @@ static int __maybe_unused brcm_ahci_resume(struct device *dev)
>  	struct brcm_ahci_priv *priv = hpriv->plat_data;
>  	int ret = 0;
>  
> -	if (!IS_ERR_OR_NULL(priv->rcdev))
> -		ret = reset_control_deassert(priv->rcdev);
> +	ret = reset_control_deassert(priv->rcdev);
>  	if (ret)
>  		return ret;
>  
> @@ -454,9 +452,11 @@ static int brcm_ahci_probe(struct platform_device *pdev)
>  	else
>  		reset_name = "ahci";
>  
> -	priv->rcdev = devm_reset_control_get(&pdev->dev, reset_name);
> -	if (!IS_ERR_OR_NULL(priv->rcdev))
> -		reset_control_deassert(priv->rcdev);
> +	priv->rcdev = devm_reset_control_get_optional(&pdev->dev, reset_name);
> +	if (IS_ERR(priv->rcdev))
> +		return PTR_ERR(priv->rcdev);
> +
> +	reset_control_deassert(priv->rcdev);
>  
>  	hpriv = ahci_platform_get_resources(pdev, 0);
>  	if (IS_ERR(hpriv)) {
> @@ -520,8 +520,7 @@ static int brcm_ahci_probe(struct platform_device *pdev)
>  out_disable_clks:
>  	ahci_platform_disable_clks(hpriv);
>  out_reset:
> -	if (!IS_ERR_OR_NULL(priv->rcdev))
> -		reset_control_assert(priv->rcdev);
> +	reset_control_assert(priv->rcdev);
>  	return ret;
>  }
>  
> 


-- 
Florian

  reply	other threads:[~2020-01-07 22:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 22:14 [PATCH 1/2] ata: brcm: mark PM functions as __maybe_unused Arnd Bergmann
2020-01-07 22:15 ` [PATCH 2/2] ata: brcm: fix reset controller API usage Arnd Bergmann
2020-01-07 22:52   ` Florian Fainelli [this message]
2020-01-07 22:51 ` [PATCH 1/2] ata: brcm: mark PM functions as __maybe_unused Florian Fainelli

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=6fb53662-ebdb-55de-c470-0aa1c447bbd0@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=allison@lohutok.net \
    --cc=arnd@arndb.de \
    --cc=axboe@kernel.dk \
    --cc=hdegoede@redhat.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=tglx@linutronix.de \
    /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