2023-07-07 04:29:25

by 李扬韬

[permalink] [raw]
Subject: [PATCH 01/18] mtd: rawnand: sunxi: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/nand/raw/sunxi_nand.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
index 9884304634f6..db36bd755b8d 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -2087,8 +2087,7 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
nand_controller_init(&nfc->controller);
INIT_LIST_HEAD(&nfc->chips);

- r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- nfc->regs = devm_ioremap_resource(dev, r);
+ nfc->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
if (IS_ERR(nfc->regs))
return PTR_ERR(nfc->regs);

--
2.39.0



2023-07-07 04:32:37

by 李扬韬

[permalink] [raw]
Subject: [PATCH 08/18] mtd: rawnand: fsl_upm: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/nand/raw/fsl_upm.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/fsl_upm.c b/drivers/mtd/nand/raw/fsl_upm.c
index 086426139173..f1810e2f2c07 100644
--- a/drivers/mtd/nand/raw/fsl_upm.c
+++ b/drivers/mtd/nand/raw/fsl_upm.c
@@ -172,8 +172,7 @@ static int fun_probe(struct platform_device *ofdev)
if (!fun)
return -ENOMEM;

- io_res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
- fun->io_base = devm_ioremap_resource(&ofdev->dev, io_res);
+ fun->io_base = devm_platform_get_and_ioremap_resource(ofdev, 0, &io_res);
if (IS_ERR(fun->io_base))
return PTR_ERR(fun->io_base);

--
2.39.0


2023-07-07 04:34:02

by 李扬韬

[permalink] [raw]
Subject: [PATCH 18/18] mtd: physmap-core: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/maps/physmap-core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c
index c73854da5136..78710fbc8e7f 100644
--- a/drivers/mtd/maps/physmap-core.c
+++ b/drivers/mtd/maps/physmap-core.c
@@ -508,8 +508,7 @@ static int physmap_flash_probe(struct platform_device *dev)
for (i = 0; i < info->nmaps; i++) {
struct resource *res;

- res = platform_get_resource(dev, IORESOURCE_MEM, i);
- info->maps[i].virt = devm_ioremap_resource(&dev->dev, res);
+ info->maps[i].virt = devm_platform_get_and_ioremap_resource(dev, i, &res);
if (IS_ERR(info->maps[i].virt)) {
err = PTR_ERR(info->maps[i].virt);
goto err_out;
--
2.39.0


2023-07-07 04:35:20

by 李扬韬

[permalink] [raw]
Subject: [PATCH 17/18] mtd: spear_smi: Convert to devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/devices/spear_smi.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
index cc17133be297..93bca5225116 100644
--- a/drivers/mtd/devices/spear_smi.c
+++ b/drivers/mtd/devices/spear_smi.c
@@ -937,7 +937,6 @@ static int spear_smi_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node;
struct spear_smi_plat_data *pdata = NULL;
struct spear_smi *dev;
- struct resource *smi_base;
int irq, ret = 0;
int i;

@@ -975,9 +974,7 @@ static int spear_smi_probe(struct platform_device *pdev)
goto err;
}

- smi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
- dev->io_base = devm_ioremap_resource(&pdev->dev, smi_base);
+ dev->io_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(dev->io_base)) {
ret = PTR_ERR(dev->io_base);
goto err;
--
2.39.0


2023-07-07 04:36:37

by 李扬韬

[permalink] [raw]
Subject: [PATCH 07/18] mtd: rawnand: lpc32xx_mlc: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/nand/raw/lpc32xx_mlc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/lpc32xx_mlc.c b/drivers/mtd/nand/raw/lpc32xx_mlc.c
index b3136ae6f4e9..488fd452611a 100644
--- a/drivers/mtd/nand/raw/lpc32xx_mlc.c
+++ b/drivers/mtd/nand/raw/lpc32xx_mlc.c
@@ -695,8 +695,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)

host->pdev = pdev;

- rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- host->io_base = devm_ioremap_resource(&pdev->dev, rc);
+ host->io_base = devm_platform_get_and_ioremap_resource(pdev, 0, &rc);
if (IS_ERR(host->io_base))
return PTR_ERR(host->io_base);

--
2.39.0


2023-07-07 04:40:28

by 李扬韬

