ata: pata_rb532_cf: use devm_platform_ioremap_resource()
PATCH 1/1 ata: pata_rb532_cf: use devm_platform_ioremap_resource()
Replace the open-coded platform_get_resource() plus devm_ioremap() sequence with a single devm_platform_ioremap_resource() call, which folds the resource lookup and mapping into one step and returns an ERR_PTR on failure, checked with IS_ERR() and propagated via PTR_ERR(). Similar to platform_get_irq(), it can return -EPROBE_DEFER so move it early.
The pata-rb532-cf platform device (arch/mips/rb532/devices.c) provides a single IORESOURCE_MEM window at the DEV1BASE chip-select, distinct from the other RB532 chip-selects, so the region reservation now performed by devm_platform_ioremap_resource() introduces no conflict. The mapped size is unchanged. Drop the redundant error message, as devm_platform_ioremap_resource() already logs on failure.
Built for MIPS (rb532_defconfig) with LLVM=1;drivers/ata/pata_rb532_cf.o compiles cleanly.
--- drivers/ata/pata_rb532_cf.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/ata/pata_rb532_cf.c +5 -11
@@ -103,16 +103,14 @@ static int rb532_pata_driver_probe(struct platform_device *pdev) {int irq;struct gpio_desc *gpiod; -struct resource *res;struct ata_host *ah;struct rb532_cf_info *info; +void __iomem *iobase;int ret; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { -dev_err (&pdev->dev,"no IOMEM resource found\n" ); -return -EINVAL ; - } + iobase =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (iobase)) +return PTR_ERR (iobase); irq =platform_get_irq (pdev,0 );if (irq <0 )
@@ -139,11 +137,7 @@ static int rb532_pata_driver_probe(struct platform_device *pdev) ah->private_data = info; info->gpio_line = gpiod; info->irq = irq; - - info->iobase =devm_ioremap (&pdev->dev, res->start, -resource_size (res)); -if (!info->iobase) -return -ENOMEM ; + info->iobase = iobase;rb532_pata_setup_ports (ah);
Signature · 1 line
2.55.0
Quoted 13 lines · Rosen Penev
Replace the open-coded
platform_get_resource()plusdevm_ioremap()sequence with a singledevm_platform_ioremap_resource()call, which folds the resource lookup and mapping into one step and returns anERR_PTRon failure, checked withIS_ERR()and propagated viaPTR_ERR(). Similar toplatform_get_irq(), it can return -EPROBE_DEFER so move it early.The pata-rb532-cf platform device (
arch/mips/rb532/devices.c) provides a singleIORESOURCE_MEMwindow at the DEV1BASE chip-select, distinct from the other RB532 chip-selects, so the region reservation now performed bydevm_platform_ioremap_resource()introduces no conflict. The mapped size is unchanged. Drop the redundant error message, asdevm_platform_ioremap_resource()already logs on failure.
Quoted 5 lines
Built for MIPS (
rb532_defconfig) with LLVM=1;drivers/ata/pata_rb532_cf.ocompiles cleanly.Assisted-by opencode:hy3-freeSigned-off-by Rosen Penev <[email protected]>
Applied to for-7.3. Thanks!
Signature · 2 lines
Damien Le Moal Western Digital Research