2018-07-19 23:45:24

by kernel test robot

[permalink] [raw]
Subject: drivers/pci/controller/dwc/pcie-kirin.c:141:1-3: WARNING: PTR_ERR_OR_ZERO can be used

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: fb7d1bcf1602b46f37ada72178516c01a250e434
commit: 6e0832fa432ec99c94caee733c8f5851cf85560b PCI: Collect all native drivers under drivers/pci/controller/
date: 6 weeks ago


coccinelle warnings: (new ones prefixed by >>)

>> drivers/pci/controller/dwc/pcie-kirin.c:141:1-3: WARNING: PTR_ERR_OR_ZERO can be used
drivers/pci/controller/dwc/pcie-kirin.c:177:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


2018-07-19 23:44:50

by Fengguang Wu

[permalink] [raw]
Subject: [PATCH] PCI: fix ptr_ret.cocci warnings

From: kbuild test robot <[email protected]>

drivers/pci/controller/dwc/pcie-kirin.c:141:1-3: WARNING: PTR_ERR_OR_ZERO can be used
drivers/pci/controller/dwc/pcie-kirin.c:177:1-3: WARNING: PTR_ERR_OR_ZERO can be used


Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

Generated by: scripts/coccinelle/api/ptr_ret.cocci

Fixes: 6e0832fa432e ("PCI: Collect all native drivers under drivers/pci/controller/")
CC: Shawn Lin <[email protected]>
Signed-off-by: kbuild test robot <[email protected]>
---

pcie-kirin.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

--- a/drivers/pci/controller/dwc/pcie-kirin.c
+++ b/drivers/pci/controller/dwc/pcie-kirin.c
@@ -138,10 +138,7 @@ static long kirin_pcie_get_clk(struct ki
return PTR_ERR(kirin_pcie->apb_sys_clk);

kirin_pcie->pcie_aclk = devm_clk_get(dev, "pcie_aclk");
- if (IS_ERR(kirin_pcie->pcie_aclk))
- return PTR_ERR(kirin_pcie->pcie_aclk);
-
- return 0;
+ return PTR_ERR_OR_ZERO(kirin_pcie->pcie_aclk);
}

static long kirin_pcie_get_resource(struct kirin_pcie *kirin_pcie,
@@ -174,10 +171,7 @@ static long kirin_pcie_get_resource(stru

kirin_pcie->sysctrl =
syscon_regmap_lookup_by_compatible("hisilicon,hi3660-sctrl");
- if (IS_ERR(kirin_pcie->sysctrl))
- return PTR_ERR(kirin_pcie->sysctrl);
-
- return 0;
+ return PTR_ERR_OR_ZERO(kirin_pcie->sysctrl);
}

static int kirin_pcie_phy_init(struct kirin_pcie *kirin_pcie)

2018-09-18 14:21:55

by Lorenzo Pieralisi

[permalink] [raw]
Subject: Re: [PATCH] PCI: fix ptr_ret.cocci warnings

On Fri, Jul 20, 2018 at 07:42:43AM +0800, kbuild test robot wrote:
> From: kbuild test robot <[email protected]>
>
> drivers/pci/controller/dwc/pcie-kirin.c:141:1-3: WARNING: PTR_ERR_OR_ZERO can be used
> drivers/pci/controller/dwc/pcie-kirin.c:177:1-3: WARNING: PTR_ERR_OR_ZERO can be used
>
>
> Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
>
> Generated by: scripts/coccinelle/api/ptr_ret.cocci
>
> Fixes: 6e0832fa432e ("PCI: Collect all native drivers under drivers/pci/controller/")
> CC: Shawn Lin <[email protected]>
> Signed-off-by: kbuild test robot <[email protected]>
> ---
>
> pcie-kirin.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)

Xiaowei, Binghui,

are you OK with this change ? I will remove the Fixes: tag from the
patch.

Let me know, thanks.

Lorenzo

