devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang@pengutronix.de>
To: Thierry Reding <thierry.reding@avionic-design.de>
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,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v2 2/4] input: keyboard: tegra: use devm_* for resource allocation
Date: Wed, 16 Jan 2013 07:35:33 +0100	[thread overview]
Message-ID: <20130116063533.GA22345@pengutronix.de> (raw)
In-Reply-To: <20130115154423.GA13871@avionic-0098.adnet.avionic-design.de>

[-- Attachment #1: Type: text/plain, Size: 3966 bytes --]

Hi,

> > Then, I added the example code in the documentation using EADDRNOTAVAIL.
> > Yes, I was brave with this one. Yet, EINVAL, EBUSY, ENOENT, did not
> > really cut it and are so heavily used in drivers that they turned into a
> > generic "something is wrong" error. I tried here to use a not overloaded
> > error code in order to be specific again. Since the patches were
> > accepted, I assumed it wasn't seen as a namespace violation. (Then
> > again, it probably would have been if that error code would go out to
> > userspace) Naturally, I didn't have the resources to check all patches
> > for a consistent error code.
> 
> The problem with the current approach is that people (me included) keep
> telling people to use this or that error code in an attempt to achieve
> some kind of consistency. Also using an error message to distinguish
> between reasons for failure makes it impossible to handle the error
> other than by visual inspection. Granted, there are currently no code
> paths that require this.

Yes, so currently, this is rather a cosmetic change. And for that, it is
quite intrusive. I think something like this is needed somewhen as part
of a bigger overhaul. That's what I called "master plan" last time. That
could be that resource handling gets aligned in general, also taking
e.g. interrupt resources into account. But only changing error code
handling for this function, doesn't seem too useful to me and might even
need another change later, then.

> One problem with the original patch was also that it didn't actually
> convert any existing uses, so there was little chance of anyone noticing

Like with the error codes now, there are so many different ways of
handling resources that I did not want to mass convert all the drivers
without being able to test them. I was hoping for a migration over time
with patches from people who really tested what they did.

> potential problems. More than a year later this function is used by many
> subsystems and a lot of drivers. It just so happened that I observed how
> many people just didn't know what error codes to choose and often just
> grabbing one randomly.

Yes, and concerning resources this needs cleaning on a bigger scale IMO.

> By adding devm_ioremap_resource() and having it return ERR_PTR()-encoded
> error codes we get rid of all these problems and put the responsibility
> for choosing the error code where, in my opinion, it belongs: the
> failing function.

For completeness, it leaves the problem that people might forget to use
ERR_PTR (seen that often in the clk framework). And the change is huge
while I can't see any real benefit right now.

> > When working with this function, there was also the idea to abstract
> > getting the resource away. Which then gave Sascha Hauer and me the
> > question, if drivers really have to do this or if this couldn't be done
> > by the kernel somehow, i.e. giving the drivers already the resources
> > they need, completely prepared.
> 
> I'm not sure I like that very much. That could possibly lead to a new
> problem where drivers that need to do something special have to jump
> through hoops to achieve something that may otherwise be simple.

I assume that drivers are already doing something special :) So, that
would turn up in the conversion process. I can't promise that it would
really work, it would need some playing around.

> Anyway, if people don't think this is a sensible conversion I should
> waste no more time on it. On the other hand I have the patch series
> ready so I might as well post it for broader review.

Working on patches is hardly a waste. Even if not accepted, you gain
understanding. Please put me on CC, if you post the patches.

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2013-01-16  6:35 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
     [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 [this message]
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=20130116063533.GA22345@pengutronix.de \
    --to=w.sang@pengutronix.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=thierry.reding@avionic-design.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).