[permalink] [raw]
Subject: [PATCH 06/18] mtd: rawnand: stm32_fmc2: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/nand/raw/stm32_fmc2_nand.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
index 10c11cecac08..2f9e43f64dd7 100644
--- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c
+++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
@@ -1922,8 +1922,8 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
if (!(nfc->cs_assigned & BIT(chip_cs)))
continue;

- res = platform_get_resource(pdev, IORESOURCE_MEM, mem_region);
- nfc->data_base[chip_cs] = devm_ioremap_resource(dev, res);
+ nfc->data_base[chip_cs] = devm_platform_get_and_ioremap_resource(pdev,
+ mem_region, &res);
if (IS_ERR(nfc->data_base[chip_cs]))
return PTR_ERR(nfc->data_base[chip_cs]);

--
2.39.0


2023-07-07 04:40:31

by 李扬韬

[permalink] [raw]
Subject: [PATCH 15/18] mtd: lpddr2_nvm: Convert to devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/lpddr/lpddr2_nvm.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mtd/lpddr/lpddr2_nvm.c b/drivers/mtd/lpddr/lpddr2_nvm.c
index e71af4c49096..f4e5174b2449 100644
--- a/drivers/mtd/lpddr/lpddr2_nvm.c
+++ b/drivers/mtd/lpddr/lpddr2_nvm.c
@@ -412,7 +412,6 @@ static int lpddr2_nvm_probe(struct platform_device *pdev)
struct map_info *map;
struct mtd_info *mtd;
struct resource *add_range;
- struct resource *control_regs;
struct pcm_int_data *pcm_data;

/* Allocate memory control_regs data structures */
@@ -452,8 +451,7 @@ static int lpddr2_nvm_probe(struct platform_device *pdev)

simple_map_init(map); /* fill with default methods */

- control_regs = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- pcm_data->ctl_regs = devm_ioremap_resource(&pdev->dev, control_regs);
+ pcm_data->ctl_regs = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(pcm_data->ctl_regs))
return PTR_ERR(pcm_data->ctl_regs);

--
2.39.0


2023-07-07 04:47:01

by 李扬韬

[permalink] [raw]
Subject: [PATCH 02/18] mtd: rawnand: lpc32xx_slc: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/nand/raw/lpc32xx_slc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/lpc32xx_slc.c b/drivers/mtd/nand/raw/lpc32xx_slc.c
index 3139b6107660..2201264d3c37 100644
--- a/drivers/mtd/nand/raw/lpc32xx_slc.c
+++ b/drivers/mtd/nand/raw/lpc32xx_slc.c
@@ -836,8 +836,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
if (!host)
return -ENOMEM;

- rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- host->io_base = devm_ioremap_resource(&pdev->dev, rc);
+ host->io_base = devm_platform_get_and_ioremap_resource(pdev, 0, &rc);
if (IS_ERR(host->io_base))
return PTR_ERR(host->io_base);

--
2.39.0


2023-07-07 04:47:05

by 李扬韬

[permalink] [raw]
Subject: [PATCH 10/18] mtd: rawnand: atmel: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/nand/raw/atmel/nand-controller.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c
index 81e3d682a8cd..3f494f7c7ecb 100644
--- a/drivers/mtd/nand/raw/atmel/nand-controller.c
+++ b/drivers/mtd/nand/raw/atmel/nand-controller.c
@@ -1791,8 +1791,7 @@ atmel_nand_controller_legacy_add_nands(struct atmel_nand_controller *nc)

nand->numcs = 1;

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- nand->cs[0].io.virt = devm_ioremap_resource(dev, res);
+ nand->cs[0].io.virt = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(nand->cs[0].io.virt))
return PTR_ERR(nand->cs[0].io.virt);

--
2.39.0


2023-07-07 04:47:15

by 李扬韬

[permalink] [raw]
Subject: [PATCH 09/18] mtd: rawnand: davinci: Convert to devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/nand/raw/davinci_nand.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/nand/raw/davinci_nand.c b/drivers/mtd/nand/raw/davinci_nand.c
index 415d6aaa8255..2db1cd1d3d03 100644
--- a/drivers/mtd/nand/raw/davinci_nand.c
+++ b/drivers/mtd/nand/raw/davinci_nand.c
@@ -710,8 +710,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
{
struct davinci_nand_pdata *pdata;
struct davinci_nand_info *info;
- struct resource *res1;
- struct resource *res2;
+ struct resource *res;
void __iomem *vaddr;
void __iomem *base;
int ret;
@@ -736,26 +735,24 @@ static int nand_davinci_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, info);

