From: Thierry Reding <thierry.reding@avionic-design.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Laxman Dewangan <ldewangan@nvidia.com>,
grant.likely@secretlab.ca, rob.herring@calxeda.com,
swarren@nvidia.com, devicetree-discuss@lists.ozlabs.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-input@vger.kernel.org, linux-tegra@vger.kernel.org,
Wolfram Sang <w.sang@pengutronix.de>,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v2 2/4] input: keyboard: tegra: use devm_* for resource allocation
Date: Mon, 14 Jan 2013 23:15:51 +0100 [thread overview]
Message-ID: <20130114221551.GA30020@avionic-0098.adnet.avionic-design.de> (raw)
In-Reply-To: <20130114161644.GC14721@kroah.com>
[-- Attachment #1: Type: text/plain, Size: 5465 bytes --]
On Mon, Jan 14, 2013 at 08:16:44AM -0800, Greg Kroah-Hartman wrote:
> On Mon, Jan 14, 2013 at 04:49:59PM +0100, Thierry Reding wrote:
> > On Wed, Jan 09, 2013 at 10:23:52AM +0100, Thierry Reding wrote:
> > > On Wed, Jan 09, 2013 at 01:19:39AM -0800, Dmitry Torokhov wrote:
> > > > On Wed, Jan 09, 2013 at 08:07:45AM +0100, Thierry Reding wrote:
> > > > > On Sun, Jan 06, 2013 at 11:57:48AM -0800, Dmitry Torokhov wrote:
> > > > > > On Sun, Jan 06, 2013 at 08:27:39PM +0100, Thierry Reding wrote:
> > > > > > > On Sat, Jan 05, 2013 at 12:06:58AM -0800, Dmitry Torokhov wrote:
> > > > > > > > On Sat, Jan 05, 2013 at 01:15:08PM +0530, Laxman Dewangan wrote:
> > > > > > > [...]
> > > > > > > > > @@ -735,25 +738,16 @@ static int tegra_kbc_probe(struct platform_device *pdev)
> > > > > > > > > spin_lock_init(&kbc->lock);
> > > > > > > > > setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc);
> > > > > > > > >
> > > > > > > > > - res = request_mem_region(res->start, resource_size(res), pdev->name);
> > > > > > > > > - if (!res) {
> > > > > > > > > - dev_err(&pdev->dev, "failed to request I/O memory\n");
> > > > > > > > > - err = -EBUSY;
> > > > > > > > > - goto err_free_mem;
> > > > > > > > > - }
> > > > > > > > > -
> > > > > > > > > - kbc->mmio = ioremap(res->start, resource_size(res));
> > > > > > > > > + kbc->mmio = devm_request_and_ioremap(&pdev->dev, res);
> > > > > > > > > if (!kbc->mmio) {
> > > > > > > > > - dev_err(&pdev->dev, "failed to remap I/O memory\n");
> > > > > > > > > - err = -ENXIO;
> > > > > > > > > - goto err_free_mem_region;
> > > > > > > > > + dev_err(&pdev->dev, "Cannot request memregion/iomap address\n");
> > > > > > > > > + return -EADDRNOTAVAIL;
> > > > > > > >
> > > > > > > > Erm, no, -EBUSY please.
> > > > > > >
> > > > > > > EADDRNOTAVAIL is the canonical error for devm_request_and_ioremap()
> > > > > > > failure. The kerneldoc comment in lib/devres.c even gives a short
> > > > > > > example that uses this error code.
> > > > > >
> > > > > > I am sorry, but I do not consider a function that was added a little
> > > > > > over a year ago as a canon. If you look at the uses of EADDRNOTAVAIL it
> > > > > > is used predominantly in networking code to indicate that attempted
> > > > > > _network_ address is not available.
> > > > >
> > > > > EBUSY might be misleading, though. devm_request_and_ioremap() can fail
> > > > > in both the request_mem_region() and ioremap() calls. Furthermore it'd
> > > > > be good to settle on a consistent error-code instead of doing it
> > > > > differently depending on subsystem and/or driver. Currently the various
> > > > > error codes used are:
> > > > >
> > > > > EBUSY, EADDRNOTAVAIL, ENXIO, ENOMEM, ENODEV, ENOENT, EINVAL,
> > > > > EIO, EFAULT, EADDRINUSE
> > > > >
> > > > > Also if we can settle on one error code we should follow up with a patch
> > > > > to make it consistent across the tree and also update that kerneldoc
> > > > > comment. I volunteer to do that if nobody else steps up. I'm also Cc'ing
> > > > > Wolfram (the original author), maybe he has some thoughts on this.
> > > > >
> > > >
> > > > If you going to change all drivers make devm_request_and_ioremap()
> > > > return ERR_PTR()-encoded errors and then we can differentiate what
> > > > part of it failed.
> > >
> > > Yeah, that thought also crossed my mind. I'll give other people some
> > > time to comment before hurling myself into preparing patches.
> >
> > I've prepared a patch that changes devm_request_and_ioremap() to return
> > ERR_PTR()-encoded errors and adjusts all callers. As you can imagine it
> > is a bit on the huge side. scripts/get_maintainer.pl lists 156 people
> > and mailing lists. I've gone through the list, and as far as I can tell
> > everyone on that list is actually affected by the patch, so there's not
> > much potential for tuning it down.
> >
> > There is also the issue of whose tree this should go into. Unfortunately
> > the patch can't be broken down into smaller chunks because it changes
> > how the devm_request_and_ioremap() function's return value is handled in
> > an incompatible way, so it won't be possible to gradually phase this in.
> > Furthermore I can imagine that until the end of the release cycle new
> > code may be added on which the same transformations need to be done. I
> > have a semantic patch to do the bulk of the work, but quite a bit of
> > coordination will be required.
> >
> > I'm adding Arnd and Greg on Cc, maybe they can advise on how best to
> > handle this kind of patch.
>
> You should provide a "wrapper" function that does the correct return
> value, convert drivers over to it, and then, when everyone is changed,
> drop the old call. To change 156 different drivers all at once, in a
> way that is not detectable by the compiler breaking the build, is not a
> good thing to do at all.
>
> By doing it in this manner, it will take longer, but you can push the
> patches through the different maintainer's trees. If they are slow,
> I'll be glad to take the remaining patches in my driver-core tree to do
> the final bits.
It certainly sounds like a less complicated way to do it. But it also
involves adding a function with a made up name and drop a function with
a perfectly good name instead. I wouldn't even know what name to choose
for the new API.
Thierry
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2013-01-14 22:15 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-05 7:45 [PATCH V2 0/4] input: keyboard: tegra: cleanups and DT supports Laxman Dewangan
[not found] ` <1357371910-3164-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-05 7:45 ` [PATCH v2 1/4] input: keyboard: tegra: fix build warning Laxman Dewangan
2013-01-05 7:45 ` [PATCH v2 2/4] input: keyboard: tegra: use devm_* for resource allocation Laxman Dewangan
2013-01-05 8:06 ` Dmitry Torokhov
2013-01-05 11:20 ` Laxman Dewangan
2013-01-05 23:18 ` Dmitry Torokhov
[not found] ` <20130105231858.GD6475-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2013-01-06 11:00 ` Laxman Dewangan
[not found] ` <20130105080658.GA1315-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2013-01-06 19:27 ` Thierry Reding
2013-01-06 19:57 ` Dmitry Torokhov
2013-01-09 7:07 ` Thierry Reding
2013-01-09 9:19 ` Dmitry Torokhov
[not found] ` <20130109091939.GA4369-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2013-01-09 9:23 ` Thierry Reding
2013-01-14 15:49 ` Thierry Reding
2013-01-14 16:16 ` Greg Kroah-Hartman
2013-01-14 22:15 ` Thierry Reding [this message]
[not found] ` <20130114221551.GA30020-RM9K5IK7kjIyiCvfTdI0JKcOhU4Rzj621B7CTYaBSLdn68oJJulU0Q@public.gmane.org>
2013-01-14 22:24 ` Arnd Bergmann
[not found] ` <201301142224.11243.arnd-r2nGTMty4D4@public.gmane.org>
2013-01-15 6:44 ` Thierry Reding
2013-01-15 12:32 ` Wolfram Sang
2013-01-15 13:06 ` Wolfram Sang
[not found] ` <20130115130623.GC2625-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-01-15 15:44 ` Thierry Reding
2013-01-16 6:35 ` Wolfram Sang
2013-02-09 9:04 ` Grant Likely
2013-01-05 7:45 ` [PATCH v2] input: keyboard: tegra: add support for rows/cols configuration from dt Laxman Dewangan
2013-01-05 7:45 ` [PATCH v2 4/4] input: keyboard: tegra: remove default key mapping Laxman Dewangan
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=20130114221551.GA30020@avionic-0098.adnet.avionic-design.de \
--to=thierry.reding@avionic-design.de \
--cc=arnd@arndb.de \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=dmitry.torokhov@gmail.com \
--cc=grant.likely@secretlab.ca \
--cc=gregkh@linuxfoundation.org \
--cc=ldewangan@nvidia.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=rob.herring@calxeda.com \
--cc=swarren@nvidia.com \
--cc=w.sang@pengutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).