From patchwork Mon Nov 25 20:43:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 294084 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A50782C00A4 for ; Tue, 26 Nov 2013 07:47:12 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vl32E-0004Xk-02; Mon, 25 Nov 2013 20:45:34 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vl31n-0005qE-K4; Mon, 25 Nov 2013 20:45:07 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vl31T-0005n2-Bl for linux-arm-kernel@lists.infradead.org; Mon, 25 Nov 2013 20:44:49 +0000 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Vl30x-0001VP-V4; Mon, 25 Nov 2013 21:44:15 +0100 Received: from ukl by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1Vl30x-0005Dw-Lp; Mon, 25 Nov 2013 21:44:15 +0100 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Bryan Wu , Richard Purdie , Thierry Reding Subject: [PATCH 2/3] leds/pwm: Don't disable pwm when setting brightness to 0 Date: Mon, 25 Nov 2013 21:43:44 +0100 Message-Id: <1385412225-29740-3-git-send-email-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1385412225-29740-1-git-send-email-u.kleine-koenig@pengutronix.de> References: <1385412225-29740-1-git-send-email-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131125_154447_685272_4016A4C5 X-CRM114-Status: GOOD ( 14.52 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: kernel@pengutronix.de, Matt Sealey , Shawn Guo , linux-arm-kernel@lists.infradead.org, linux-leds@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org This fixes disabling the LED on i.MX28. The PWM hardware delays using the newly set pwm-config until the beginning of a new period. It's very likely that pwm_disable is called before the current period ends. In case the LED was on brightness=max before the LED stays on because in the disabled PWM block the period never ends. Also only call pwm_enable only once in the probe call back and the matching pwm_disable in .remove(). Moreover the pwm is explicitly initialized to off. Signed-off-by: Uwe Kleine-König --- drivers/leds/leds-pwm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index 2848171..cdc3e4d 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c @@ -45,11 +45,6 @@ static void __led_pwm_set(struct led_pwm_data *led_dat) int new_duty = led_dat->duty; pwm_config(led_dat->pwm, new_duty, led_dat->period); - - if (new_duty == 0) - pwm_disable(led_dat->pwm); - else - pwm_enable(led_dat->pwm); } static void led_pwm_work(struct work_struct *work) @@ -180,6 +175,10 @@ static int led_pwm_probe(struct platform_device *pdev) led_dat->cdev.max_brightness = cur_led->max_brightness; led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; + led_dat->duty = 0; + __led_pwm_set(led_dat); + pwm_enable(led_dat->pwm); + led_dat->can_sleep = pwm_can_sleep(led_dat->pwm); if (led_dat->can_sleep) INIT_WORK(&led_dat->work, led_pwm_work); @@ -215,6 +214,7 @@ static int led_pwm_remove(struct platform_device *pdev) led_classdev_unregister(&priv->leds[i].cdev); if (priv->leds[i].can_sleep) cancel_work_sync(&priv->leds[i].work); + pwm_disable(priv->leds[i].pwm); } return 0;