From: Antonio Ospite Date: Thu, 14 Apr 2011 22:21:59 +0000 (-0700) Subject: leds/leds-regulator.c: fix handling of already enabled regulators X-Git-Tag: upstream/snapshot3+hdmi~10657 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=592ce316395abc6b4e96c1ac198e5f347bb5d578;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git leds/leds-regulator.c: fix handling of already enabled regulators 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 being incremented to 2 after calling regulator_led_set_value() in the .probe method when a regulator was already enabled at insmod time, which made it impossible to ever disable the regulator. Signed-off-by: Antonio Ospite Cc: Richard Purdie Cc: Antonio Ospite Acked-by: Mark Brown Cc: Liam Girdwood Cc: Daniel Ribeiro Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- 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);