- res1 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if (!res1 || !res2) {
- dev_err(&pdev->dev, "resource missing\n");
- return -EINVAL;
- }
-
- vaddr = devm_ioremap_resource(&pdev->dev, res1);
+ vaddr = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(vaddr))
return PTR_ERR(vaddr);

+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ if (!res) {
+ dev_err(&pdev->dev, "resource missing\n");
+ return -EINVAL;
+ }
/*
* This registers range is used to setup NAND settings. In case with
* TI AEMIF driver, the same memory address range is requested already
* by AEMIF, so we cannot request it twice, just ioremap.
* The AEMIF and NAND drivers not use the same registers in this range.
*/
- base = devm_ioremap(&pdev->dev, res2->start, resource_size(res2));
+ base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
if (!base) {
- dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res2);
+ dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res);
return -EADDRNOTAVAIL;
}

--
2.39.0


2023-07-07 04:47:22

by 李扬韬

[permalink] [raw]
Subject: [PATCH 12/18] mtd: nand: omap: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/nand/onenand/onenand_omap2.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/onenand/onenand_omap2.c b/drivers/mtd/nand/onenand/onenand_omap2.c
index ff7af98604df..b39aee023103 100644
--- a/drivers/mtd/nand/onenand/onenand_omap2.c
+++ b/drivers/mtd/nand/onenand/onenand_omap2.c
@@ -467,11 +467,9 @@ static int omap2_onenand_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(dev, "error getting memory resource\n");
- return -EINVAL;
- }
+ c->onenand.base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+ if (IS_ERR(c->onenand.base))
+ return PTR_ERR(c->onenand.base);

r = of_property_read_u32(np, "reg", &val);
if (r) {
@@ -488,10 +486,6 @@ static int omap2_onenand_probe(struct platform_device *pdev)
c->gpmc_cs = val;
c->phys_base = res->start;

- c->onenand.base = devm_ioremap_resource(dev, res);
- if (IS_ERR(c->onenand.base))
- return PTR_ERR(c->onenand.base);
-
c->int_gpiod = devm_gpiod_get_optional(dev, "int", GPIOD_IN);
if (IS_ERR(c->int_gpiod)) {
/* Just try again if this happens */
--
2.39.0


2023-07-07 04:48:03

by 李扬韬

[permalink] [raw]
Subject: [PATCH 16/18] mtd: st_spi_fsm: Convert to devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/devices/st_spi_fsm.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
index 3dbb1aa80bfa..95530cbbb1e0 100644
--- a/drivers/mtd/devices/st_spi_fsm.c
+++ b/drivers/mtd/devices/st_spi_fsm.c
@@ -2016,7 +2016,6 @@ static int stfsm_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct flash_info *info;
- struct resource *res;
struct stfsm *fsm;
int ret;

@@ -2033,18 +2032,9 @@ static int stfsm_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, fsm);

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(&pdev->dev, "Resource not found\n");
- return -ENODEV;
- }
-
- fsm->base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(fsm->base)) {
- dev_err(&pdev->dev,
- "Failed to reserve memory region %pR\n", res);
+ fsm->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(fsm->base))
return PTR_ERR(fsm->base);
- }

fsm->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(fsm->clk)) {
--
2.39.0


2023-07-07 04:48:22

by 李扬韬

[permalink] [raw]
Subject: [PATCH 05/18] mtd: rawnand: omap2: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/nand/raw/omap2.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/omap2.c b/drivers/mtd/nand/raw/omap2.c
index db22b3af16d8..277d16f1e0bb 100644
--- a/drivers/mtd/nand/raw/omap2.c
+++ b/drivers/mtd/nand/raw/omap2.c
@@ -2219,8 +2219,7 @@ static int omap_nand_probe(struct platform_device *pdev)
}
}

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- vaddr = devm_ioremap_resource(&pdev->dev, res);
+ vaddr = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(vaddr))
return PTR_ERR(vaddr);

--
2.39.0


2023-07-07 04:48:47

by 李扬韬

