[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54ABC8A2.7090905@free-electrons.com>
Date: Tue, 06 Jan 2015 12:36:02 +0100
From: Gregory CLEMENT <gregory.clement@...e-electrons.com>
To: Mark Brown <broonie@...nel.org>
CC: Liam Girdwood <lgirdwood@...il.com>, linux-kernel@...r.kernel.org,
Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>,
Ezequiel Garcia <ezequiel.garcia@...e-electrons.com>,
Maxime Ripard <maxime.ripard@...e-electrons.com>,
Boris BREZILLON <boris.brezillon@...e-electrons.com>,
Lior Amsalem <alior@...vell.com>,
Tawfik Bayouk <tawfik@...vell.com>,
Nadav Haklai <nadavh@...vell.com>, linux-ide@...r.kernel.org
Subject: Re: [PATCH 1/2] regulator: core: Add a sanity check on the regulator_
enable/disable functions
Hi Mark,
On 29/12/2014 16:40, Mark Brown wrote:
> On Fri, Dec 26, 2014 at 06:26:38PM +0100, Gregory CLEMENT wrote:
>> These two functions use the pointer passed in parameter without any
>> check. By adding a NULL pointer check, it allows using those functions
>> from a driver in a more generic way. It is useful especially for the
>> disable case if the regulator is optional.
>
> No, especially in the case of regulator_enable() this is deliberate -
> we're trying to ensure that if people are using regulators they're being
> careful about it, checking error codes and so on. I'd really want to
OK so at least we should check that the pointer is not NULL before using it
and inform the user of it by using a WARNING() or even a BUG() instead of
just let the kernel crash latter.
> see some persuasive use case for this. What you're saying here sounds
> like the consumer shouldn't be treating the regulator as optional at
> all but should instead be using a normal regulator.
>
Being able to deal with NULL pointer in the disable function is convenient
and is done in other similar subsystems such as phy or clk for example. Instead
of having a check on the NULL pointer in each driver, it seems more logical to
do it directly in the disable function.
Thanks for you review,
Gregory
--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists