Re: [PATCH 1/2] MMC/pxamci: workaround regulator framework bugs

From: Mark Brown
Date: Fri Jul 24 2009 - 10:36:04 EST


On Wed, Jul 22, 2009 at 02:03:07PM -0700, David Brownell wrote:

> /* that this simple idiom would finally work */
> if (regulator_is_enabled(r))
> regulator_disable(r);

For the avoidance of future disappointment please note that an exclusive
access request does not remove the reference counting on the regulator,
it only changes the way in which it is intialised. This means that the
above code is only guaranteed to cause the regulator to be disabled so
long as the consumer never calls enable() twice without a matching
disable(). It will, however, not return an error due to unbalanced
enables and disables which I believe is your primary requirement here.

> of which were within (d) an ever-increasing number of constraints
> you grew with each new iteration. I had to try so many different
> approaches since nothing seemed to be getting through. The lack

For clarity and in the hope that this helps to avoid future issues
let me list the three major constraints in this area:

- The API supports shared regulators.
- Regulator enabling by software is reference counted.
- Changing the state of regulators before drivers have had a chance to
take control of the devices is very disruptive to the system and
needs to be avoided as a result.

Everything else flows from those, in conjunction with the standard
considerations about making sure that any transitions are managed in as
graceful a fashion as possible.

I'm leaving the rest of your mail because I don't think discussing that
further here is going to get us anywhere.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/