From: thierry.reding@gmail.com (Thierry Reding)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] pwm: Add new helper to initialize a pwm_state variable with defaults
Date: Fri, 16 Nov 2018 11:24:28 +0100 [thread overview]
Message-ID: <20181116102428.GC14769@ulmo> (raw)
In-Reply-To: <20181115210535.mxmyjjbpzrjdufsr@pengutronix.de>
On Thu, Nov 15, 2018 at 10:05:35PM +0100, Uwe Kleine-K?nig wrote:
> Hello Thierry,
>
> On Thu, Nov 15, 2018 at 05:21:59PM +0100, Thierry Reding wrote:
> > On Thu, Nov 15, 2018 at 10:16:44AM +0100, Uwe Kleine-K?nig wrote:
> > > On Wed, Nov 14, 2018 at 01:32:36PM +0100, Thierry Reding wrote:
> > > > On Fri, Oct 26, 2018 at 08:41:55PM +0200, Uwe Kleine-K?nig wrote:
> > > > > This helps to convert drivers from the legacy API to pwm_apply_state without
> > > > > having to make the aware of the configured polarity (and in some cases even
> > > > > period).
> > > > >
> > > > > Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
> > > > > ---
> > > > > include/linux/pwm.h | 13 ++++++++++---
> > > > > 1 file changed, 10 insertions(+), 3 deletions(-)
> > > >
> > > > So if I understand your intention correctly here you want consumers to
> > > > be able to get at the default state, which would be the state as it was
> > > > "configured" in DT or the PWM lookup table so that you can modify that
> > > > state (well, really just setting the duty-cycle) before you actually
> > > > send the state to the hardware.
> > > >
> > > > So the difference to pwm_apply_args() is that you don't want the driver
> > > > to specifically program a duty cycle of 0 before setting the actual duty
> > > > cycle that you want to set.
> > > >
> > > > Is that about right?
> > >
> > > Yes, and a resulting advantage is that the apply callback is only called
> > > once.
> > >
> > > > Isn't that exactly what pwm_init_state() already does? pwm-backlight
> > > > uses it for exactly the same purpose that you seem to be using it in
> > > > RX1950 backlight control.
> > >
> > > I didn't use pwm_init_state because that doesn't give a helpful value
> > > for state->enabled. (I think it is: if the driver provides a get_state
> > > callback it is whatever that one set, otherwise it's off.)
> >
> > That's correct. It's pretty much the same thing that you have, except
> > you explicitly set enable = false. But that's not really important
> > because consumers are supposed to explicitly override that anyway.
>
> If we hardcode to enable=false the call to pwm_get_state could be
> dropped, too. Then the two functions are really semantically identical.
> >
> > > Also the name pwm_init_state isn't that good IMHO. Just from the name
> > > I'd expect it to be something like
> > >
> > > memset(state, 0, sizeof(&state));
> > >
> > > instead of something more informed that depends on hardware state and/or
> > > data provided by a device tree.
> >
> > Be that as it may, the kerneldoc is pretty explicit about what it does
> > and so is the code. Not liking the name shouldn't be an excuse for
> > duplicating functionality.
>
> With your suggestion to move the initialisation of ->state into the
> core, maybe this function can go away from the public API such that the
> naming doesn't really matter (and can be adapted easily).
Yeah, I think it would be best to move it into core.c and make it static
in that case. There should be no need for anyone to create any special
state, they can just use pwm_get_state() instead.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181116/621c9ecc/attachment.sig>
prev parent reply other threads:[~2018-11-16 10:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-26 18:41 [PATCH 1/4] pwm: Add new helper to initialize a pwm_state variable with defaults Uwe Kleine-König
2018-10-26 18:41 ` [PATCH 2/4] ARM: S3C24XX: rx1950: make use of atomic PWM API Uwe Kleine-König
2018-10-29 10:46 ` Krzysztof Kozlowski
2018-11-14 9:15 ` Uwe Kleine-König
2018-11-14 12:08 ` Thierry Reding
2018-11-15 8:58 ` Uwe Kleine-König
2018-11-15 16:15 ` Thierry Reding
2018-11-15 21:00 ` Uwe Kleine-König
2018-10-26 18:41 ` [PATCH 3/4] bus: ts-nbus: convert to " Uwe Kleine-König
2018-11-14 12:15 ` Thierry Reding
2018-10-26 18:41 ` [PATCH 4/4] bus: ts-nbus: weaken driver dependency to allow broader compile testing Uwe Kleine-König
2018-11-14 12:18 ` Thierry Reding
2018-10-29 11:33 ` [PATCH 1/4] pwm: Add new helper to initialize a pwm_state variable with defaults Thierry Reding
2018-11-03 14:25 ` Uwe Kleine-König
2018-11-08 15:13 ` Uwe Kleine-König
2018-11-14 12:32 ` Thierry Reding
2018-11-15 9:16 ` Uwe Kleine-König
2018-11-15 16:21 ` Thierry Reding
2018-11-15 21:05 ` Uwe Kleine-König
2018-11-16 10:24 ` Thierry Reding [this message]
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=20181116102428.GC14769@ulmo \
--to=thierry.reding@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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).