From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 12 Apr 2016 14:17:18 +0200 From: Boris Brezillon To: Thierry Reding Cc: linux-pwm@vger.kernel.org, Mike Turquette , Stephen Boyd , linux-clk@vger.kernel.org, Mark Brown , Liam Girdwood , Kamil Debski , lm-sensors@lm-sensors.org, Jean Delvare , Guenter Roeck , Dmitry Torokhov , linux-input@vger.kernel.org, Bryan Wu , Richard Purdie , Jacek Anaszewski , linux-leds@vger.kernel.org, Maxime Ripard , Chen-Yu Tsai , linux-sunxi@googlegroups.com, Joachim Eastwood , Thomas Petazzoni , Heiko Stuebner , linux-rockchip@lists.infradead.org, Jingoo Han , Lee Jones , linux-fbdev@vger.kernel.org, Jean-Christophe Plagniol-Villard , Tomi Valkeinen , Robert Jarzmik , Alexandre Belloni , Kukjin Kim , Krzysztof Kozlowski , linux-samsung-soc@vger.kernel.org, intel-gfx@lists.freedesktop.org, Daniel Vetter , Jani Nikula , Jonathan Corbet , linux-doc@vger.kernel.org, David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Hartley Sweeten , Ryan Mallon , Alexander Shiyan , Milo Kim Subject: Re: [PATCH v5 15/46] pwm: introduce the pwm_state concept Message-ID: <20160412141718.5fe4cf24@bbrezillon> In-Reply-To: <20160412114904.GM18882@ulmo.ba.sec> References: <1459368249-13241-1-git-send-email-boris.brezillon@free-electrons.com> <1459368249-13241-16-git-send-email-boris.brezillon@free-electrons.com> <20160412114904.GM18882@ulmo.ba.sec> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII List-ID: On Tue, 12 Apr 2016 13:49:04 +0200 Thierry Reding wrote: > On Wed, Mar 30, 2016 at 10:03:38PM +0200, Boris Brezillon wrote: > > The PWM state, represented by its period, duty_cycle and polarity, > > is currently directly stored in the PWM device. > > Declare a pwm_state structure embedding those field so that we can later > > use this struct to atomically update all the PWM parameters at once. > > > > All pwm_get_xxx() helpers are now implemented as wrappers around > > pwm_get_state(). > > > > Signed-off-by: Boris Brezillon > > --- > > drivers/pwm/core.c | 8 ++++---- > > include/linux/pwm.h | 54 +++++++++++++++++++++++++++++++++++++++++------------ > > 2 files changed, 46 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c > > index 6433059..f3f91e7 100644 > > --- a/drivers/pwm/core.c > > +++ b/drivers/pwm/core.c > > @@ -268,7 +268,7 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip, > > pwm->chip = chip; > > pwm->pwm = chip->base + i; > > pwm->hwpwm = i; > > - pwm->polarity = polarity; > > + pwm->state.polarity = polarity; > > Would this not more correctly be assigned to pwm->args.polarity? After > all this is setting up the "initial" state, much like DT or the lookup > tables would for duty cycle and period. Yes, I wasn't sure about the pwm_add_with_polarity() meaning. To me, all the reference info should be extracted from DT, PWM lookup table or driver specific ->request() implementation, but I can definitely initialize the args.polarity here too. Should I keep the pwm->state.polarity assignment (to set the initial polarity when the driver does not support hardware readout)? -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Brezillon Date: Tue, 12 Apr 2016 12:17:18 +0000 Subject: Re: [PATCH v5 15/46] pwm: introduce the pwm_state concept Message-Id: <20160412141718.5fe4cf24@bbrezillon> List-Id: References: <1459368249-13241-1-git-send-email-boris.brezillon@free-electrons.com> <1459368249-13241-16-git-send-email-boris.brezillon@free-electrons.com> <20160412114904.GM18882@ulmo.ba.sec> In-Reply-To: <20160412114904.GM18882@ulmo.ba.sec> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Thierry Reding Cc: Milo Kim , Kamil Debski , Heiko Stuebner , linux-doc@vger.kernel.org, David Airlie , Mike Turquette , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Alexandre Belloni , Daniel Vetter , Lee Jones , linux-clk@vger.kernel.org, linux-leds@vger.kernel.org, Krzysztof Kozlowski , linux-samsung-soc@vger.kernel.org, Alexander Shiyan , Jonathan Corbet , Robert Jarzmik , lm-sensors@lm-sensors.org, linux-rockchip@lists.infradead.org, Chen-Yu Tsai , Tomi Valkeinen , linux-input@vger.kernel.org, Jean-Christophe On Tue, 12 Apr 2016 13:49:04 +0200 Thierry Reding wrote: > On Wed, Mar 30, 2016 at 10:03:38PM +0200, Boris Brezillon wrote: > > The PWM state, represented by its period, duty_cycle and polarity, > > is currently directly stored in the PWM device. > > Declare a pwm_state structure embedding those field so that we can later > > use this struct to atomically update all the PWM parameters at once. > > > > All pwm_get_xxx() helpers are now implemented as wrappers around > > pwm_get_state(). > > > > Signed-off-by: Boris Brezillon > > --- > > drivers/pwm/core.c | 8 ++++---- > > include/linux/pwm.h | 54 +++++++++++++++++++++++++++++++++++++++++------------ > > 2 files changed, 46 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c > > index 6433059..f3f91e7 100644 > > --- a/drivers/pwm/core.c > > +++ b/drivers/pwm/core.c > > @@ -268,7 +268,7 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip, > > pwm->chip = chip; > > pwm->pwm = chip->base + i; > > pwm->hwpwm = i; > > - pwm->polarity = polarity; > > + pwm->state.polarity = polarity; > > Would this not more correctly be assigned to pwm->args.polarity? After > all this is setting up the "initial" state, much like DT or the lookup > tables would for duty cycle and period. Yes, I wasn't sure about the pwm_add_with_polarity() meaning. To me, all the reference info should be extracted from DT, PWM lookup table or driver specific ->request() implementation, but I can definitely initialize the args.polarity here too. Should I keep the pwm->state.polarity assignment (to set the initial polarity when the driver does not support hardware readout)? -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Brezillon Subject: Re: [PATCH v5 15/46] pwm: introduce the pwm_state concept Date: Tue, 12 Apr 2016 14:17:18 +0200 Message-ID: <20160412141718.5fe4cf24@bbrezillon> References: <1459368249-13241-1-git-send-email-boris.brezillon@free-electrons.com> <1459368249-13241-16-git-send-email-boris.brezillon@free-electrons.com> <20160412114904.GM18882@ulmo.ba.sec> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Return-path: In-Reply-To: <20160412114904.GM18882@ulmo.ba.sec> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Thierry Reding Cc: Milo Kim , Kamil Debski , Heiko Stuebner , linux-doc@vger.kernel.org, David Airlie , Mike Turquette , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Alexandre Belloni , Daniel Vetter , Lee Jones , linux-clk@vger.kernel.org, linux-leds@vger.kernel.org, Krzysztof Kozlowski , linux-samsung-soc@vger.kernel.org, Alexander Shiyan , Jonathan Corbet , Robert Jarzmik , lm-sensors@lm-sensors.org, linux-rockchip@lists.infradead.org, Chen-Yu Tsai , Tomi Valkeinen , linux-input@vger.kernel.org, Jean-Christophe List-Id: linux-input@vger.kernel.org T24gVHVlLCAxMiBBcHIgMjAxNiAxMzo0OTowNCArMDIwMApUaGllcnJ5IFJlZGluZyA8dGhpZXJy eS5yZWRpbmdAZ21haWwuY29tPiB3cm90ZToKCj4gT24gV2VkLCBNYXIgMzAsIDIwMTYgYXQgMTA6 MDM6MzhQTSArMDIwMCwgQm9yaXMgQnJlemlsbG9uIHdyb3RlOgo+ID4gVGhlIFBXTSBzdGF0ZSwg cmVwcmVzZW50ZWQgYnkgaXRzIHBlcmlvZCwgZHV0eV9jeWNsZSBhbmQgcG9sYXJpdHksCj4gPiBp cyBjdXJyZW50bHkgZGlyZWN0bHkgc3RvcmVkIGluIHRoZSBQV00gZGV2aWNlLgo+ID4gRGVjbGFy ZSBhIHB3bV9zdGF0ZSBzdHJ1Y3R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19fXwpJbnRlbC1nZnggbWFpbGluZyBsaXN0CkludGVsLWdmeEBsaXN0cy5mcmVlZGVza3RvcC5v cmcKaHR0cHM6Ly9saXN0cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9pbnRlbC1n ZngK From mboxrd@z Thu Jan 1 00:00:00 1970 From: boris.brezillon@free-electrons.com (Boris Brezillon) Date: Tue, 12 Apr 2016 14:17:18 +0200 Subject: [PATCH v5 15/46] pwm: introduce the pwm_state concept In-Reply-To: <20160412114904.GM18882@ulmo.ba.sec> References: <1459368249-13241-1-git-send-email-boris.brezillon@free-electrons.com> <1459368249-13241-16-git-send-email-boris.brezillon@free-electrons.com> <20160412114904.GM18882@ulmo.ba.sec> Message-ID: <20160412141718.5fe4cf24@bbrezillon> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Tue, 12 Apr 2016 13:49:04 +0200 Thierry Reding wrote: > On Wed, Mar 30, 2016 at 10:03:38PM +0200, Boris Brezillon wrote: > > The PWM state, represented by its period, duty_cycle and polarity, > > is currently directly stored in the PWM device. > > Declare a pwm_state structure embedding those field so that we can later > > use this struct to atomically update all the PWM parameters at once. > > > > All pwm_get_xxx() helpers are now implemented as wrappers around > > pwm_get_state(). > > > > Signed-off-by: Boris Brezillon > > --- > > drivers/pwm/core.c | 8 ++++---- > > include/linux/pwm.h | 54 +++++++++++++++++++++++++++++++++++++++++------------ > > 2 files changed, 46 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c > > index 6433059..f3f91e7 100644 > > --- a/drivers/pwm/core.c > > +++ b/drivers/pwm/core.c > > @@ -268,7 +268,7 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip, > > pwm->chip = chip; > > pwm->pwm = chip->base + i; > > pwm->hwpwm = i; > > - pwm->polarity = polarity; > > + pwm->state.polarity = polarity; > > Would this not more correctly be assigned to pwm->args.polarity? After > all this is setting up the "initial" state, much like DT or the lookup > tables would for duty cycle and period. Yes, I wasn't sure about the pwm_add_with_polarity() meaning. To me, all the reference info should be extracted from DT, PWM lookup table or driver specific ->request() implementation, but I can definitely initialize the args.polarity here too. Should I keep the pwm->state.polarity assignment (to set the initial polarity when the driver does not support hardware readout)? -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com