mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
gpio: bt8xx: use devm_ioremap_resource()
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> Link: https://patch.msgid.link/20260713232810.1144712-1-rosenp@gmail.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
parent
a8e59e3ac9
commit
bbd8254da1
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user