[permalink] [raw]
Subject: [PATCH 13/18] mtd: plat-ram: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <[email protected]>
---
drivers/mtd/maps/plat-ram.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c
index cedd8ef9a6bf..4c921dce7396 100644
--- a/drivers/mtd/maps/plat-ram.c
+++ b/drivers/mtd/maps/plat-ram.c
@@ -123,8 +123,7 @@ static int platram_probe(struct platform_device *pdev)
info->pdata = pdata;

/* get the resource for the memory mapping */
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- info->map.virt = devm_ioremap_resource(&pdev->dev, res);
+ info->map.virt = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(info->map.virt)) {
err = PTR_ERR(info->map.virt);
goto exit_free;
--
2.39.0


2023-07-11 18:41:29

by Jernej Škrabec

[permalink] [raw]
Subject: Re: [PATCH 01/18] mtd: rawnand: sunxi: Use devm_platform_get_and_ioremap_resource()

Dne petek, 07. julij 2023 ob 06:06:05 CEST je Yangtao Li napisal(a):
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <[email protected]>

Acked-by: Jernej Skrabec <[email protected]>

Best regards,
Jernej

> ---
> drivers/mtd/nand/raw/sunxi_nand.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c
> b/drivers/mtd/nand/raw/sunxi_nand.c index 9884304634f6..db36bd755b8d 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> @@ -2087,8 +2087,7 @@ static int sunxi_nfc_probe(struct platform_device
> *pdev) nand_controller_init(&nfc->controller);
> INIT_LIST_HEAD(&nfc->chips);
>
> - r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - nfc->regs = devm_ioremap_resource(dev, r);
> + nfc->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
> if (IS_ERR(nfc->regs))
> return PTR_ERR(nfc->regs);





2023-07-12 12:22:31

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 01/18] mtd: rawnand: sunxi: Use devm_platform_get_and_ioremap_resource()


[email protected] wrote on Wed, 12 Jul 2023 13:54:55 +0200:

> Hi Yangtao,
>
> [email protected] wrote on Fri, 7 Jul 2023 12:06:05 +0800:
>
> > Convert platform_get_resource(), devm_ioremap_resource() to a single
> > call to devm_platform_get_and_ioremap_resource(), as this is exactly
> > what this function does.
> >
> > Signed-off-by: Yangtao Li <[email protected]>
> > ---
> > drivers/mtd/nand/raw/sunxi_nand.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> > index 9884304634f6..db36bd755b8d 100644
> > --- a/drivers/mtd/nand/raw/sunxi_nand.c
> > +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> > @@ -2087,8 +2087,7 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
> > nand_controller_init(&nfc->controller);
> > INIT_LIST_HEAD(&nfc->chips);
> >
> > - r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > - nfc->regs = devm_ioremap_resource(dev, r);
> > + nfc->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
>
> Why do you keep a reference over the resource? Why not just
> devm_platform_ioremap_resource(pdev, 0) ?
>
> This comment is valid for almost all the cases in this series.

Actually 'r' is used at the bottom, so the patch is good. I reviewed
all the patches, 17 look right, I have a minor comment on one of them.
In order to avoid resending all the patches, I'll first apply the 17
good ones and ask you to resend just the last one.

> When the resource is only needed in an error printk, I am also in favor
> of modifying the error message to avoid having to grab the resource.
>
> > if (IS_ERR(nfc->regs))
> > return PTR_ERR(nfc->regs);
> >
>
> These comments apply to the 18 patches.
>
> Thanks,
> Miquèl


Thanks,
Miquèl

2023-07-12 12:49:20

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 01/18] mtd: rawnand: sunxi: Use devm_platform_get_and_ioremap_resource()

Hi Yangtao,

[email protected] wrote on Fri, 7 Jul 2023 12:06:05 +0800:

> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <[email protected]>
> ---
> drivers/mtd/nand/raw/sunxi_nand.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> index 9884304634f6..db36bd755b8d 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> @@ -2087,8 +2087,7 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
> nand_controller_init(&nfc->controller);
> INIT_LIST_HEAD(&nfc->chips);
>
> - r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - nfc->regs = devm_ioremap_resource(dev, r);
> + nfc->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r);

Why do you keep a reference over the resource? Why not just
devm_platform_ioremap_resource(pdev, 0) ?

