From: Sebastian Reichel <sre@kernel.org>
To: Tang Bin <tangbin@cmss.chinamobile.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Subject: Re: [PATCH] power: supply: cpcap-battery: Use IS_ERR() to check and simplify code
Date: Fri, 6 Aug 2021 23:47:13 +0200 [thread overview]
Message-ID: <20210806214713.p7ygp2iux6wjxk5n@earth.universe> (raw)
In-Reply-To: <20210720061836.29148-1-tangbin@cmss.chinamobile.com>
[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]
Hi,
On Tue, Jul 20, 2021 at 02:18:36PM +0800, 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>
> ---
I think the original variant is the simpler one. Also
compiler should be able to optimize this.
-- Sebastian
> drivers/power/supply/cpcap-battery.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
> index 90eba3646..7007e5d53 100644
> --- a/drivers/power/supply/cpcap-battery.c
> +++ b/drivers/power/supply/cpcap-battery.c
> @@ -912,10 +912,9 @@ static int cpcap_battery_probe(struct platform_device *pdev)
>
> ddata->psy = devm_power_supply_register(ddata->dev, psy_desc,
> &psy_cfg);
> - error = PTR_ERR_OR_ZERO(ddata->psy);
> - if (error) {
> + if (IS_ERR(ddata->psy)) {
> dev_err(ddata->dev, "failed to register power supply\n");
> - return error;
> + return PTR_ERR(ddata->psy);
> }
>
> atomic_set(&ddata->active, 1);
> --
> 2.20.1.windows.1
>
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2021-08-06 21:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-20 6:18 [PATCH] power: supply: cpcap-battery: Use IS_ERR() to check and simplify code Tang Bin
2021-08-06 21:47 ` Sebastian Reichel [this message]
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=20210806214713.p7ygp2iux6wjxk5n@earth.universe \
--to=sre@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=tangbin@cmss.chinamobile.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;
as well as URLs for NNTP newsgroup(s).