> --- a/drivers/pci/controller/dwc/pcie-kirin.c
> +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> @@ -138,10 +138,7 @@ static long kirin_pcie_get_clk(struct ki
> return PTR_ERR(kirin_pcie->apb_sys_clk);
>
> kirin_pcie->pcie_aclk = devm_clk_get(dev, "pcie_aclk");
> - if (IS_ERR(kirin_pcie->pcie_aclk))
> - return PTR_ERR(kirin_pcie->pcie_aclk);
> -
> - return 0;
> + return PTR_ERR_OR_ZERO(kirin_pcie->pcie_aclk);
> }
>
> static long kirin_pcie_get_resource(struct kirin_pcie *kirin_pcie,
> @@ -174,10 +171,7 @@ static long kirin_pcie_get_resource(stru
>
> kirin_pcie->sysctrl =
> syscon_regmap_lookup_by_compatible("hisilicon,hi3660-sctrl");
> - if (IS_ERR(kirin_pcie->sysctrl))
> - return PTR_ERR(kirin_pcie->sysctrl);
> -
> - return 0;
> + return PTR_ERR_OR_ZERO(kirin_pcie->sysctrl);
> }
>
> static int kirin_pcie_phy_init(struct kirin_pcie *kirin_pcie)

2018-09-19 00:43:06

by Songxiaowei (Kirin_DRV)

[permalink] [raw]
Subject: RE: [PATCH] PCI: fix ptr_ret.cocci warnings

That's OK, and thank a lot.

> -----Original Message-----
> From: Lorenzo Pieralisi [mailto:[email protected]]
> Sent: Tuesday, September 18, 2018 10:21 PM
> To: kbuild test robot <[email protected]>; Songxiaowei (Kirin_DRV)
> <[email protected]>; Wangbinghui (Biggio, Kirin_DRV)
> <[email protected]>
> Cc: Shawn Lin <[email protected]>; [email protected];
> [email protected]; Bjorn Helgaas <[email protected]>
> Subject: Re: [PATCH] PCI: fix ptr_ret.cocci warnings
>
> On Fri, Jul 20, 2018 at 07:42:43AM +0800, kbuild test robot wrote:
> > From: kbuild test robot <[email protected]>
> >
> > drivers/pci/controller/dwc/pcie-kirin.c:141:1-3: WARNING:
> > PTR_ERR_OR_ZERO can be used
> > drivers/pci/controller/dwc/pcie-kirin.c:177:1-3: WARNING:
> > PTR_ERR_OR_ZERO can be used
> >
> >
> > Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
> >
> > Generated by: scripts/coccinelle/api/ptr_ret.cocci
> >
> > Fixes: 6e0832fa432e ("PCI: Collect all native drivers under
> > drivers/pci/controller/")
> > CC: Shawn Lin <[email protected]>
> > Signed-off-by: kbuild test robot <[email protected]>
> > ---
> >
> > pcie-kirin.c | 10 ++--------
> > 1 file changed, 2 insertions(+), 8 deletions(-)
>
> Xiaowei, Binghui,
>
> are you OK with this change ? I will remove the Fixes: tag from the patch.
>
> Let me know, thanks.
>
> Lorenzo
>
> > --- a/drivers/pci/controller/dwc/pcie-kirin.c
> > +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> > @@ -138,10 +138,7 @@ static long kirin_pcie_get_clk(struct ki
> > return PTR_ERR(kirin_pcie->apb_sys_clk);
> >
> > kirin_pcie->pcie_aclk = devm_clk_get(dev, "pcie_aclk");
> > - if (IS_ERR(kirin_pcie->pcie_aclk))
> > - return PTR_ERR(kirin_pcie->pcie_aclk);
> > -
> > - return 0;
> > + return PTR_ERR_OR_ZERO(kirin_pcie->pcie_aclk);
> > }
> >
> > static long kirin_pcie_get_resource(struct kirin_pcie *kirin_pcie, @@
> > -174,10 +171,7 @@ static long kirin_pcie_get_resource(stru
> >
> > kirin_pcie->sysctrl =
> > syscon_regmap_lookup_by_compatible("hisilicon,hi3660-sctrl");
> > - if (IS_ERR(kirin_pcie->sysctrl))
> > - return PTR_ERR(kirin_pcie->sysctrl);
> > -
> > - return 0;
> > + return PTR_ERR_OR_ZERO(kirin_pcie->sysctrl);
> > }
> >
> > static int kirin_pcie_phy_init(struct kirin_pcie *kirin_pcie)