This comment is valid for almost all the cases in this series.

When the resource is only needed in an error printk, I am also in favor
of modifying the error message to avoid having to grab the resource.

> if (IS_ERR(nfc->regs))
> return PTR_ERR(nfc->regs);
>

These comments apply to the 18 patches.

Thanks,
Miquèl

2023-07-12 12:58:09

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 09/18] mtd: rawnand: davinci: Convert to devm_platform_ioremap_resource()

Hi Yangtao,

[email protected] wrote on Fri, 7 Jul 2023 12:06:13 +0800:

> Use devm_platform_ioremap_resource() to simplify code.
>
> Signed-off-by: Yangtao Li <[email protected]>
> ---
> drivers/mtd/nand/raw/davinci_nand.c | 21 +++++++++------------
> 1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/davinci_nand.c b/drivers/mtd/nand/raw/davinci_nand.c
> index 415d6aaa8255..2db1cd1d3d03 100644
> --- a/drivers/mtd/nand/raw/davinci_nand.c
> +++ b/drivers/mtd/nand/raw/davinci_nand.c
> @@ -710,8 +710,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
> {
> struct davinci_nand_pdata *pdata;
> struct davinci_nand_info *info;
> - struct resource *res1;
> - struct resource *res2;
> + struct resource *res;
> void __iomem *vaddr;
> void __iomem *base;
> int ret;
> @@ -736,26 +735,24 @@ static int nand_davinci_probe(struct platform_device *pdev)
>
> platform_set_drvdata(pdev, info);
>
> - res1 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> - if (!res1 || !res2) {
> - dev_err(&pdev->dev, "resource missing\n");
> - return -EINVAL;
> - }
> -
> - vaddr = devm_ioremap_resource(&pdev->dev, res1);
> + vaddr = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(vaddr))
> return PTR_ERR(vaddr);
>
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + if (!res) {
> + dev_err(&pdev->dev, "resource missing\n");
> + return -EINVAL;
> + }
> /*
> * This registers range is used to setup NAND settings. In case with
> * TI AEMIF driver, the same memory address range is requested already
> * by AEMIF, so we cannot request it twice, just ioremap.
> * The AEMIF and NAND drivers not use the same registers in this range.
> */
> - base = devm_ioremap(&pdev->dev, res2->start, resource_size(res2));
> + base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
> if (!base) {
> - dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res2);
> + dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res);

I believe this is the only use of the resource, I am in favor of just
using the regular devm_platform_ioremap_resource() helper here and just
drop the reference to the resource from the message.

I will apply all other patches, please send a v2 only for this one
once improved.

> return -EADDRNOTAVAIL;
> }
>


Thanks,
Miquèl

2023-07-12 14:23:42

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 16/18] mtd: st_spi_fsm: Convert to devm_platform_ioremap_resource()

On Fri, 2023-07-07 at 04:06:20 UTC, Yangtao Li wrote:
> Use devm_platform_ioremap_resource() to simplify code.
>
> Signed-off-by: Yangtao Li <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

2023-07-12 14:25:49

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 15/18] mtd: lpddr2_nvm: Convert to devm_platform_ioremap_resource()

On Fri, 2023-07-07 at 04:06:19 UTC, Yangtao Li wrote:
> Use devm_platform_ioremap_resource() to simplify code.
>
> Signed-off-by: Yangtao Li <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

2023-07-12 14:27:34

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 17/18] mtd: spear_smi: Convert to devm_platform_ioremap_resource()

On Fri, 2023-07-07 at 04:06:21 UTC, Yangtao Li wrote:
> Use devm_platform_ioremap_resource() to simplify code.
>
> Signed-off-by: Yangtao Li <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

2023-07-12 14:28:55

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 18/18] mtd: physmap-core: Use devm_platform_get_and_ioremap_resource()

On Fri, 2023-07-07 at 04:06:22 UTC, Yangtao Li wrote:
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

2023-07-12 14:28:59

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 13/18] mtd: plat-ram: Use devm_platform_get_and_ioremap_resource()

On Fri, 2023-07-07 at 04:06:17 UTC, Yangtao Li wrote:
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

2023-07-13 08:14:32

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 12/18] mtd: nand: omap: Use devm_platform_get_and_ioremap_resource()

