On Tue, Nov 13, 2012 at 10:49:37AM +0100, Marek Szyprowski wrote:
> + if (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE) {
> + if (rdev->desc->n_voltages)
> + return rdev->desc->n_voltages;
> + else
> + return -EINVAL;
> + } else {
> + return 1;
> + }
Hrm, now I can read the logic I'm not convinced this is a good idea.
This will report that we have an available voltage for devices which
don't know their voltage (things like battery supplies often do this as
the voltage is unregulated) and it will mean that we are doing something
different for the case where there's only one voltage (reporting the
restricted count instead of the physically supported count).
I think we want a regulator_can_change_voltage() or possibly a count
function (though I can't see any use cases except this) which answers
the question directly instead of layering on top of this function.