mtd: docg3: use devm_platform_ioremap_resource()
PATCH 1/1 mtd: docg3: use devm_platform_ioremap_resource()
Replace the open-coded platform_get_resource(IORESOURCE_MEM, 0) plus devm_ioremap() sequence with devm_platform_ioremap_resource(), which folds the resource lookup, region reservation and mapping into one step and returns an ERR_PTR checked with IS_ERR()/PTR_ERR().
The canonical docg3 register window is DOC_IOSPACE_SIZE (0x2000), which is the size any platform provides for this device, so mapping the full resource is equivalent to the previous fixed-size devm_ioremap().
Built for ARM (multi_v7_defconfig + CONFIG_MTD_DOCG3) with LLVM=1; drivers/mtd/devices/docg3.o compiles cleanly.
--- drivers/mtd/devices/docg3.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/mtd/devices/docg3.c +3 -13
@@ -1971,25 +1971,15 @@ static int __init docg3_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct mtd_info *mtd; -struct resource *ress;void __iomem *base;int ret, floor;struct docg3_cascade *cascade; - ret = -ENXIO ; - ress =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!ress) { -dev_err (dev,"No I/O memory resource defined\n" ); -return ret; - } + base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (base)) +return PTR_ERR (base); ret = -ENOMEM ; - base =devm_ioremap (dev, ress->start,DOC_IOSPACE_SIZE ); -if (!base) { -dev_err (dev,"devm_ioremap dev failed\n" ); -return ret; - } - cascade =devm_kcalloc (dev,DOC_MAX_NBFLOORS ,sizeof (*cascade),GFP_KERNEL );if (!cascade)
Signature · 1 line
2.55.0
Quoted 10 lines · Rosen Penev
Replace the open-coded
platform_get_resource(IORESOURCE_MEM, 0)plusdevm_ioremap()sequence withdevm_platform_ioremap_resource(), which folds the resource lookup, region reservation and mapping into one step and returns anERR_PTRchecked with IS_ERR()/PTR_ERR().The canonical docg3 register window is
DOC_IOSPACE_SIZE(0x2000), which is the size any platform provides for this device, so mapping the full resource is equivalent to the previous fixed-sizedevm_ioremap().[...]
Applied to mtd/next, thanks!
[1/1] mtd: docg3: use devm_platform_ioremap_resource()
commit: 8fcbb04ee5152b303980b2b48d69c6f7f4094ca6
Patche(s) should be available on mtd/linux.git and will be part of the next PR (provided that no robot complains by then).
Kind regards,
Miquèl