From patchwork Thu Aug 23 14:19:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Th=C3=A9baudeau?= X-Patchwork-Id: 1367581 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id BD8C1DF2AB for ; Thu, 23 Aug 2012 14:17:39 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T4YB7-0005DA-ME; Thu, 23 Aug 2012 14:14:33 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T4YB4-0005CS-5L for linux-arm-kernel@merlin.infradead.org; Thu, 23 Aug 2012 14:14:30 +0000 Received: from zose-mta-15.w4a.fr ([176.31.217.10] helo=zose-mta15.web4all.fr) by casper.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T4YB0-0001mm-Ov for linux-arm-kernel@lists.infradead.org; Thu, 23 Aug 2012 14:14:29 +0000 Received: from localhost (localhost [127.0.0.1]) by zose-mta15.web4all.fr (Postfix) with ESMTP id 085D22D2D4; Thu, 23 Aug 2012 16:17:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at zose1.web4all.fr Received: from zose-mta15.web4all.fr ([127.0.0.1]) by localhost (zose-mta15.web4all.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p7QgOhVIikK1; Thu, 23 Aug 2012 16:17:04 +0200 (CEST) Received: from zose-store12.web4all.fr (zose-store-12.w4a.fr [178.33.204.48]) by zose-mta15.web4all.fr (Postfix) with ESMTP id 94EFD2C373; Thu, 23 Aug 2012 16:17:04 +0200 (CEST) Date: Thu, 23 Aug 2012 16:19:47 +0200 (CEST) From: =?utf-8?Q?Beno=C3=AEt_Th=C3=A9baudeau?= To: Thierry Reding , linux-kernel@vger.kernel.org, Sascha Hauer , linux-arm-kernel@lists.infradead.org, Dmitry Torokhov , linux-input@vger.kernel.org, Bryan Wu , Richard Purdie , linux-leds@vger.kernel.org, Florian Tobias Schandinat , linux-fbdev@vger.kernel.org Message-ID: <217877237.2758643.1345731587941.JavaMail.root@advansee.com> In-Reply-To: <320569847.2756382.1345729013971.JavaMail.root@advansee.com> Subject: [PATCH] pwm: Call pwm_enable() before pwm_config() MIME-Version: 1.0 X-Originating-IP: [88.188.188.98] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - FF3.0 (Win)/7.2.0_GA_2669) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20120823_151426_905405_4F6EB27F X-CRM114-Status: UNSURE ( 8.30 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on casper.infradead.org summary: Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: =?utf-8?Q?Beno=C3=AEt_Th=C3=A9baudeau?= X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Some PWM drivers enable the clock of the PWM peripheral in pwm_enable(). Hence, for these drivers, a call to pwm_config() does not have any effect before pwm_enable() has been called. This patch fixes the PWM users to make sure that they call pwm_enable() before pwm_config(). This fixes the first setting of brightness through sysfs that had no effect with leds-pwm and the i.MX PWM driver. Cc: Thierry Reding Cc: Cc: Sascha Hauer Cc: Cc: Dmitry Torokhov Cc: Cc: Bryan Wu Cc: Richard Purdie Cc: Cc: Florian Tobias Schandinat Cc: Cc: Benoît Thébaudeau Signed-off-by: Benoît Thébaudeau --- .../drivers/input/misc/pwm-beeper.c | 6 +++--- .../drivers/leds/leds-pwm.c | 2 +- .../drivers/video/backlight/pwm_bl.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git linux-next-c94456b.orig/drivers/input/misc/pwm-beeper.c linux-next-c94456b/drivers/input/misc/pwm-beeper.c index fc84c8a..97d322b 100644 --- linux-next-c94456b.orig/drivers/input/misc/pwm-beeper.c +++ linux-next-c94456b/drivers/input/misc/pwm-beeper.c @@ -53,10 +53,10 @@ static int pwm_beeper_event(struct input_dev *input, pwm_disable(beeper->pwm); } else { period = HZ_TO_NANOSECONDS(value); - ret = pwm_config(beeper->pwm, period / 2, period); + ret = pwm_enable(beeper->pwm); if (ret) return ret; - ret = pwm_enable(beeper->pwm); + ret = pwm_config(beeper->pwm, period / 2, period); if (ret) return ret; beeper->period = period; @@ -156,8 +156,8 @@ static int pwm_beeper_resume(struct device *dev) struct pwm_beeper *beeper = dev_get_drvdata(dev); if (beeper->period) { - pwm_config(beeper->pwm, beeper->period / 2, beeper->period); pwm_enable(beeper->pwm); + pwm_config(beeper->pwm, beeper->period / 2, beeper->period); } return 0; diff --git linux-next-c94456b.orig/drivers/leds/leds-pwm.c linux-next-c94456b/drivers/leds/leds-pwm.c index f2e44c7..c2e0c22 100644 --- linux-next-c94456b.orig/drivers/leds/leds-pwm.c +++ linux-next-c94456b/drivers/leds/leds-pwm.c @@ -42,8 +42,8 @@ static void led_pwm_set(struct led_classdev *led_cdev, pwm_config(led_dat->pwm, 0, period); pwm_disable(led_dat->pwm); } else { - pwm_config(led_dat->pwm, brightness * period / max, period); pwm_enable(led_dat->pwm); + pwm_config(led_dat->pwm, brightness * period / max, period); } } diff --git linux-next-c94456b.orig/drivers/video/backlight/pwm_bl.c linux-next-c94456b/drivers/video/backlight/pwm_bl.c index 995f016..a4bb95c 100644 --- linux-next-c94456b.orig/drivers/video/backlight/pwm_bl.c +++ linux-next-c94456b/drivers/video/backlight/pwm_bl.c @@ -65,8 +65,8 @@ static int pwm_backlight_update_status(struct backlight_device *bl) duty_cycle = pb->lth_brightness + (duty_cycle * (pb->period - pb->lth_brightness) / max); - pwm_config(pb->pwm, duty_cycle, pb->period); pwm_enable(pb->pwm); + pwm_config(pb->pwm, duty_cycle, pb->period); } if (pb->notify_after)