linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: core: Return error in get optional stub
@ 2014-04-17 18:55 Tim Kryger
  2014-04-18 14:12 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Tim Kryger @ 2014-04-17 18:55 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: Tim Kryger, Linux Kernel Mailing List

Drivers that call regulator_get_optional are tolerant to the absence of
that regulator.  By modifying the value returned from the stub function
to match that seen when a regulator isn't present, callers can wrap the
regulator logic with an IS_ERR based conditional even if they happen to
call regulator_is_supported_voltage.  This improves efficiency as well
as eliminates the possibility for a very subtle bug.

Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
---

This change was proposed here: https://lkml.org/lkml/2014/4/16/627

 include/linux/regulator/consumer.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index e530681..1a4a8c1 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -258,14 +258,14 @@ regulator_get_exclusive(struct device *dev, const char *id)
 static inline struct regulator *__must_check
 regulator_get_optional(struct device *dev, const char *id)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 
 static inline struct regulator *__must_check
 devm_regulator_get_optional(struct device *dev, const char *id)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 static inline void regulator_put(struct regulator *regulator)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regulator: core: Return error in get optional stub
  2014-04-17 18:55 [PATCH] regulator: core: Return error in get optional stub Tim Kryger
@ 2014-04-18 14:12 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2014-04-18 14:12 UTC (permalink / raw)
  To: Tim Kryger; +Cc: Liam Girdwood, Linux Kernel Mailing List

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

On Thu, Apr 17, 2014 at 11:55:24AM -0700, Tim Kryger wrote:
> Drivers that call regulator_get_optional are tolerant to the absence of
> that regulator.  By modifying the value returned from the stub function
> to match that seen when a regulator isn't present, callers can wrap the
> regulator logic with an IS_ERR based conditional even if they happen to
> call regulator_is_supported_voltage.  This improves efficiency as well
> as eliminates the possibility for a very subtle bug.

Applied, thanks.

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-18 14:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-17 18:55 [PATCH] regulator: core: Return error in get optional stub Tim Kryger
2014-04-18 14:12 ` Mark Brown

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).