> 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 countis init to 1.

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

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