Re: [PATCH] leds: lm3530: fix handling of already enabled regulators

From: Mark Brown
Date: Mon Apr 23 2012 - 07:09:18 EST

On Sun, Apr 22, 2012 at 11:11:48PM +0800, Axel Lin wrote:

> drvdata->regulator = NULL;
> goto err_regulator_get;
> }
> + drvdata->enable = regulator_is_enabled(drvdata->regulator);

This isn't sufficient for what the driver is doing - it also needs to
enable the regulator. Regulator enables are reference counted (since
the regulator can be shared by many device supplies) so if this driver
doesn't reference the regulator when it's needed then it could get
powered off.

If this regulator is the actual LED then the current default of assuming
the regulator is off on boot isn't ideal either as it means that if the
regulator is enabled on boot then the LED may be left on even though the
driver thinks it's off.

Attachment: signature.asc
Description: Digital signature