[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1215709668.13431.83.camel@odin>
Date: Thu, 10 Jul 2008 18:07:48 +0100
From: Liam Girdwood <lg@...nsource.wolfsonmicro.com>
To: pHilipp Zabel <philipp.zabel@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
arm kernel <linux-arm-kernel@...ts.arm.linux.org.uk>,
Mark Brown <broonie@...nsource.wolfsonmicro.com>
Subject: Re: [PATCH 05/15] regulator: regulator framework core
On Thu, 2008-07-10 at 18:04 +0200, pHilipp Zabel wrote:
> On Thu, Jul 10, 2008 at 5:26 PM, Liam Girdwood
> <lg@...nsource.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists