
Hello Simon,
int power_domain_on(struct power_domain *power_domain) {
...
if (priv->on_count++ > 0)
return 0;
-EALREADY
...
int power_domain_off(struct power_domain *power_domain) {
...
if (priv->on_count-- > 1)
return 0;
-EBUSY
See how the regulator uclass does it.
I really does not understand why we would like to do that.
It is perfectly normal operation to call power_domain_on/off() on the same power domain several times in a row and there is no reason to return an error code. It is quite the opposite, the main reason for power domains is to act like shared regulators. Se while a regulator has one user and doing the same action on it several times does not make much sense and can be reported, that is not how power domains have been thought about in the first place.
Hence, I do not agree with returning error codes in these situations, they are misleading and they would have to be ignored anyway.
Thanks, Miquèl