Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1317220
| From | "Maciej W. Rozycki" <macro@imgtec.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] mtd: bcm47xxsflash: use ioremap_cachable() instead of KSEG0ADDR() |
| Date | 2016-01-25 20:20 +0100 |
| Message-ID | <qUUQ9-cl-3@gated-at.bofh.it> (permalink) |
| References | <qRJHA-3tz-15@gated-at.bofh.it> <qUziF-1wc-7@gated-at.bofh.it> <qUGDw-6IF-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, 25 Jan 2016, Brian Norris wrote:
> > > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > + if (!res) {
> > > + dev_err(dev, "invalid resource\n");
> > > + return -EINVAL;
> > > + }
> > > + if (!devm_request_mem_region(dev, res->start, resource_size(res),
> > > + res->name)) {
> > > + dev_err(dev, "can't request region for resource %pR\n", res);
> > > + return -EBUSY;
> > > + }
> > > + b47s->window = ioremap_cachable(res->start, resource_size(res));
> > > + if (!b47s->window) {
> > > + dev_err(dev, "ioremap failed for resource %pR\n", res);
> >
> > You need to call `devm_release_mem_region' in this case.
>
> No he doesn't. devm_* functions automatically release their resources
> when either the device is removed, or the probe() fails. So the whole
> point is that we don't have to explicitly manage the error case.
Why does `devm_ioremap_resource' (in lib/devres.c) do that manually then?
dest_ptr = devm_ioremap(dev, res->start, size);
if (!dest_ptr) {
dev_err(dev, "ioremap failed for resource %pR\n", res);
devm_release_mem_region(dev, res->start, size);
dest_ptr = IOMEM_ERR_PTR(-ENOMEM);
}
Is this an oversight or was it a deliberate design decision?
> But...since he's not using a devm_* version of ioremap (there isn't one
> for ioremap_cachable()), we actually need to add an iounmap() for the
> case where mtd_device_parse_register() fails. If we fix that one, I can
> apply this.
As from 4.5-rc1 we now have `ioremap_cache' available for MIPS as well
(thanks, Ralf, for a quick action on that!), so you can use that instead
to make your code generic.
> Thanks for the review!
You're welcome! :)
Maciej
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] mtd: bcm47xxsflash: use ioremap_cachable() instead of KSEG0ADDR() Rafał Miłecki <zajec5@gmail.com> - 2016-01-17 01:50 +0100
Re: [PATCH] mtd: bcm47xxsflash: use ioremap_cachable() instead of KSEG0ADDR() "Maciej W. Rozycki" <macro@imgtec.com> - 2016-01-24 21:20 +0100
Re: [PATCH] mtd: bcm47xxsflash: use ioremap_cachable() instead of KSEG0ADDR() Brian Norris <computersforpeace@gmail.com> - 2016-01-25 05:10 +0100
Re: [PATCH] mtd: bcm47xxsflash: use ioremap_cachable() instead of KSEG0ADDR() "Maciej W. Rozycki" <macro@imgtec.com> - 2016-01-25 20:20 +0100
Re: [PATCH] mtd: bcm47xxsflash: use ioremap_cachable() instead of KSEG0ADDR() Brian Norris <computersforpeace@gmail.com> - 2016-01-25 20:40 +0100
csiph-web