Re: [PATCH 05/15] regulator: regulator framework core

From: Liam Girdwood
Date: Thu Jul 10 2008 - 13:08:29 EST


On Thu, 2008-07-10 at 18:04 +0200, pHilipp Zabel wrote:
> On Thu, Jul 10, 2008 at 5:26 PM, Liam Girdwood
> <lg@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

> > +
> > +/* current constraint check */
> > +static int regulator_check_current_limit(struct regulator_dev *rdev,
> > + int *min_uA, int *max_uA)
> > +{
> > + BUG_ON(*min_uA > *max_uA);
> > +
> > + if (!rdev->constraints) {
> > + printk(KERN_ERR "%s: no constraints for %s\n", __func__,
> > + rdev->desc->name);
> > + return -ENODEV;
> > + }
> > + if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_CURRENT)) {
> > + printk(KERN_ERR "%s: operation not allowed for %s\n",
> > + __func__, rdev->desc->name);
> > + return -EPERM;
> > + }
> > +
> > + if (*max_uA > rdev->constraints->max_uA ||
> > + *min_uA < rdev->constraints->min_uA) {
> > + printk(KERN_ERR "%s: invalid current range %d-%duA for %s\n",
> > + __func__, *min_uA, *max_uA, rdev->desc->name);
> > + return -EINVAL;
> > + }
> > +
> > + *min_uA = max(*min_uA, rdev->constraints->min_uA);
> > + *max_uA = min(*max_uA, rdev->constraints->max_uA);
>
> I don't understand this part. If max_uA > constraints->max_uA or
> min_uA < constraints->min_uA, we returned with -EINVAL above. So in
> this place
> I'd expect min_uA to be >= constraints->min_uA and max_uA <=
> constraints->max_uA, in which case the last two statements are no-ops.
>

It looks like the limit check with printk was added post min()/max()
here and does indeed make them no-ops. I'll remove.

> In comparison, regulator_check_voltage silently fixes the requested
> voltage range to fit into the constraints. Should
> regulator_check_current_limit do the same?

Yes, current should do the same and make sure the our consumers
requested current window fits into the system constraints like voltage.
Atm it just rejects it.

Thanks

Liam


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/