mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gpio: bt8xx: use devm_ioremap_resource()
@ 2026-07-13 23:28 Rosen Penev
  2026-07-17  8:58 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-07-13 23:28 UTC (permalink / raw)
  To: linux-gpio
  Cc: Michael Buesch, Linus Walleij, Bartosz Golaszewski,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

Replace the open-coded devm_request_mem_region() plus devm_ioremap()
sequence with a single devm_ioremap_resource() call on the BAR0 resource.
This reserves the region and maps it in one step, and maps the full BAR
length instead of a hardcoded 0x1000 (BAR0 on the bt848/878 is a 4KB
register block, so the mapped size is unchanged).

devm_ioremap_resource() returns an ERR_PTR on failure, so check with
IS_ERR() and propagate PTR_ERR(). Drop the now-redundant error message,
as devm_ioremap_resource() already logs on every failure path. Since it
can return -EPROBE_DEFER, place it early.

Built for ARM (defconfig + CONFIG_GPIO_BT8XX) with LLVM=1;
drivers/gpio/gpio-bt8xx.o compiles cleanly.

Assisted-by: opencode:hy3-free
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/gpio/gpio-bt8xx.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/gpio/gpio-bt8xx.c b/drivers/gpio/gpio-bt8xx.c
index 324eeb77dbd5..f3a2321bc388 100644
--- a/drivers/gpio/gpio-bt8xx.c
+++ b/drivers/gpio/gpio-bt8xx.c
@@ -154,12 +154,18 @@ static int bt8xxgpio_probe(struct pci_dev *dev,
 			const struct pci_device_id *pci_id)
 {
 	struct bt8xxgpio *bg;
+	void __iomem *mmio;
 	int err;
 
+	mmio = devm_ioremap_resource(&dev->dev, pci_resource_n(dev, 0));
+	if (IS_ERR(mmio))
+		return PTR_ERR(mmio);
+
 	bg = devm_kzalloc(&dev->dev, sizeof(struct bt8xxgpio), GFP_KERNEL);
 	if (!bg)
 		return -ENOMEM;
 
+	bg->mmio = mmio;
 	bg->pdev = dev;
 	spin_lock_init(&bg->lock);
 
@@ -168,24 +174,9 @@ static int bt8xxgpio_probe(struct pci_dev *dev,
 		dev_err(&dev->dev, "can't enable device.\n");
 		return err;
 	}
-	if (!devm_request_mem_region(&dev->dev, pci_resource_start(dev, 0),
-				pci_resource_len(dev, 0),
-				"bt8xxgpio")) {
-		dev_warn(&dev->dev, "can't request iomem (0x%llx).\n",
-		       (unsigned long long)pci_resource_start(dev, 0));
-		err = -EBUSY;
-		goto err_disable;
-	}
 	pci_set_master(dev);
 	pci_set_drvdata(dev, bg);
 
-	bg->mmio = devm_ioremap(&dev->dev, pci_resource_start(dev, 0), 0x1000);
-	if (!bg->mmio) {
-		dev_err(&dev->dev, "ioremap() failed\n");
-		err = -EIO;
-		goto err_disable;
-	}
-
 	/* Disable interrupts */
 	bgwrite(0, BT848_INT_MASK);
 
-- 
2.55.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpio: bt8xx: use devm_ioremap_resource()
  2026-07-13 23:28 [PATCH] gpio: bt8xx: use devm_ioremap_resource() Rosen Penev
@ 2026-07-17  8:58 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2026-07-17  8:58 UTC (permalink / raw)
  To: linux-gpio, Rosen Penev
  Cc: Bartosz Golaszewski, Michael Buesch, Linus Walleij,
	Bartosz Golaszewski, Nathan Chancellor, Bill Wendling,
	Justin Stitt, linux-kernel, llvm, Nick Desaulniers


On Mon, 13 Jul 2026 16:28:10 -0700, Rosen Penev wrote:
> Replace the open-coded devm_request_mem_region() plus devm_ioremap()
> sequence with a single devm_ioremap_resource() call on the BAR0 resource.
> This reserves the region and maps it in one step, and maps the full BAR
> length instead of a hardcoded 0x1000 (BAR0 on the bt848/878 is a 4KB
> register block, so the mapped size is unchanged).
> 
> devm_ioremap_resource() returns an ERR_PTR on failure, so check with
> IS_ERR() and propagate PTR_ERR(). Drop the now-redundant error message,
> as devm_ioremap_resource() already logs on every failure path. Since it
> can return -EPROBE_DEFER, place it early.
> 
> [...]

Applied, thanks!

[1/1] gpio: bt8xx: use devm_ioremap_resource()
      https://git.kernel.org/brgl/c/bbd8254da11c189072349003006091e8327e8d36

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-17  8:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-13 23:28 [PATCH] gpio: bt8xx: use devm_ioremap_resource() Rosen Penev
2026-07-17  8:58 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox