On Tue, Apr 28, 2020 at 10:42:56AM +0200, Nicolas Ferre wrote:
> On 28/04/2020 at 05:24, Dejin Zheng wrote:
> > On Mon, Apr 27, 2020 at 01:33:41PM +0300, Andy Shevchenko wrote:
> > > On Sat, Apr 25, 2020 at 3:57 PM Dejin Zheng <zhengdej...@gmail.com> wrote:
> > > > 
> > > > A call of the function macb_init() can fail in the function
> > > > fu540_c000_init. The related system resources were not released
> > > > then. use devm_ioremap() to replace ioremap() for fix it.
> > > > 
> > > 
> > > Why not to go further and convert to use devm_platform_ioremap_resource()?
> > > 
> > devm_platform_ioremap_resource() will call devm_request_mem_region(),
> > and here did not do it.
> 
> And what about devm_platform_get_and_ioremap_resource()? This would
> streamline this whole fu540_c000_init() function.
>
Nicolas, the function devm_platform_get_and_ioremap_resource() will also
call devm_request_mem_region(), after call it, These IO addresses will
be monopolized by this driver. the devm_ioremap() and ioremap() are not
do this. if this IO addresses will be shared with the other driver, call
devm_platform_get_and_ioremap_resource() may be fail.

BR,
Dejin

> Regards,
>   Nicolas
> 
> > > > Fixes: c218ad559020ff9 ("macb: Add support for SiFive FU540-C000")
> > > > Cc: Andy Shevchenko <andy.shevche...@gmail.com>
> > > > Signed-off-by: Dejin Zheng <zhengdej...@gmail.com>
> > > > ---
> > > >   drivers/net/ethernet/cadence/macb_main.c | 2 +-
> > > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/net/ethernet/cadence/macb_main.c 
> > > > b/drivers/net/ethernet/cadence/macb_main.c
> > > > index a0e8c5bbabc0..edba2eb56231 100644
> > > > --- a/drivers/net/ethernet/cadence/macb_main.c
> > > > +++ b/drivers/net/ethernet/cadence/macb_main.c
> > > > @@ -4178,7 +4178,7 @@ static int fu540_c000_init(struct platform_device 
> > > > *pdev)
> > > >          if (!res)
> > > >                  return -ENODEV;
> > > > 
> > > > -       mgmt->reg = ioremap(res->start, resource_size(res));
> > > > +       mgmt->reg = devm_ioremap(&pdev->dev, res->start, 
> > > > resource_size(res));
> > > >          if (!mgmt->reg)
> > > >                  return -ENOMEM;
> > > > 
> 
> 
> -- 
> Nicolas Ferre

Reply via email to