diff mbox series

[7/7] usb: musb: convert to devm_platform_ioremap_resource_byname

Message ID 1595404275-8449-7-git-send-email-chunfeng.yun@mediatek.com (mailing list archive)
State Mainlined
Commit 2d30e408a2a6b3443d3232593e3d472584a3e9f8
Headers show
Series [1/7] usb: mtu3: convert to devm_platform_ioremap_resource_byname | expand

Commit Message

Chunfeng Yun (云春峰) July 22, 2020, 7:51 a.m. UTC
Use devm_platform_ioremap_resource_byname() to simplify code

Cc: Bin Liu <b-liu@ti.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/usb/musb/musb_dsps.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Geert Uytterhoeven Nov. 12, 2020, 2:08 p.m. UTC | #1
Hi Chunfeng,

On Wed, Jul 22, 2020 at 9:54 AM Chunfeng Yun <chunfeng.yun@mediatek.com> wrote:
> Use devm_platform_ioremap_resource_byname() to simplify code
>
> Cc: Bin Liu <b-liu@ti.com>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>

Thanks for your patch, which is now commit 2d30e408a2a6b344 ("usb: musb:
convert to devm_platform_ioremap_resource_byname") in v5.9.

> --- a/drivers/usb/musb/musb_dsps.c
> +++ b/drivers/usb/musb/musb_dsps.c
> @@ -429,12 +429,10 @@ static int dsps_musb_init(struct musb *musb)
>         struct platform_device *parent = to_platform_device(dev->parent);
>         const struct dsps_musb_wrapper *wrp = glue->wrp;
>         void __iomem *reg_base;
> -       struct resource *r;
>         u32 rev, val;
>         int ret;
>
> -       r = platform_get_resource_byname(parent, IORESOURCE_MEM, "control");
> -       reg_base = devm_ioremap_resource(dev, r);
> +       reg_base = devm_platform_ioremap_resource_byname(parent, "control");
>         if (IS_ERR(reg_base))
>                 return PTR_ERR(reg_base);
>         musb->ctrl_base = reg_base;

On Beaglebone Black, where each interface has 2 children:

    musb-dsps 47401c00.usb: can't request region for resource [mem
0x47401800-0x474019ff]
    musb-hdrc musb-hdrc.1: musb_init_controller failed with status -16
    musb-hdrc: probe of musb-hdrc.1 failed with error -16
    musb-dsps 47401400.usb: can't request region for resource [mem
0x47401000-0x474011ff]
    musb-hdrc musb-hdrc.0: musb_init_controller failed with status -16
    musb-hdrc: probe of musb-hdrc.0 failed with error -16

Before, devm_ioremap_resource() was called on "dev" ("musb-hdrc.0" or
"musb-hdrc.1"), after it is called on "&pdev->dev" ("47401400.usb" or
"47401c00.usb"), leading to a duplicate region request, which fails.

I have sent a revert:
https://lore.kernel.org/linux-usb/20201112135900.3822599-1-geert+renesas@glider.be/

Gr{oetje,eeting}s,

                        Geert
Chunfeng Yun (云春峰) Nov. 13, 2020, 8:26 a.m. UTC | #2
On Thu, 2020-11-12 at 15:08 +0100, Geert Uytterhoeven wrote:
> Hi Chunfeng,
> 
> On Wed, Jul 22, 2020 at 9:54 AM Chunfeng Yun <chunfeng.yun@mediatek.com> wrote:
> > Use devm_platform_ioremap_resource_byname() to simplify code
> >
> > Cc: Bin Liu <b-liu@ti.com>
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> 
> Thanks for your patch, which is now commit 2d30e408a2a6b344 ("usb: musb:
> convert to devm_platform_ioremap_resource_byname") in v5.9.
> 
> > --- a/drivers/usb/musb/musb_dsps.c
> > +++ b/drivers/usb/musb/musb_dsps.c
> > @@ -429,12 +429,10 @@ static int dsps_musb_init(struct musb *musb)
> >         struct platform_device *parent = to_platform_device(dev->parent);
> >         const struct dsps_musb_wrapper *wrp = glue->wrp;
> >         void __iomem *reg_base;
> > -       struct resource *r;
> >         u32 rev, val;
> >         int ret;
> >
> > -       r = platform_get_resource_byname(parent, IORESOURCE_MEM, "control");
> > -       reg_base = devm_ioremap_resource(dev, r);
> > +       reg_base = devm_platform_ioremap_resource_byname(parent, "control");
> >         if (IS_ERR(reg_base))
> >                 return PTR_ERR(reg_base);
> >         musb->ctrl_base = reg_base;
> 
> On Beaglebone Black, where each interface has 2 children:
> 
>     musb-dsps 47401c00.usb: can't request region for resource [mem
> 0x47401800-0x474019ff]
>     musb-hdrc musb-hdrc.1: musb_init_controller failed with status -16
>     musb-hdrc: probe of musb-hdrc.1 failed with error -16
>     musb-dsps 47401400.usb: can't request region for resource [mem
> 0x47401000-0x474011ff]
>     musb-hdrc musb-hdrc.0: musb_init_controller failed with status -16
>     musb-hdrc: probe of musb-hdrc.0 failed with error -16
> 
> Before, devm_ioremap_resource() was called on "dev" ("musb-hdrc.0" or
> "musb-hdrc.1"), after it is called on "&pdev->dev" ("47401400.usb" or
> "47401c00.usb"), leading to a duplicate region request, which fails.
> 
My bad, I didn't notice that, thanks a lot.

And sorry, I missed your message

> I have sent a revert:
> https://lore.kernel.org/linux-usb/20201112135900.3822599-1-geert+renesas@glider.be/
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
>
diff mbox series

Patch

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 8892317..9dbf977 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -429,12 +429,10 @@  static int dsps_musb_init(struct musb *musb)
 	struct platform_device *parent = to_platform_device(dev->parent);
 	const struct dsps_musb_wrapper *wrp = glue->wrp;
 	void __iomem *reg_base;
-	struct resource *r;
 	u32 rev, val;
 	int ret;
 
-	r = platform_get_resource_byname(parent, IORESOURCE_MEM, "control");
-	reg_base = devm_ioremap_resource(dev, r);
+	reg_base = devm_platform_ioremap_resource_byname(parent, "control");
 	if (IS_ERR(reg_base))
 		return PTR_ERR(reg_base);
 	musb->ctrl_base = reg_base;