[PATCH 1/2] gpio: pci-idio-16: Replace deprecated PCI functions

William Breathitt Gray posted 2 patches 3 weeks, 2 days ago
[PATCH 1/2] gpio: pci-idio-16: Replace deprecated PCI functions
Posted by William Breathitt Gray 3 weeks, 2 days ago
pcim_iomap_regions() and pcim_iomap_table() have been deprecated in
commit e354bb84a4c1 ("PCI: Deprecate pcim_iomap_table(),
pcim_iomap_regions_request_all()"). Replace these functions with
pcim_iomap_region().

In order to match the rest of the code in idio_16_probe(), utilize
dev_err_probe() to handle error for pcim_enable_device().

Signed-off-by: William Breathitt Gray <wbg@kernel.org>
---
 drivers/gpio/gpio-pci-idio-16.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
index 44c0a21b1d1d9f1ba4e013ba0947ccae78288d5c..64f332c805507645039615e0a89b83175f6bb616 100644
--- a/drivers/gpio/gpio-pci-idio-16.c
+++ b/drivers/gpio/gpio-pci-idio-16.c
@@ -70,24 +70,17 @@ static int idio_16_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	struct device *const dev = &pdev->dev;
 	int err;
 	const size_t pci_bar_index = 2;
-	const char *const name = pci_name(pdev);
 	struct idio_16_regmap_config config = {};
 	void __iomem *regs;
 	struct regmap *map;
 
 	err = pcim_enable_device(pdev);
-	if (err) {
-		dev_err(dev, "Failed to enable PCI device (%d)\n", err);
-		return err;
-	}
-
-	err = pcim_iomap_regions(pdev, BIT(pci_bar_index), name);
-	if (err) {
-		dev_err(dev, "Unable to map PCI I/O addresses (%d)\n", err);
-		return err;
-	}
+	if (err)
+		return dev_err_probe(dev, err, "Failed to enable PCI device\n");
 
-	regs = pcim_iomap_table(pdev)[pci_bar_index];
+	regs = pcim_iomap_region(pdev, pci_bar_index, pci_name(pdev));
+	if (IS_ERR(regs))
+		return dev_err_probe(dev, PTR_ERR(regs), "Unable to map PCI I/O addresses\n");
 
 	map = devm_regmap_init_mmio(dev, regs, &idio_16_regmap_config);
 	if (IS_ERR(map))

-- 
2.47.0
Re: [PATCH 1/2] gpio: pci-idio-16: Replace deprecated PCI functions
Posted by Linus Walleij 3 weeks, 2 days ago
On Fri, Nov 1, 2024 at 8:15 AM William Breathitt Gray <wbg@kernel.org> wrote:

> pcim_iomap_regions() and pcim_iomap_table() have been deprecated in
> commit e354bb84a4c1 ("PCI: Deprecate pcim_iomap_table(),
> pcim_iomap_regions_request_all()"). Replace these functions with
> pcim_iomap_region().
>
> In order to match the rest of the code in idio_16_probe(), utilize
> dev_err_probe() to handle error for pcim_enable_device().
>
> Signed-off-by: William Breathitt Gray <wbg@kernel.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij