Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21606632ybl; Mon, 6 Jan 2020 07:51:31 -0800 (PST) X-Google-Smtp-Source: APXvYqzYpBHSbHJk4cRfr2A6qf/bR/I5lGCPgrbw3tZ8RBXCw3OoqErKcHG6vVGP8FArIUXBTwmQ X-Received: by 2002:a9d:ee2:: with SMTP id 89mr53332542otj.270.1578325891845; Mon, 06 Jan 2020 07:51:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578325891; cv=none; d=google.com; s=arc-20160816; b=MLEeQbBkc6jSZfTJdtcGRvzc6sHon10bXN1B65TQJibNTVE/dez3icITgxfH9gxDEs pv11bMDI21gWYXLPqHByzBmi7RqUzIJN2XK9JiKAaBmWN6YqLXSgemsI4kp1lqAglVbJ +FcZtW67KZHLegE/NPvYbs6HZ8KRVDoIyXMWqA+oE18ems6u05nv6L/70EtyunWVNbj4 H+BtGEwfjl8sPIr87OwUE5tUXgmGsXTq6UdniUG/zOYER6ccJdVjfj24JaaTndXrZrZK J646tlT4R4Ih6EhCCPgzfWdZsZoFgrp5TBK73tx/85KQ+A3vzOHRDOZ/6SCedmhC5RZf Qrrw== 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=dxJXy3PM6CmtSQQhtb97lnLQFW+ALaXrNTOcmd2afYU=; b=sp9lKVyLR6CPqZ6N5Weic8tzqLfe+tdWnXnuOuI9u7VttkoG4+10q3ixTiIbc64MSf d1c7lUUoQpMi8ykdM3F56RPQiXOeUpFyWCcBuJaYXIPzBt1BT3x44vVm9l9z0MTcYJUN IbLYnvhvq3J0XgkshvP6Awo2bWQfKNdN4LakEMoLYY3cJJqy7WnD1EyPjomRhXiiSrfV 1YbyGpk/njt3UIuOHD3AQ/5F0UcNZfL90i7Gajk/K42MPDMNWf3kfNX0Ki3I1/GienEE 1HJ3Tj+lkbwna8AaM7u1hO4ciBG/Q2DJ+rX6wi4XYTPpardy//2whN7mUDy6EpsXRAcQ 7nRQ== 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 y8si32337933oih.141.2020.01.06.07.51.19; Mon, 06 Jan 2020 07:51:31 -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 S1727006AbgAFPtY (ORCPT + 99 others); Mon, 6 Jan 2020 10:49:24 -0500 Received: from honk.sigxcpu.org ([24.134.29.49]:41180 "EHLO honk.sigxcpu.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726710AbgAFPtH (ORCPT ); Mon, 6 Jan 2020 10:49:07 -0500 Received: from localhost (localhost [127.0.0.1]) by honk.sigxcpu.org (Postfix) with ESMTP id 3DF89FB06; Mon, 6 Jan 2020 16:49:05 +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 wghSo_sjs6-k; Mon, 6 Jan 2020 16:49:00 +0100 (CET) Received: by bogon.sigxcpu.org (Postfix, from userid 1000) id 4F5BA49D43; Mon, 6 Jan 2020 16:48:56 +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 v4 4/6] leds: lm3692x: Disable chip on brightness 0 Date: Mon, 6 Jan 2020 16:48:53 +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 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c index 1254695d7e94..28a51aeb28de 100644 --- a/drivers/leds/leds-lm3692x.c +++ b/drivers/leds/leds-lm3692x.c @@ -116,7 +116,8 @@ struct lm3692x_led { int led_enable; int model_id; - u8 boost_ctrl; + 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) { @@ -272,6 +276,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"); @@ -293,6 +298,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", @@ -310,6 +318,7 @@ static int lm3692x_leds_disable(struct lm3692x_led *led) "Failed to disable regulator: %d\n", ret); } + led->enabled = false; return ret; } @@ -323,6 +332,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