On Fri, 2023-07-07 at 04:06:16 UTC, Yangtao Li wrote:
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

2023-07-13 08:15:54

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 02/18] mtd: rawnand: lpc32xx_slc: Use devm_platform_get_and_ioremap_resource()

On Fri, 2023-07-07 at 04:06:06 UTC, Yangtao Li wrote:
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

2023-07-13 08:16:13

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 10/18] mtd: rawnand: atmel: Use devm_platform_get_and_ioremap_resource()

On Fri, 2023-07-07 at 04:06:14 UTC, Yangtao Li wrote:
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

2023-07-13 08:28:38

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 07/18] mtd: rawnand: lpc32xx_mlc: Use devm_platform_get_and_ioremap_resource()

On Fri, 2023-07-07 at 04:06:11 UTC, Yangtao Li wrote:
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

2023-07-13 08:32:05

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 05/18] mtd: rawnand: omap2: Use devm_platform_get_and_ioremap_resource()

On Fri, 2023-07-07 at 04:06:09 UTC, Yangtao Li wrote:
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

2023-07-13 08:36:08

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 01/18] mtd: rawnand: sunxi: Use devm_platform_get_and_ioremap_resource()

On Fri, 2023-07-07 at 04:06:05 UTC, Yangtao Li wrote:
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <[email protected]>
> Acked-by: Jernej Skrabec <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

2023-07-13 08:38:15

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 08/18] mtd: rawnand: fsl_upm: Use devm_platform_get_and_ioremap_resource()

On Fri, 2023-07-07 at 04:06:12 UTC, Yangtao Li wrote:
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

2023-07-13 08:40:43

by 李扬韬

[permalink] [raw]
Subject: Re: [PATCH 09/18] mtd: rawnand: davinci: Convert to devm_platform_ioremap_resource()

Hi Mique,

On 2023/7/12 20:09, Miquel Raynal wrote:
> Hi Yangtao,
>
> [email protected] wrote on Fri, 7 Jul 2023 12:06:13 +0800:
>
>> Use devm_platform_ioremap_resource() to simplify code.
>>
>> Signed-off-by: Yangtao Li <[email protected]>
>> ---
>> drivers/mtd/nand/raw/davinci_nand.c | 21 +++++++++------------
>> 1 file changed, 9 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/raw/davinci_nand.c b/drivers/mtd/nand/raw/davinci_nand.c
>> index 415d6aaa8255..2db1cd1d3d03 100644
>> --- a/drivers/mtd/nand/raw/davinci_nand.c
>> +++ b/drivers/mtd/nand/raw/davinci_nand.c
>> @@ -710,8 +710,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
>> {
>> struct davinci_nand_pdata *pdata;
>> struct davinci_nand_info *info;
>> - struct resource *res1;
>> - struct resource *res2;
>> + struct resource *res;
>> void __iomem *vaddr;
>> void __iomem *base;
>> int ret;
>> @@ -736,26 +735,24 @@ static int nand_davinci_probe(struct platform_device *pdev)
>>
>> platform_set_drvdata(pdev, info);
>>
>> - res1 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> - res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>> - if (!res1 || !res2) {
>> - dev_err(&pdev->dev, "resource missing\n");
>> - return -EINVAL;
>> - }
>> -
>> - vaddr = devm_ioremap_resource(&pdev->dev, res1);
>> + vaddr = devm_platform_ioremap_resource(pdev, 0);
>> if (IS_ERR(vaddr))
>> return PTR_ERR(vaddr);
>>
>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>> + if (!res) {
>> + dev_err(&pdev->dev, "resource missing\n");
>> + return -EINVAL;
>> + }
>> /*
>> * This registers range is used to setup NAND settings. In case with
>> * TI AEMIF driver, the same memory address range is requested already
>> * by AEMIF, so we cannot request it twice, just ioremap.
>> * The AEMIF and NAND drivers not use the same registers in this range.
>> */
>> - base = devm_ioremap(&pdev->dev, res2->start, resource_size(res2));
>> + base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
>> if (!base) {
>> - dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res2);
>> + dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res);
> I believe this is the only use of the resource, I am in favor of just
> using the regular devm_platform_ioremap_resource() helper here and just
> drop the reference to the resource from the message.


I guess maybe you can apply this patch directly?


