From: Isaac Scott <isaac.scott@ideasonboard.com>
To: "Hennerich, Michael" <Michael.Hennerich@analog.com>
Cc: "lgirdwood@gmail.com" <lgirdwood@gmail.com>,
"broonie@kernel.org" <broonie@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] RFC: regulator: ad5398: Change selector division calculation
Date: Wed, 29 Jan 2025 18:21:18 +0000 [thread overview]
Message-ID: <dd50b01ea752ef0a6c028cd7eebf927c5b2f877b.camel@ideasonboard.com> (raw)
In-Reply-To: <PH0PR03MB65127833FDCEA37075CBB3F68EEE2@PH0PR03MB6512.namprd03.prod.outlook.com>
Hi,
On Wed, 2025-01-29 at 08:34 +0000, Hennerich, Michael wrote:
>
>
> > -----Original Message-----
> > From: Isaac Scott <isaac.scott@ideasonboard.com>
> > Sent: Tuesday, January 28, 2025 6:32 PM
> > To: Hennerich, Michael <Michael.Hennerich@analog.com>
> > Cc: lgirdwood@gmail.com; broonie@kernel.org;
> > linux-kernel@vger.kernel.org;
> > Isaac Scott <isaac.scott@ideasonboard.com>
> > Subject: [PATCH v2 2/3] RFC: regulator: ad5398: Change selector
> > division
> > calculation
> >
> > [External]
> >
> > If the AD5398 is defined to have a current limit with no range,
> > i.e.
> > when max_Ua and min_Ua are equal, the DIV_ROUND_UP erroneously
> > tries
> > to set the current to a higher level than the max_Ua, which causes
> > the driver to
> > fail to set the current. Fix this so the driver slightly
> > underestimates the current
> > to set.
> >
> > Signed-off-by: Isaac Scott <isaac.scott@ideasonboard.com>
> > ---
> > drivers/regulator/ad5398.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/regulator/ad5398.c
> > b/drivers/regulator/ad5398.c index
> > e6f45c6e750c..0c60ecd1f0f2 100644
> > --- a/drivers/regulator/ad5398.c
> > +++ b/drivers/regulator/ad5398.c
> > @@ -98,8 +98,7 @@ static int ad5398_set_current_limit(struct
> > regulator_dev
> > *rdev, int min_uA, int
> > if (min_uA > chip->max_uA || max_uA < chip->min_uA)
> > return -EINVAL;
> >
> > - selector = DIV_ROUND_UP((min_uA - chip->min_uA) * chip-
> > > current_level,
> > - range_uA);
> > + selector = ((min_uA - chip->min_uA) * chip->current_level
> > /
> > range_uA);
>
> Not sure if this is a good idea. The rational was to set the limit
> slightly higher.
> This will do the opposite. The ranges are already checked.
> Why not clamp() the calculated value?
That sounds like a better idea. Thank you! Out of interest, why is it
beneficial for the limit to be higher?
>
> > if (ad5398_calc_current(chip, selector) > max_uA)
> > return -EINVAL;
> >
> > --
> > 2.43.0
>
Best wishes,
Isaac
next prev parent reply other threads:[~2025-01-29 18:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-28 17:31 [PATCH v2 0/3] regulator: Add device tree support to AD5398 Isaac Scott
2025-01-28 17:31 ` [PATCH v2 1/3] regulator: ad5398: change enable bit name to improve readibility Isaac Scott
2025-01-29 8:31 ` Hennerich, Michael
2025-02-05 18:45 ` Guenter Roeck
2025-02-06 9:59 ` Isaac Scott
2025-02-06 11:30 ` Mark Brown
2025-01-28 17:31 ` [PATCH v2 2/3] RFC: regulator: ad5398: Change selector division calculation Isaac Scott
2025-01-29 8:34 ` Hennerich, Michael
2025-01-29 18:21 ` Isaac Scott [this message]
2025-02-06 13:38 ` Isaac Scott
2025-01-28 17:31 ` [PATCH v2 3/3] regulator: ad5398: Add device tree support Isaac Scott
2025-01-29 8:32 ` Hennerich, Michael
2025-02-03 19:57 ` (subset) [PATCH v2 0/3] regulator: Add device tree support to AD5398 Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dd50b01ea752ef0a6c028cd7eebf927c5b2f877b.camel@ideasonboard.com \
--to=isaac.scott@ideasonboard.com \
--cc=Michael.Hennerich@analog.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome