linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@kernel.org>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: power: supply: Compress return logic into one line.
Date: Tue, 17 Jan 2017 00:42:38 +0100	[thread overview]
Message-ID: <20170116234238.wqj4qmtm5uln2nsw@earth> (raw)
In-Reply-To: <20170112024557.GA23047@embeddedgus>

[-- Attachment #1: Type: text/plain, Size: 2360 bytes --]

Hi,

On Wed, Jan 11, 2017 at 08:45:57PM -0600, Gustavo A. R. Silva wrote:
> Simplify return logic to avoid unnecessary variable assignments.
> These issues were detected using Coccinelle and the following semantic patch:
> 
> @@
> local idexpression ret;
> expression e;
> @@
> 
> -ret =
> +return
>      e;
> -return ret;
> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/power/supply/pcf50633-charger.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/power/supply/pcf50633-charger.c b/drivers/power/supply/pcf50633-charger.c
> index d05597b..b3c1873 100644
> --- a/drivers/power/supply/pcf50633-charger.c
> +++ b/drivers/power/supply/pcf50633-charger.c
> @@ -393,7 +393,6 @@ static int pcf50633_mbc_probe(struct platform_device *pdev)
>  {
>  	struct power_supply_config psy_cfg = {};
>  	struct pcf50633_mbc *mbc;
> -	int ret;
>  	int i;
>  	u8 mbcs1;
>  
> @@ -419,8 +418,7 @@ static int pcf50633_mbc_probe(struct platform_device *pdev)
>  					     &psy_cfg);
>  	if (IS_ERR(mbc->adapter)) {
>  		dev_err(mbc->pcf->dev, "failed to register adapter\n");
> -		ret = PTR_ERR(mbc->adapter);
> -		return ret;
> +		return PTR_ERR(mbc->adapter);
>  	}
>  
>  	mbc->usb = power_supply_register(&pdev->dev, &pcf50633_mbc_usb_desc,
> @@ -428,8 +426,7 @@ static int pcf50633_mbc_probe(struct platform_device *pdev)
>  	if (IS_ERR(mbc->usb)) {
>  		dev_err(mbc->pcf->dev, "failed to register usb\n");
>  		power_supply_unregister(mbc->adapter);
> -		ret = PTR_ERR(mbc->usb);
> -		return ret;
> +		return PTR_ERR(mbc->usb);
>  	}
>  
>  	mbc->ac = power_supply_register(&pdev->dev, &pcf50633_mbc_ac_desc,
> @@ -438,12 +435,10 @@ static int pcf50633_mbc_probe(struct platform_device *pdev)
>  		dev_err(mbc->pcf->dev, "failed to register ac\n");
>  		power_supply_unregister(mbc->adapter);
>  		power_supply_unregister(mbc->usb);
> -		ret = PTR_ERR(mbc->ac);
> -		return ret;
> +		return PTR_ERR(mbc->ac);
>  	}
>  
> -	ret = sysfs_create_group(&pdev->dev.kobj, &mbc_attr_group);
> -	if (ret)
> +	if (sysfs_create_group(&pdev->dev.kobj, &mbc_attr_group))
>  		dev_err(mbc->pcf->dev, "failed to create sysfs entries\n");
>  
>  	mbcs1 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS1);

Thanks, queued.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-01-16 23:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-12  2:45 [PATCH] drivers: power: supply: Compress return logic into one line Gustavo A. R. Silva
2017-01-16 23:42 ` Sebastian Reichel [this message]
2017-01-19 22:25   ` Gustavo A. R. Silva
  -- strict thread matches above, loose matches on Subject: below --
2017-01-12  2:29 Gustavo A. R. Silva
2017-01-16 23:42 ` Sebastian Reichel
2017-01-19 22:24   ` Gustavo A. R. Silva

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=20170116234238.wqj4qmtm5uln2nsw@earth \
    --to=sre@kernel.org \
    --cc=garsilva@embeddedor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).