From patchwork Mon Jun 6 10:44:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Lothar_Wa=C3=9Fmann?= X-Patchwork-Id: 9157809 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F38A960759 for ; Mon, 6 Jun 2016 10:45:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E45E926907 for ; Mon, 6 Jun 2016 10:45:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D906A26E82; Mon, 6 Jun 2016 10:45:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9660226907 for ; Mon, 6 Jun 2016 10:45:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751072AbcFFKpZ (ORCPT ); Mon, 6 Jun 2016 06:45:25 -0400 Received: from mail.karo-electronics.de ([81.173.242.67]:49267 "EHLO mail.karo-electronics.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751003AbcFFKpX (ORCPT ); Mon, 6 Jun 2016 06:45:23 -0400 From: =?UTF-8?q?Lothar=20Wa=C3=9Fmann?= To: Jean-Christophe Plagniol-Villard , Jingoo Han , Lee Jones , Thierry Reding , Tomi Valkeinen , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org Cc: =?UTF-8?q?Lothar=20Wa=C3=9Fmann?= Subject: [PATCH] backlight: pwm_bl: disable PWM when 'duty_cycle' is zero Date: Mon, 6 Jun 2016 12:44:56 +0200 Message-Id: <1465209896-10319-1-git-send-email-LW@KARO-electronics.de> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 'brightness' is usually an index into a table of duty_cycle values, where the value at index 0 may well be non-zero (tegra30-apalis-eval.dts and tegra30-colibri-eval-v3.dts are real-life examples). Thus brightness == 0 does not necessarily mean that the PWM output will be inactive. Check for 'duty_cycle == 0' rather than 'brightness == 0' to decide whether to disable the PWM. Signed-off-by: Lothar Waßmann --- drivers/video/backlight/pwm_bl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index b2b366b..80b2b52 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -103,8 +103,8 @@ static int pwm_backlight_update_status(struct backlight_device *bl) if (pb->notify) brightness = pb->notify(pb->dev, brightness); - if (brightness > 0) { - duty_cycle = compute_duty_cycle(pb, brightness); + duty_cycle = compute_duty_cycle(pb, brightness); + if (duty_cycle > 0) { pwm_config(pb->pwm, duty_cycle, pb->period); pwm_backlight_power_on(pb, brightness); } else