lkml.org 
[lkml]   [2008]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 05/15] regulator: regulator framework core
From
Date
On Thu, 2008-07-10 at 18:04 +0200, pHilipp Zabel wrote:
> On Thu, Jul 10, 2008 at 5:26 PM, Liam Girdwood
> <lg@opensource.wolfsonmicro.com> 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




\
 
 \ /
  Last update: 2008-07-10 19:13    [W:0.045 / U:1.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site