It should be noted that devm_ioremap_resource is not the same as
devm_ioremap,

here is devm_ioremap (devm_request_mem_region will not be called, and
there are comments explaining why this interface is needed),

which means that we cannot simply replace it with
devm_platform_ioremap_resource.


MBR,

Yangtao


>
> I will apply all other patches, please send a v2 only for this one
> once improved.
>
>> return -EADDRNOTAVAIL;
>> }
>>
>
> Thanks,
> Miquèl

2023-07-13 08:42:21

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 06/18] mtd: rawnand: stm32_fmc2: Use devm_platform_get_and_ioremap_resource()

On Fri, 2023-07-07 at 04:06:10 UTC, Yangtao Li wrote:
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

2023-07-13 08:47:18

by 李扬韬

[permalink] [raw]
Subject: Re: [PATCH 09/18] mtd: rawnand: davinci: Convert to devm_platform_ioremap_resource()

> I believe this is the only use of the resource, I am in favor of just
> using the regular devm_platform_ioremap_resource() helper here and just
> drop the reference to the resource from the message.

I guess maybe you can apply this patch directly?

It should be noted that devm_ioremap_resource is not the same as devm_ioremap,
here is devm_ioremap (devm_request_mem_region will not be called, and there are comments explaining why this interface is needed),
which means that we cannot simply replace it with devm_platform_ioremap_resource.

MBR,
Yangtao

2023-07-14 16:00:18

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH 12/18] mtd: nand: omap: Use devm_platform_get_and_ioremap_resource()

On Thu, Jul 13, 2023 at 09:57:51AM +0200, Miquel Raynal wrote:
> On Fri, 2023-07-07 at 04:06:16 UTC, Yangtao Li wrote:
> > Convert platform_get_resource(), devm_ioremap_resource() to a single
> > call to devm_platform_get_and_ioremap_resource(), as this is exactly
> > what this function does.
> >
> > Signed-off-by: Yangtao Li <[email protected]>
>
> Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Please apply the updated version at [1], the current version is
obviously not correct, as clang points out in next-20230714:

drivers/mtd/nand/onenand/onenand_omap2.c:470:2: warning: variable 'c' is uninitialized when used here [-Wuninitialized]
470 | c->onenand.base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
| ^
drivers/mtd/nand/onenand/onenand_omap2.c:465:25: note: initialize the variable 'c' to silence this warning
465 | struct omap2_onenand *c;
| ^
| = NULL
1 warning generated.

KernelCI also reported this at [2]. I apologize if this has already been
reported or fixed locally, I did not see your branch updated.

[1]: https://lore.kernel.org/[email protected]/
[2]: https://lore.kernel.org/[email protected]/

Cheers,
Nathan

2023-07-15 16:26:08

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH 12/18] mtd: nand: omap: Use devm_platform_get_and_ioremap_resource()

Hi Nathan,

[email protected] wrote on Fri, 14 Jul 2023 08:27:01 -0700:

> On Thu, Jul 13, 2023 at 09:57:51AM +0200, Miquel Raynal wrote:
> > On Fri, 2023-07-07 at 04:06:16 UTC, Yangtao Li wrote:
> > > Convert platform_get_resource(), devm_ioremap_resource() to a single
> > > call to devm_platform_get_and_ioremap_resource(), as this is exactly
> > > what this function does.
> > >
> > > Signed-off-by: Yangtao Li <[email protected]>
> >
> > Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.
>
> Please apply the updated version at [1], the current version is
> obviously not correct, as clang points out in next-20230714:

I will replace the first version by the corrected one.

>
> drivers/mtd/nand/onenand/onenand_omap2.c:470:2: warning: variable 'c' is uninitialized when used here [-Wuninitialized]
> 470 | c->onenand.base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> | ^
> drivers/mtd/nand/onenand/onenand_omap2.c:465:25: note: initialize the variable 'c' to silence this warning
> 465 | struct omap2_onenand *c;
> | ^
> | = NULL
> 1 warning generated.
>
> KernelCI also reported this at [2]. I apologize if this has already been
> reported or fixed locally, I did not see your branch updated.
>
> [1]: https://lore.kernel.org/[email protected]/
> [2]: https://lore.kernel.org/[email protected]/
>
> Cheers,
> Nathan


Thanks,
Miquèl