Hi Miquel, On Mon, 20 Jan 2025 at 03:34, Miquel Raynal <[email protected]> wrote: > > 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.
I am not aware of any difference between these two subsystems. If we want a power domain to actually turn off, how many times do we need to call power_domain_off()? The function silently does nothing in many cases, so it is not deterministic. In the case where we *actually* want to turn the power domain off, we are at a loss as to what code to write. > > Hence, I do not agree with returning error codes in these situations, > they are misleading and they would have to be ignored anyway. > How about creating a power_domain_off_if_allowed() or power_domain_soft_off/on() or power_domain_req_off (for request)? Regards, SImon

