From: Thierry Reding <thierry.reding@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-pwm@vger.kernel.org,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ilkka Koskinen <ilkka.koskinen@intel.com>
Subject: Re: [PATCH v2 4/4] pwm: lpss: Switch to new atomic API
Date: Fri, 20 Jan 2017 11:48:27 +0100 [thread overview]
Message-ID: <20170120104827.GI3824@ulmo.ba.sec> (raw)
In-Reply-To: <1484836366.2133.243.camel@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2917 bytes --]
On Thu, Jan 19, 2017 at 04:32:46PM +0200, Andy Shevchenko wrote:
> On Wed, 2017-01-18 at 12:15 +0100, Thierry Reding wrote:
> > On Mon, Jan 02, 2017 at 11:16:47AM +0200, Andy Shevchenko wrote:
> > > Instead of doing things separately, which is not so reliable on some
> > > platforms,
> > > switch the driver to use new atomic API, i.e. ->apply() callback.
> > >
> > > The change has been tested on Intel platforms such as Broxton,
> > > BayTrail, and
> > > Merrifield.
>
> > > +static int pwm_lpss_apply(struct pwm_chip *chip, struct pwm_device
> > > *pwm,
> > > + struct pwm_state *state)
> > > +{
> > > + struct pwm_lpss_chip *lpwm = to_lpwm(chip);
> > > +
> > > + if (state->enabled) {
> > > + if (!pwm_is_enabled(pwm)) {
> > > + pm_runtime_get_sync(chip->dev);
> > > + pwm_lpss_config(lpwm, pwm, state-
> > > >duty_cycle, state->period);
> > > + pwm_lpss_enable(pwm);
> > > + } else {
> > > + pwm_lpss_config(lpwm, pwm, state-
> > > >duty_cycle, state->period);
> > > + }
> > > + } else if (pwm_is_enabled(pwm)) {
> > > + pwm_lpss_disable(pwm);
> > > + pm_runtime_put(chip->dev);
> > > + }
> >
> > Would you mind doing another pass over this and inline the
> > pwm_lpss_enable(), pwm_lpss_disable() and pwm_lpss_config() functions
> > into pwm_lpss_apply()? Your current version effectively duplicates the
> > transitional helpers, but the goal should be to fully get rid of the
> > remainders of the legacy API.
>
> I don't see how inlining them helps. For me readability of code is more
> important than names of the functions.
>
> I can rename functions, but I would like to have them separate from the
> ->apply() callback.
>
> Compiler inlines them during optimization.
>
> > Besides being much cleaner this also gets rid of slight
> > inconsistencies
> > between the two APIs.
>
> I don't see how One Big Function can be cleaner than split version. But
> I give a try to see it on my side when you have settled with Mika's
> patch.
It doesn't necessarily have to be one big function. You obviously need
to find the right balance. If the combined function is still readable,
there's no reason, in my opinion, to split it up. If it gets too large
I think a good split is to keep all of the register programming to be
within ->apply() and have a helper that computes the values to program
and that is called from ->apply().
What I want to avoid is people converting to atomic by mindlessly
duplicating the fallback path in pwm_apply_state().
The goal of the atomic API is that programming of the hardware becomes
atomic. So if you have any computations that may fail because of invalid
inputs or similar, then all of that should happen before any registers
are touched. That's difficult to do with the old enable/config/disable
callbacks, so I don't think we should be following it when converting.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-01-20 10:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-02 9:16 [PATCH v2 0/4] pwm: lpss: clean up series Andy Shevchenko
2017-01-02 9:16 ` [PATCH v2 1/4] pwm: lpss: Avoid potential overflow of base_unit Andy Shevchenko
2017-01-02 9:16 ` [PATCH v2 2/4] pwm: lpss: Allow duty cycle to be 0 Andy Shevchenko
2017-01-02 9:16 ` [PATCH v2 3/4] pwm: lpss: Do not export board infos for different PWM types Andy Shevchenko
2017-01-18 11:11 ` Thierry Reding
2017-01-18 13:01 ` Mika Westerberg
2017-01-20 11:00 ` Thierry Reding
2017-01-20 11:15 ` Mika Westerberg
2017-01-20 11:18 ` Thierry Reding
2017-01-02 9:16 ` [PATCH v2 4/4] pwm: lpss: Switch to new atomic API Andy Shevchenko
2017-01-18 11:15 ` Thierry Reding
2017-01-19 14:32 ` Andy Shevchenko
2017-01-20 10:48 ` Thierry Reding [this message]
2017-01-05 8:09 ` [PATCH v2 0/4] pwm: lpss: clean up series Ilkka Koskinen
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=20170120104827.GI3824@ulmo.ba.sec \
--to=thierry.reding@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ilkka.koskinen@intel.com \
--cc=linux-pwm@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).