Re: [RFC PATCH] regulator: introduce boot protection flag
From: Pingbo Wen
Date: Thu Jun 23 2016 - 08:02:18 EST
Hi, Mark
On Friday, June 17, 2016 07:42 PM, Mark Brown wrote:
> On Fri, Jun 17, 2016 at 11:34:25AM +0800, Pingbo Wen wrote:
>> On Wednesday, June 15, 2016 09:32 PM, Mark Brown wrote:
>
>>> Having the consumer driver know that it's "critical" seems wrong since
>>> different systems may have different ideas about that, it's probably
>>> better to hook this in with the device model so that when the device
>>> finishes probing that kicks things off.
>
>> That will imply the protection would be end when the specific device has
>> probed, and consumers should take their place at the same time. But
>> there have some other devices, which will set the consumer in a IRQ
>> event, or after some other events, can't be covered.
>
> I don't understand what this means, sorry.
>
I mean maybe there's some consumer driver only do partial initialization
during probing.
>> We can set the protection flag easily, but it's hard to tell whether a
>> consumer is well initialized, the end of protection, since regulator
>> consumer is not initialized within one call.
>
> If the driver is not initializing itself during probe the driver is
> doing something wrong and needs to be fixed anyway.
>
OK, if all driver have full initialized during probing, and we need
insert a hook after driver probing. I think we can add a function in
driver/base/dd.c:driver_probe_device() as this:
ret = really_probe(dev, drv);
...
if (!ret)
regulator_clean_up(dev);
And in regulator_clean_up(), we can iterate all regulator deivce, and
call a regulator_clear_boot_protection function:
if (!rdev->constraints->boot_protection)
return 0;
if (strcmp(rdev->constraints->critical_consumer, dev_name(dev)))
return 0;
rdev->constraints->boot_protection = 0;
...
-real clean stuffs-
the critical_consumer can be specified in devicetree.
Add a callback in driver_probe_device() is not so good, but it's fine
for me.
Pingbo