On Tue, Oct 24, 2023 at 10:57:38AM +0200, Stephan Gerhold wrote: > I think it does not change much for this patch, though. Even when > implemented in the core we still need to represent this situation > somehow for regulator_is_enabled(). Simply returning 0 (disabled) or > 1 (enabled) would be wrong. Do you think returning -EBUSY would be > appropriate for that? In these cases where we simply can't read the expectation is that we'll always be using the logical state - one way of thinking about it is that the operation is mostly a bootstrapping helper to figure out what the initial state is. A quick survey of users suggest they'll pretty much all be buggy if we start returning errors, and I frankly even if all the current users were fixed I'd expect that to continue to be a common error. I suppose that the effect of ignoring the possibility of error is like the current behaviour though. > The second challenge I see on a quick look is that both > qcom_smd-regulator.c and qcom-rpmh-regulator.c use their reference > counter internally in other function (e.g. to decide if a voltage change > should be sent, see "vreg->enabled" checks). I think we would also need > to add some rdev_is_enabled() function that would expose the core > reference counter to the driver? > Tracking the enable state in the driver (the way it is right now) is not > that much code, so I'm not entirely sure if we might actually end up > with more code/complexity when moving this to the core. We have to do the reference count in the core anyway since it's a reference count not just a simple on/off so it doesn't really cost us anything to make it available to drivers.
Attachment:
signature.asc
Description: PGP signature