On Tue, Nov 26, 2013 at 08:10:46AM +0100, Michal Simek wrote:
> On 11/22/2013 05:34 AM, Stefan Kristiansson wrote:
> > +
> > +   /* Request I/O resource */
> > +   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +   if (!res) {
> > +           dev_err(&pdev->dev, "I/O resource request failed\n");
> > +           return -ENXIO;
> > +   }
> > +   fbdev->regs_phys = res->start;
> > +   fbdev->regs_phys_size = resource_size(res);
> > +   mmio = devm_request_mem_region(&pdev->dev, res->start,
> > +                                  resource_size(res), res->name);
> > +   if (!mmio) {
> > +           dev_err(&pdev->dev, "I/O memory space request failed\n");
> > +           return -ENXIO;
> > +   }
> > +   fbdev->regs = devm_ioremap_nocache(&pdev->dev, mmio->start,
> > +                                      resource_size(mmio));
> > +   if (!fbdev->regs) {
> > +           dev_err(&pdev->dev, "I/O memory remap request failed\n");
> > +           return -ENXIO;
> > +   }
> 
> 
> This construction seems to me too complicated and can be simpler.
> 
> What about this?
>       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>       res->flags &= ~IORESOURCE_CACHEABLE;
>       fbdev->regs = devm_ioremap_resource(&pdev->dev, res);
>       if (IS_ERR(fbdev->regs))
>               return PTR_ERR(fbdev->regs);
> 

Yes, that looks better.

Slightly related, I also noticed that I have a release_mem_region even though I
used devm_request_mem_region to request it.
I will fix that as well.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to