Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8642812ybl; Wed, 25 Dec 2019 03:17:41 -0800 (PST) X-Google-Smtp-Source: APXvYqy/l5bLsxfQXaX0sHtL4l4FKsUkHt3TwX/RKJUmK6nqcOASBm6ABPJsJX9VHHxBskvwxdJO X-Received: by 2002:a05:6830:15a:: with SMTP id j26mr42213811otp.137.1577272661277; Wed, 25 Dec 2019 03:17:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577272661; cv=none; d=google.com; s=arc-20160816; b=CcK9+qB1flJ99Sl7C7Y/pgCi1SM/o9M9gjeV4so2WN6fQsK2IaNqQ9o7fvX2iN6dkf X+yY2m/4n+wraOvkG4DAC/bzQfJvl4VESKZs6s82nM93U2R+ZDHRfYyE7sYJsJz7enZY CdKBe6ud0RtSgu+Zrig+Y8WRq9vyO46cMJVWthVlzRjOXgIQplIuPYtUmvurLSSjrDeI aAlexuMIDw0w5i1h3C/4hWvnkbcymy2R3mhVetPik31PEnaAgT7G+kRi9gZZOQD/AF+g QaGLKJQIpInsST3XFVXu2D592OFL6dbg5ejJ2c9tIsO1FJ3t6X+TfMcmR8J40VrIocMj HZSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=vCTORukJJ9LUeo4ib22Ijw4QBFWLz45Asts/hqm77hc=; b=hzHSY3Fg2H0kgTHZg0scZ6luLlWkkcJCQrkxOanyEaxQcIXAcn//ZeyZ9/yRcLhqKI 2PtQbw6AU6j62WNSp6GNniTwm4wUd5ho9H3OTHHLlGEtx2xWmOkR5/JS7nC645Gq7RiS GPfVFxNhf2OahohilTY2/wEc+PvYTx9/JCu1j8GjzpiQJpwv1xSPAK5rQAt8q1J2zBMo dCCNciq1WdEz9OA4pHs8cRrV2oEETGAoa5nQfZETjwhua3AFAyVwYSILM5KJGa0Gzz1y 7uJySpos0Nn0l3VFQNc60ZR6Nyfd9ghD09IIwJdfadF3jhfaeRh6oF0k91ZdCO8rwA3+ /FEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b1si9568643otl.302.2019.12.25.03.17.28; Wed, 25 Dec 2019 03:17:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726866AbfLYLQq (ORCPT + 99 others); Wed, 25 Dec 2019 06:16:46 -0500 Received: from honk.sigxcpu.org ([24.134.29.49]:36566 "EHLO honk.sigxcpu.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726414AbfLYLQq (ORCPT ); Wed, 25 Dec 2019 06:16:46 -0500 Received: from localhost (localhost [127.0.0.1]) by honk.sigxcpu.org (Postfix) with ESMTP id A7A56FB04; Wed, 25 Dec 2019 12:16:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at honk.sigxcpu.org Received: from honk.sigxcpu.org ([127.0.0.1]) by localhost (honk.sigxcpu.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Xnsbr-uoR8Bh; Wed, 25 Dec 2019 12:16:42 +0100 (CET) Received: by bogon.sigxcpu.org (Postfix, from userid 1000) id BFE7440BFC; Wed, 25 Dec 2019 12:16:39 +0100 (CET) From: =?UTF-8?q?Guido=20G=C3=BCnther?= To: Jacek Anaszewski , Pavel Machek , Dan Murphy , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] leds: lm3692x: Disable chip on brightness 0 Date: Wed, 25 Dec 2019 12:16:39 +0100 Message-Id: X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Otherwise there's a noticeable glow even with brightness 0. Also turning off the regulator can save additional power. Signed-off-by: Guido Günther --- drivers/leds/leds-lm3692x.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c index d1bd9ae4e7ab..183614744b92 100644 --- a/drivers/leds/leds-lm3692x.c +++ b/drivers/leds/leds-lm3692x.c @@ -117,6 +117,7 @@ struct lm3692x_led { int model_id; u8 boost_ctrl, brightness_ctrl; + bool enabled; }; static const struct reg_default lm3692x_reg_defs[] = { @@ -170,6 +171,9 @@ static int lm3692x_leds_enable(struct lm3692x_led *led) int enable_state; int ret, reg_ret; + if (led->enabled) + return 0; + if (led->regulator) { ret = regulator_enable(led->regulator); if (ret) { @@ -271,6 +275,7 @@ static int lm3692x_leds_enable(struct lm3692x_led *led) ret = regmap_update_bits(led->regmap, LM3692X_EN, LM3692X_ENABLE_MASK, enable_state | LM3692X_DEVICE_EN); + led->enabled = true; return ret; out: dev_err(&led->client->dev, "Fail writing initialization values\n"); @@ -292,6 +297,9 @@ static int lm3692x_leds_disable(struct lm3692x_led *led) { int ret; + if (!led->enabled) + return 0; + ret = regmap_update_bits(led->regmap, LM3692X_EN, LM3692X_DEVICE_EN, 0); if (ret) { dev_err(&led->client->dev, "Failed to disable regulator: %d\n", @@ -309,6 +317,7 @@ static int lm3692x_leds_disable(struct lm3692x_led *led) "Failed to disable regulator: %d\n", ret); } + led->enabled = false; return ret; } @@ -322,6 +331,13 @@ static int lm3692x_brightness_set(struct led_classdev *led_cdev, mutex_lock(&led->lock); + if (brt_val == 0) { + ret = lm3692x_leds_disable(led); + goto out; + } else { + lm3692x_leds_enable(led); + } + ret = lm3692x_fault_check(led); if (ret) { dev_err(&led->client->dev, "Cannot read/clear faults: %d\n", -- 2.23.0