On Fri, Apr 02, 2010 at 09:30:10PM +0200, Jean Delvare wrote:
Yes, you could pass a pointer to the value or similar. OTOH that'd mean
managing the transition :/
I'm not sure there's actually much win from this information since we do
have cases with things like functionally limited regulators and error
conditions which mean that drivers end up having to cope with pretty
much all this stuff anyway. But yes, NULL should be just as good as a
stub.
In this case you don't need the if (voltage) check - the code that uses
supply_uV is going to have to cope with it being set to 0 if the driver
doesn't just give up, and the enable wants to happen anyway (perhaps
we've got a switchable supply we can't read the voltage of). It should
never make any odds if the notifier never gets called since the supply
could be invariant.
The regulator API is kind of odd here in that there's a lot of users
that are able to do things using it but which are largely indifferent to
if they're happening or not since the results are optimisations of
benefit to the system as a whole rather than directly used
functionality. The stubs are only attempting to cater for them and
don't cater for the other users that do care about what happens.
I agree that it's unusual but don't see any great alternatives that
don't involve things like pushing some stuff for the stub users more
into the core APIs (like how some platforms are integrating their clock
management into the PM framework) and I don't think we're anywhere near
the point where we know enough to say that's a good idea at the minute.
Actually having thought about that one a bit more I'm not so sure for
set_voltage() - the DVFS style drivers are in a similar position to the
basic power switching ones, they'd like to be able to lower the supplies
to save power but don't actually need that to happen. Needs a bit more
thought.
There are currently some functions that don't get stubbed, like
regulator_get_exclusive().
--