diff mbox series

[09/24] mmc: mtk-sd: check for valid optional memory resource

Message ID 20190323211612.860-10-fparent@baylibre.com (mailing list archive)
State Not Applicable
Headers show
Series arm64: mediatek: add support for Pumpkin MT8516 board | expand

Commit Message

Fabien Parent March 23, 2019, 9:15 p.m. UTC
'top_base' memory region is optional. Check that the resource is valid
before using it. This avoid getting a "invalid resource" error message
printed by the kernel.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
---
 drivers/mmc/host/mtk-sd.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Yingjoe Chen March 24, 2019, 3:34 a.m. UTC | #1
On Sat, 2019-03-23 at 22:15 +0100, Fabien Parent wrote:
> 'top_base' memory region is optional. Check that the resource is valid
> before using it. This avoid getting a "invalid resource" error message
> printed by the kernel.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> ---
>  drivers/mmc/host/mtk-sd.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> index 833ef0590af8..573aa127d00b 100644
> --- a/drivers/mmc/host/mtk-sd.c
> +++ b/drivers/mmc/host/mtk-sd.c
> @@ -2123,9 +2123,11 @@ static int msdc_drv_probe(struct platform_device *pdev)
>  	}
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> -	host->top_base = devm_ioremap_resource(&pdev->dev, res);
> -	if (IS_ERR(host->top_base))
> -		host->top_base = NULL;
> +	if (ret) {

This should be res?

> +		host->top_base = devm_ioremap_resource(&pdev->dev, res);
> +		if (IS_ERR(host->top_base))
> +			host->top_base = NULL;
> +	}
>  
>  	ret = mmc_regulator_get_supply(mmc);
>  	if (ret)
Fabien Parent March 24, 2019, 3:18 p.m. UTC | #2
On Sun, Mar 24, 2019 at 4:34 AM Yingjoe Chen <yingjoe.chen@mediatek.com> wrote:
>
> On Sat, 2019-03-23 at 22:15 +0100, Fabien Parent wrote:
> > 'top_base' memory region is optional. Check that the resource is valid
> > before using it. This avoid getting a "invalid resource" error message
> > printed by the kernel.
> >
> > Signed-off-by: Fabien Parent <fparent@baylibre.com>
> > ---
> >  drivers/mmc/host/mtk-sd.c | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> > index 833ef0590af8..573aa127d00b 100644
> > --- a/drivers/mmc/host/mtk-sd.c
> > +++ b/drivers/mmc/host/mtk-sd.c
> > @@ -2123,9 +2123,11 @@ static int msdc_drv_probe(struct platform_device *pdev)
> >       }
> >
> >       res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> > -     host->top_base = devm_ioremap_resource(&pdev->dev, res);
> > -     if (IS_ERR(host->top_base))
> > -             host->top_base = NULL;
> > +     if (ret) {
>
> This should be res?

Indeed. Thanks, I will fix it in v2.

> > +             host->top_base = devm_ioremap_resource(&pdev->dev, res);
> > +             if (IS_ERR(host->top_base))
> > +                     host->top_base = NULL;
> > +     }
> >
> >       ret = mmc_regulator_get_supply(mmc);
> >       if (ret)
>
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 833ef0590af8..573aa127d00b 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -2123,9 +2123,11 @@  static int msdc_drv_probe(struct platform_device *pdev)
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	host->top_base = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(host->top_base))
-		host->top_base = NULL;
+	if (ret) {
+		host->top_base = devm_ioremap_resource(&pdev->dev, res);
+		if (IS_ERR(host->top_base))
+			host->top_base = NULL;
+	}
 
 	ret = mmc_regulator_get_supply(mmc);
 	if (ret)