From: Mark Brown <broonie@kernel.org>
To: Matthias Kaehlcke <mka@chromium.org>
Cc: lgirdwood@gmail.com, Douglas Anderson <dianders@chromium.org>,
briannorris@chromium.org, javier@dowhile0.org,
robh+dt@kernel.org, mark.rutland@arm.com,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 1/4] regulator: Add set_voltage_time op
Date: Tue, 13 Sep 2016 00:57:58 +0100 [thread overview]
Message-ID: <20160912235758.GO27946@sirena.org.uk> (raw)
In-Reply-To: <20160912231851.GA62872@google.com>
[-- Attachment #1: Type: text/plain, Size: 2422 bytes --]
On Mon, Sep 12, 2016 at 04:18:51PM -0700, Matthias Kaehlcke wrote:
> El Mon, Sep 12, 2016 at 07:32:30PM +0100 Mark Brown ha dit:
> > On Tue, Sep 06, 2016 at 12:03:15PM -0700, Matthias Kaehlcke wrote:
> > > - /* Call set_voltage_time_sel if successfully obtained old_selector */
> > > - if (ret == 0 && !rdev->constraints->ramp_disable && old_selector >= 0
> > > - && old_selector != selector) {
> > > + if (ret != 0 || rdev->constraints->ramp_disable)
> > > + goto no_delay;
> > You probably want to do the refactoring for splitting out decisions
> > about old_selector separately, it'll make the diff clearer.
> The old_selector conditions could be moved into the "else if
> (rdev->desc->ops->set_voltage_sel)" branch above, is that you mean?
No, what I mean is this change is doing a bunch of moving code around as
well as adding new things which makes it hard to spot where the new
things are. Moving the code around separately (that is, in a separate
patch) would make the review easier.
> > > + /* Insert any necessary delays */
> > > + if (delay >= 1000) {
> > > + mdelay(delay / 1000);
> > > + udelay(delay % 1000);
> > > + } else if (delay) {
> > > + udelay(delay);
> > > + }
> > > +no_delay:
> > Why were the gotos there?
> Not sure how to interpret your question. Would you prefer no to use
> gotos, should the notification be skipped in case the voltage is not
> changed, do you expect a comment, ...?
I mean I couldn't tell why a goto was a good idea for what seemed like
perfectly normal conditional logic. Either I couldn't tell because it's
not a good idea or it is a good idea but should be clearer in some way
but since I didn't really understand what the purpose of doing the gotos
was I can't say for sure either way.
> > The diff and I expect the resulting code would be a lot clearer if we
> > just left most of the function indented as it is and simply directly
> > returned set_voltage_time(). Which is what we do anyway so no need to
> > reindent the rest of the code.
> Ok, with your comment below on a default implementation this would
> become something like:
> if (ops->set_voltage_time) {
> return ops->set_voltage_time(...);
> } else if (!ops->set_voltage_time_sel) {
> return _regulator_set_voltage_time(..);
> }
I suspect you'll end up with more refactoring than that around
_set_voltage_time() and this'll be inside that function but I've lost
context here so ICBW.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2016-09-12 23:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20160906190315.GC92391@google.com>
2016-09-12 18:32 ` Mark Brown
2016-09-12 23:18 ` Matthias Kaehlcke
2016-09-12 23:57 ` Mark Brown [this message]
2016-09-13 1:18 ` Matthias Kaehlcke
2016-09-13 19:12 ` Matthias Kaehlcke
2016-09-06 21:01 Matthias Kaehlcke
2016-09-06 22:40 ` Mark Brown
2016-09-06 23:38 ` 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=20160912235758.GO27946@sirena.org.uk \
--to=broonie@kernel.org \
--cc=briannorris@chromium.org \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=javier@dowhile0.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mka@chromium.org \
--cc=robh+dt@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
all inboxes | Powered by JetHome®