Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp19503027ybl; Sat, 4 Jan 2020 02:55:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzAiqLYP+mbXYYuiqY1ONsuzfmDayIQ9eA+l3Iv9WxE2i50Q3as6Vk0IwNE+VsY4PY0Z/1B X-Received: by 2002:a9d:7d85:: with SMTP id j5mr87221100otn.86.1578135353377; Sat, 04 Jan 2020 02:55:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578135353; cv=none; d=google.com; s=arc-20160816; b=J9zDXNepAaERE1j8JPS6hpCybph0kZT3O3Ie/sSeExCnpIeYhYjcypcHZlufzfxhnD OIEllqOFQn7SumPQSCcr8bZzLRtwcdk3t+5HNvjPYL1KChnvVqhPe5iQ8rBCc1pQ4Cf6 Vx6DZHlCBdyw3FW7bDKWnO7SMMCUF0RhDqRrjtL+ZmHCNfXfCoZMOE4Jjy9UJ00DW/9l tO2WdvlyoOuZ2SFI4zqN2tbowCOyZBsHXkHz3AL/egpGoB6hSkcjXNTSKgbnffd6VWJu XeKyMWBVCvdkNjx5+fQKVITxkm6gWG9hMlsnDD+ckanaVct37WZQ+iSPuRodrzfcrKnO 023Q== 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=RWkDp3bXYqC8UGXKmWvH8HyIiPNK99b0giUH+XaYpKE=; b=tZ+cfSKKRFNOmT8APw5LBoIrfTbFYtpbvhzF9ps7lrGiHED4vbLixVTEVY5PeMveit rjhbpWB8C48BedfwQW2q7dsUdhVe+a0szOxs/aWLtdxA4HfzrN9M8rqMYYdEpkosWMNN aICmZhzwXfO212iSwLhFYtESoe4vZCJhSOUY5dx31omwzkFlVuuT8MN+6PvI5XIQeZ7a G60LWbrdDla/QlIVwTzhHe0Zf68AHJijFjRIjpQivN9oVqTiGMbyc4v6gAa4HOd4RdK+ oMgqSm3q7Fjs9cxWIP1F50NxSSikWJWy8KjzTNWEGKxrPKT8qvrRvCy712TJJAl+c/gK FhuQ== 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 c26si29932428otf.288.2020.01.04.02.55.41; Sat, 04 Jan 2020 02:55:53 -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 S1726640AbgADKyw (ORCPT + 99 others); Sat, 4 Jan 2020 05:54:52 -0500 Received: from honk.sigxcpu.org ([24.134.29.49]:40274 "EHLO honk.sigxcpu.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbgADKyn (ORCPT ); Sat, 4 Jan 2020 05:54:43 -0500 Received: from localhost (localhost [127.0.0.1]) by honk.sigxcpu.org (Postfix) with ESMTP id BB9F3FB04; Sat, 4 Jan 2020 11:54:41 +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 u0Pl_JmYpztr; Sat, 4 Jan 2020 11:54:40 +0100 (CET) Received: by bogon.sigxcpu.org (Postfix, from userid 1000) id 62D4349AAA; Sat, 4 Jan 2020 11:54:26 +0100 (CET) From: =?UTF-8?q?Guido=20G=C3=BCnther?= To: Jacek Anaszewski , Pavel Machek , Dan Murphy , Rob Herring , Mark Rutland , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 9/9] leds: lm3692x: Disable chip on brightness 0 Date: Sat, 4 Jan 2020 11:54:25 +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 075dc4b6b3b6..933b786cfaec 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