linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Ospite <ospite@studenti.unina.it>
To: Richard Purdie <rpurdie@rpsys.net>
Cc: Antonio Ospite <ospite@studenti.unina.it>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Liam Girdwood <lrg@slimlogic.co.uk>,
	Daniel Ribeiro <drwyrm@gmail.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	openezx-devel@lists.openezx.org
Subject: [PATCH] leds: leds-regulator.c, fix handling already enabled regulators
Date: Wed, 23 Mar 2011 22:00:02 +0100	[thread overview]
Message-ID: <1300914002-17760-1-git-send-email-ospite@studenti.unina.it> (raw)

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


             reply	other threads:[~2011-03-23 21:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-23 21:00 Antonio Ospite [this message]
2011-03-23 21:21 ` [PATCH] leds: leds-regulator.c, fix handling already enabled regulators Mark Brown

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=1300914002-17760-1-git-send-email-ospite@studenti.unina.it \
    --to=ospite@studenti.unina.it \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=drwyrm@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    --cc=openezx-devel@lists.openezx.org \
    --cc=rpurdie@rpsys.net \
    /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).