All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@imgtec.com>
To: Brian Norris <computersforpeace@gmail.com>
Cc: "Rafał Miłecki" <zajec5@gmail.com>,
	linux-mtd@lists.infradead.org,
	"Javier Martinez Canillas" <javier@osg.samsung.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Fengguang Wu" <fengguang.wu@intel.com>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Luis de Bethencourt" <luisbg@osg.samsung.com>,
	"Jeremy Kerr" <jk@ozlabs.org>,
	"Neelesh Gupta" <neelegup@linux.vnet.ibm.com>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"Cyril Bur" <cyrilbur@gmail.com>,
	"Ralf Baechle" <ralf@linux-mips.org>
Subject: Re: [PATCH] mtd: bcm47xxsflash: use ioremap_cachable() instead of KSEG0ADDR()
Date: Mon, 25 Jan 2016 19:15:49 +0000	[thread overview]
Message-ID: <alpine.DEB.2.00.1601250414200.5958@tp.orcam.me.uk> (raw)
In-Reply-To: <20160125040459.GA4386@localhost>

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

  reply	other threads:[~2016-01-25 19:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-17  0:42 [PATCH] mtd: bcm47xxsflash: use ioremap_cachable() instead of KSEG0ADDR() Rafał Miłecki
2016-01-24 20:17 ` Maciej W. Rozycki
2016-01-25  4:04   ` Brian Norris
2016-01-25 19:15     ` Maciej W. Rozycki [this message]
2016-01-25 19:30       ` Brian Norris
2016-02-26 10:41   ` Rafał Miłecki
2016-02-26 14:18     ` Maciej W. Rozycki
2016-02-26 16:31       ` Rafał Miłecki
2016-02-26 10:50 ` [PATCH V2] mtd: bcm47xxsflash: use ioremap_cache() " Rafał Miłecki
2016-03-05  0:54   ` Brian Norris
2016-03-18 11:22     ` Ard Biesheuvel
2016-04-04  7:09       ` Brian Norris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.00.1601250414200.5958@tp.orcam.me.uk \
    --to=macro@imgtec.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrilbur@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=fengguang.wu@intel.com \
    --cc=javier@osg.samsung.com \
    --cc=jk@ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=luisbg@osg.samsung.com \
    --cc=mpe@ellerman.id.au \
    --cc=neelegup@linux.vnet.ibm.com \
    --cc=ralf@linux-mips.org \
    --cc=zajec5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.