Skip to content

Commit

Permalink
PCI: iproc: Convert to platform remove callback returning void
Browse files Browse the repository at this point in the history
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks.

The iproc driver always returns 0, it's just a bit hidden. So make
iproc_pcie_remove() return void instead of always zero and convert the
platform driver to the alternative remove callback that returns void and
eventually replaces the int returning callback.

Link: https://lore.kernel.org/linux-pci/20230321193208.366561-9-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
  • Loading branch information
Uwe Kleine-König authored and Krzysztof Wilczyński committed Jun 24, 2023
1 parent 9a285fb commit 6f1c0a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions drivers/pci/controller/pcie-iproc-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ static int iproc_pltfm_pcie_probe(struct platform_device *pdev)
return 0;
}

static int iproc_pltfm_pcie_remove(struct platform_device *pdev)
static void iproc_pltfm_pcie_remove(struct platform_device *pdev)
{
struct iproc_pcie *pcie = platform_get_drvdata(pdev);

return iproc_pcie_remove(pcie);
iproc_pcie_remove(pcie);
}

static void iproc_pltfm_pcie_shutdown(struct platform_device *pdev)
Expand All @@ -134,7 +134,7 @@ static struct platform_driver iproc_pltfm_pcie_driver = {
.of_match_table = of_match_ptr(iproc_pcie_of_match_table),
},
.probe = iproc_pltfm_pcie_probe,
.remove = iproc_pltfm_pcie_remove,
.remove_new = iproc_pltfm_pcie_remove,
.shutdown = iproc_pltfm_pcie_shutdown,
};
module_platform_driver(iproc_pltfm_pcie_driver);
Expand Down
4 changes: 1 addition & 3 deletions drivers/pci/controller/pcie-iproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
}
EXPORT_SYMBOL(iproc_pcie_setup);

int iproc_pcie_remove(struct iproc_pcie *pcie)
void iproc_pcie_remove(struct iproc_pcie *pcie)
{
struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);

Expand All @@ -1548,8 +1548,6 @@ int iproc_pcie_remove(struct iproc_pcie *pcie)

phy_power_off(pcie->phy);
phy_exit(pcie->phy);

return 0;
}
EXPORT_SYMBOL(iproc_pcie_remove);

Expand Down
2 changes: 1 addition & 1 deletion drivers/pci/controller/pcie-iproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct iproc_pcie {
};

int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
int iproc_pcie_remove(struct iproc_pcie *pcie);
void iproc_pcie_remove(struct iproc_pcie *pcie);
int iproc_pcie_shutdown(struct iproc_pcie *pcie);

#ifdef CONFIG_PCIE_IPROC_MSI
Expand Down

0 comments on commit 6f1c0a0

Please sign in to comment.