Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754249AbcC3WB4 (ORCPT ); Wed, 30 Mar 2016 18:01:56 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:35759 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751212AbcC3WBx (ORCPT ); Wed, 30 Mar 2016 18:01:53 -0400 Date: Wed, 30 Mar 2016 15:01:49 -0700 From: Stephen Boyd To: Boris Brezillon Cc: Thierry Reding , linux-pwm@vger.kernel.org, Mike Turquette , 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 34/46] clk: pwm: switch to the atomic API Message-ID: <20160330220149.GU18567@codeaurora.org> References: <1459368249-13241-1-git-send-email-boris.brezillon@free-electrons.com> <1459368249-13241-35-git-send-email-boris.brezillon@free-electrons.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1459368249-13241-35-git-send-email-boris.brezillon@free-electrons.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1020 Lines: 29 On 03/30, Boris Brezillon wrote: > diff --git a/drivers/clk/clk-pwm.c b/drivers/clk/clk-pwm.c > index ebcd738..49ec5b1 100644 > --- a/drivers/clk/clk-pwm.c > +++ b/drivers/clk/clk-pwm.c > @@ -28,15 +28,29 @@ static inline struct clk_pwm *to_clk_pwm(struct clk_hw *hw) > static int clk_pwm_prepare(struct clk_hw *hw) > { > struct clk_pwm *clk_pwm = to_clk_pwm(hw); > + struct pwm_state pstate; > > - return pwm_enable(clk_pwm->pwm); > + pwm_get_state(clk_pwm->pwm, &pstate); > + if (pstate.enabled) > + return 0; > + > + pstate.enabled = true; > + > + return pwm_apply_state(clk_pwm->pwm, &pstate); This doesn't seem atomic anymore if we're checking the state and then not calling apply_state if it's already enabled. But I assume this doesn't matter because we "own" the pwm here? Otherwise I would think this would be unconditional apply state and duplicates would be ignored in the pwm framework. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project