linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] leds: leds-regulator.c, fix handling already enabled regulators
@ 2011-03-23 21:00 Antonio Ospite
  2011-03-23 21:21 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Antonio Ospite @ 2011-03-23 21:00 UTC (permalink / raw)
  To: Richard Purdie
  Cc: Antonio Ospite, Mark Brown, Liam Girdwood, Daniel Ribeiro,
	linux-kernel, linux-arm-kernel, openezx-devel

Make the driver aware of the initial status of the regulator.

The leds-regulator driver was ignoring the initial status of the
regulator; this resulted in rdev->use_count incremented up to 2 after
calling regulator_led_set_value() in the .probe method when a regulator
was already enabled at insmod time, and this made impossible to ever
disable the regulator.

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
---

This problem was anticipated by Mark Brown on the very first submission 
of the driver but my knowledge about regulators at the time made me 
overlook what he was asking for, now that I have actually experienced 
the problem I've finally figured out what Mark was really referring to.

NOTE: initially I thought about CC-ing stable@kernel.org as well on 
this, as it is an actual fix, but then I checked that there are 
currently no users of the driver in mainline linux and I dropped it, is 
that how it should be?

Thanks,
   Antonio Ospite
   http://ao2.it

 drivers/leds/leds-regulator.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/leds/leds-regulator.c b/drivers/leds/leds-regulator.c
index 3790816..8497f56 100644
--- a/drivers/leds/leds-regulator.c
+++ b/drivers/leds/leds-regulator.c
@@ -178,6 +178,10 @@ static int __devinit regulator_led_probe(struct platform_device *pdev)
 	led->cdev.flags |= LED_CORE_SUSPENDRESUME;
 	led->vcc = vcc;
 
+	/* to handle correctly an already enabled regulator */
+	if (regulator_is_enabled(led->vcc))
+		led->enabled = 1;
+
 	mutex_init(&led->mutex);
 	INIT_WORK(&led->work, led_work);
 
-- 
1.7.4.1


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

* Re: [PATCH] leds: leds-regulator.c, fix handling already enabled regulators
  2011-03-23 21:00 [PATCH] leds: leds-regulator.c, fix handling already enabled regulators Antonio Ospite
@ 2011-03-23 21:21 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2011-03-23 21:21 UTC (permalink / raw)
  To: Antonio Ospite
  Cc: Richard Purdie, Liam Girdwood, Daniel Ribeiro, linux-kernel,
	linux-arm-kernel, openezx-devel

On Wed, Mar 23, 2011 at 10:00:02PM +0100, Antonio Ospite wrote:

> The leds-regulator driver was ignoring the initial status of the
> regulator; this resulted in rdev->use_count incremented up to 2 after
> calling regulator_led_set_value() in the .probe method when a regulator
> was already enabled at insmod time, and this made impossible to ever
> disable the regulator.

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

> NOTE: initially I thought about CC-ing stable@kernel.org as well on 
> this, as it is an actual fix, but then I checked that there are 
> currently no users of the driver in mainline linux and I dropped it, is 
> that how it should be?

Even if there's no users in mainline people could well be shipping out
of tree boards using it and could benefit from the code.  OTOH it's not
the most urgent thing ever.

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

end of thread, other threads:[~2011-03-23 21:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-23 21:00 [PATCH] leds: leds-regulator.c, fix handling already enabled regulators Antonio Ospite
2011-03-23 21:21 ` 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).