Re: [PATCH] PCI: dwc: Use PTR_ERR_OR_ZERO() in five functions

From: Andrew Murray
Date: Fri Sep 06 2019 - 15:30:47 EST


On Fri, Sep 06, 2019 at 08:50:07PM +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> Date: Fri, 6 Sep 2019 20:40:06 +0200
>
> Simplify these function implementations by using a known function.
>
> Generated by: scripts/coccinelle/api/ptr_ret.cocci
>
> Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>

Thanks for this, looks good to me:

Reviewed-by: Andrew Murray <andrew.murray@xxxxxxx>

> ---
> drivers/pci/controller/dwc/pci-exynos.c | 5 +----
> drivers/pci/controller/dwc/pci-meson.c | 10 ++--------
> drivers/pci/controller/dwc/pcie-kirin.c | 10 ++--------
> 3 files changed, 5 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-exynos.c b/drivers/pci/controller/dwc/pci-exynos.c
> index cee5f2f590e2..b6ab1cc5d895 100644
> --- a/drivers/pci/controller/dwc/pci-exynos.c
> +++ b/drivers/pci/controller/dwc/pci-exynos.c
> @@ -92,10 +92,7 @@ static int exynos5440_pcie_get_mem_resources(struct platform_device *pdev,
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> ep->mem_res->elbi_base = devm_ioremap_resource(dev, res);
> - if (IS_ERR(ep->mem_res->elbi_base))
> - return PTR_ERR(ep->mem_res->elbi_base);
> -
> - return 0;
> + return PTR_ERR_OR_ZERO(ep->mem_res->elbi_base);
> }
>
> static int exynos5440_pcie_get_clk_resources(struct exynos_pcie *ep)
> diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c
> index e35e9eaa50ee..713059918002 100644
> --- a/drivers/pci/controller/dwc/pci-meson.c
> +++ b/drivers/pci/controller/dwc/pci-meson.c
> @@ -182,10 +182,7 @@ static int meson_pcie_get_mems(struct platform_device *pdev,
>
> /* Meson SoC has two PCI controllers use same phy register*/
> mp->mem_res.phy_base = meson_pcie_get_mem_shared(pdev, mp, "phy");
> - if (IS_ERR(mp->mem_res.phy_base))
> - return PTR_ERR(mp->mem_res.phy_base);
> -
> - return 0;
> + return PTR_ERR_OR_ZERO(mp->mem_res.phy_base);
> }
>
> static void meson_pcie_power_on(struct meson_pcie *mp)
> @@ -259,10 +256,7 @@ static int meson_pcie_probe_clocks(struct meson_pcie *mp)
> return PTR_ERR(res->general_clk);
>
> res->clk = meson_pcie_probe_clock(dev, "pcie", 0);
> - if (IS_ERR(res->clk))
> - return PTR_ERR(res->clk);
> -
> - return 0;
> + return PTR_ERR_OR_ZERO(res->clk);
> }
>
> static inline void meson_elb_writel(struct meson_pcie *mp, u32 val, u32 reg)
> diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> index c19617a912bd..75b1f1dde747 100644
> --- 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 kirin_pcie *kirin_pcie,
> 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(struct kirin_pcie *kirin_pcie,
>
> 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)
> --
> 2.23.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel