[lkml]   [2012]   [Apr]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] leds: lm3530: fix handling of already enabled regulators
> In my opinion, current source code is the simplest way.
>        1. The variable 'drvdata->enabled' is initialized as false.
>        2. The regulator is enabled and the variable is updated when the driver is probed.
>           (If the regulator is already on, it's ok - keep going ...)
>        3. The variable is updated when regulator_enable()/regulator_disable() is called by the lm3530 driver.
>           (If another driver tries to turn off the regulator, it can't be allowed
>            because the reference count was incremented by the lm3530 driver.)

No. Current code is buggy.

Let me put it this way: Assume only this driver is using the regulator.
If the regulator is enabled on boot, which means the reference count
is init to 1.

In probe, the driver assumes the enable variable is false by default and it
calls regulator_enable() in lm3530_init_registers(). This increases
the reference count to 2.

Then if we set brt_val to 0 in lm3530_brightness_set, which will then call
regulator_disable(). In this case, the reference count becomes 1, note that
the reference count is not 0 so the LED may be left on even though the driver
thinks it's off.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2012-04-24 10:51    [W:0.093 / U:1.720 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site