Re: [PATCH] mmc: moxart: use platform helpers for resource and IRQ
Ulf Hansson <[email protected]> Mon, 27 Jul 2026 18:25:05 +0200
| Newsgroups | org.kernel.vger.linux-mmc,dev.linux.lists.llvm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAPx+jO_1g00otxNP+CfFxbr2qjbH08RB3FFOU3=WnyEQC=G4sw@mail.gmail.com> |
On Wed, Jul 22, 2026 at 10:46=E2=80=AFPM Rosen Penev <[email protected]> wro= te: > > Replace of_address_to_resource() and the following devm_ioremap_resource(= ) > with a single devm_platform_get_and_ioremap_resource() call in > moxart_probe(). This requests the register region and maps it once, which > is equivalent to the previous devm_ioremap_resource() behavior, and drops > the now-redundant separate resource lookup. > > Similarly replace irq_of_parse_and_map() with platform_get_irq(), which > returns a negative errno on failure (including -EPROBE_DEFER) instead of > 0, and tighten the error check to irq < 0. > > Both substitutions are equivalent for a DT-backed platform device. The > remaining OF usage (mmc_of_parse() and the of_device_id table) is covered > by already-included headers, so linux/of_address.h and linux/of_irq.h > are dropped. > > No functional change; the MMC register window is requested and mapped > exactly once, so there is no overlapping region claim. > > Built for ARM (allmodconfig + CONFIG_MMC_MOXART) with LLVM=3D1; > drivers/mmc/host/moxart-mmc.o compiles cleanly. > > Assisted-by: opencode:hy3-free > Signed-off-by: Rosen Penev <[email protected]> Applied for next, thanks! Kind regards Uffe > --- > drivers/mmc/host/moxart-mmc.c | 29 ++++++++++------------------- > 1 file changed, 10 insertions(+), 19 deletions(-) > > diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.= c > index 4a4d8b19b18c..28aed13549a6 100644 > --- a/drivers/mmc/host/moxart-mmc.c > +++ b/drivers/mmc/host/moxart-mmc.c > @@ -26,8 +26,6 @@ > #include <linux/mmc/sd.h> > #include <linux/sched.h> > #include <linux/io.h> > -#include <linux/of_address.h> > -#include <linux/of_irq.h> > #include <linux/clk.h> > #include <linux/bitops.h> > #include <linux/of_dma.h> > @@ -555,8 +553,7 @@ static const struct mmc_host_ops moxart_ops =3D { > static int moxart_probe(struct platform_device *pdev) > { > struct device *dev =3D &pdev->dev; > - struct device_node *node =3D dev->of_node; > - struct resource res_mmc; > + struct resource *res_mmc; > struct mmc_host *mmc; > struct moxart_host *host =3D NULL; > struct dma_slave_config cfg; > @@ -565,30 +562,24 @@ static int moxart_probe(struct platform_device *pde= v) > int irq, ret; > u32 i; > > + reg_mmc =3D devm_platform_get_and_ioremap_resource(pdev, 0, &res_= mmc); > + if (IS_ERR(reg_mmc)) > + return PTR_ERR(reg_mmc); > + > + irq =3D platform_get_irq(pdev, 0); > + if (irq < 0) > + return irq; > + > mmc =3D devm_mmc_alloc_host(dev, sizeof(*host)); > if (!mmc) { > dev_err(dev, "devm_mmc_alloc_host failed\n"); > return -ENOMEM; > } > > - ret =3D of_address_to_resource(node, 0, &res_mmc); > - if (ret) > - return dev_err_probe(dev, ret, > - "of_address_to_resource failed\n"); > - > - irq =3D irq_of_parse_and_map(node, 0); > - if (irq <=3D 0) > - return dev_err_probe(dev, -EINVAL, > - "irq_of_parse_and_map failed\n"); > - > clk =3D devm_clk_get(dev, NULL); > if (IS_ERR(clk)) > return PTR_ERR(clk); > > - reg_mmc =3D devm_ioremap_resource(dev, &res_mmc); > - if (IS_ERR(reg_mmc)) > - return PTR_ERR(reg_mmc); > - > ret =3D mmc_of_parse(mmc); > if (ret) > return ret; > @@ -596,7 +587,7 @@ static int moxart_probe(struct platform_device *pdev) > host =3D mmc_priv(mmc); > host->mmc =3D mmc; > host->base =3D reg_mmc; > - host->reg_phys =3D res_mmc.start; > + host->reg_phys =3D res_mmc->start; > host->timeout =3D msecs_to_jiffies(1000); > host->sysclk =3D clk_get_rate(clk); > host->fifo_width =3D readl(host->base + REG_FEATURE) << 2; > -- > 2.55.0 >