El Fri, Feb 10, 2017 at 12:43:48PM -0800 Matthias Kaehlcke ha dit:

> The output voltage of a voltage controlled regulator can be controlled
> through the voltage of another regulator. The current version of this
> driver assumes that the output voltage is a linear function of the control
> voltage.
> 
> ...
>
> +static int vctrl_probe(struct platform_device *pdev)
> +{
> ...
> +     /* determine if the voltage range of the control supply is continuous */
> +     if ((regulator_count_voltages(vctrl->ctrl_supply) == 1) &&
> +         regulator_is_supported_voltage(vctrl->ctrl_supply,
> +                                        vrange_ctrl->min_uV,
> +                                        vrange_ctrl->min_uV) &&
> +         regulator_is_supported_voltage(vctrl->ctrl_supply,
> +                                        vrange_ctrl->max_uV,
> +                                        vrange_ctrl->max_uV)) {
> +             rdesc->continuous_voltage_range = true;
> +             rdesc->ops = &vctrl_ops_cont;
> +     } else {
> +             rdesc->ops = &vctrl_ops_non_cont;
> +     }

This creature of indisputable beauty seemed to do the job on my
test systen, however I just realized that the condition is BS. It
turns out that on my system the voltage count of 1 stems from the
parent, since the voltage count of the control supply itself is zero.

int regulator_count_voltages(struct regulator *regulator)
{
        struct regulator_dev    *rdev = regulator->rdev;

        if (rdev->desc->n_voltages)
                return rdev->desc->n_voltages;

        if (!rdev->supply)
                return -EINVAL;

        return regulator_count_voltages(rdev->supply);
}

This certainly doesn't help to determine if the regulator has a
continous voltage range. It seems we need a function that evaluates
rdesc->continuous_voltage_range

--

Matthias

Reply via email to