Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21605589ybl; Mon, 6 Jan 2020 07:50:09 -0800 (PST) X-Google-Smtp-Source: APXvYqwoC3wl/BbgMDlkgsBeIZHvXHgpWSBh9FyLfifm6Pp+vAdLy6cE3RfuPT1uD+IMw3tLVyMg X-Received: by 2002:a9d:8cb:: with SMTP id 69mr96905945otf.221.1578325809793; Mon, 06 Jan 2020 07:50:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578325809; cv=none; d=google.com; s=arc-20160816; b=GgIGkSObc5uDcAT3ZzK9IQjcdJWVT5t7dWuvGSmyS4Bi4Lq7w5obhfie+QnmwicG92 wWkSanDiV//Gc9ql65PUp1zUxlU2b4YGNPSSJtRWM0IPO6eLd8rmgelouxMcIn1xYiLF 6Zc878Y/lMBSGiLySDXD/WBOxisNCalq4Ckg5lUCErp5inBsHd265k8g6R8jvOna0Cwp 2PwtkVEltan2gtTiD+SiLWYF4lDKc1WzJY1Fd1aOZoTe2XyqrSM+p+CH/PuU98N7Z8Yl Gv6Vrn18crq8u7qHNpWU2cE22VBEeM03/xQLu6/bQ8z2l63YorBanTMchQMZFgSOsYuG j++Q== 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=MWlwGWWIKmuVRctBZ147W+UbtPOmt00OmzNMxHi8dwA=; b=shMPzTgW+89robEzreJdU5LKXduc+ij+83Rd3W25R4rqXapIvJluVzqmFRPecB5/F4 AvE1QNwpFTvhHD3bc6dwVlKVgVg5zCuM1faEAb5xv183QOC+X2lTwM68VjpNPPcog6/I OQH0pi9xJW/sYtAOe5E7PzrhsmvoTg9uEfOS9NQgWsfgFsTowX0L0o/J35NJdm6JfH0/ uEItF73571agODw6/6wUkXKxYNd5OZtpK73egLq98Sm6wDywdTDbNWAGJ0ERR3P2UfK/ xbUpathFqD6aN0ngSZWxHBxV2oHDvpeMVLMjPh4PXRe10Dcq11BZMI7bCV4jS3TJ1Jyx h7rw== 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 p26si37082533oto.240.2020.01.06.07.49.58; Mon, 06 Jan 2020 07:50:09 -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 S1726916AbgAFPtJ (ORCPT + 99 others); Mon, 6 Jan 2020 10:49:09 -0500 Received: from honk.sigxcpu.org ([24.134.29.49]:41158 "EHLO honk.sigxcpu.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726454AbgAFPtE (ORCPT ); Mon, 6 Jan 2020 10:49:04 -0500 Received: from localhost (localhost [127.0.0.1]) by honk.sigxcpu.org (Postfix) with ESMTP id 5B22AFB03; Mon, 6 Jan 2020 16:49:02 +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 7Hmxyg6x44up; Mon, 6 Jan 2020 16:49:00 +0100 (CET) Received: by bogon.sigxcpu.org (Postfix, from userid 1000) id 4330149D3D; 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 3/6] leds: lm3692x: Split out lm3692x_leds_disable Date: Mon, 6 Jan 2020 16:48:52 +0100 Message-Id: <79793beed2ef175a64c28700fdd234a007ca39a5.1578324703.git.agx@sigxcpu.org> 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 Move the relevant parts out of lm3692x_remove() and call it from there. No functional change. Signed-off-by: Guido Günther Acked-by: Pavel Machek --- drivers/leds/leds-lm3692x.c | 42 +++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c index f7fdfaee5ac5..1254695d7e94 100644 --- a/drivers/leds/leds-lm3692x.c +++ b/drivers/leds/leds-lm3692x.c @@ -289,6 +289,30 @@ static int lm3692x_leds_enable(struct lm3692x_led *led) return ret; } +static int lm3692x_leds_disable(struct lm3692x_led *led) +{ + int ret; + + 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", + ret); + return ret; + } + + if (led->enable_gpio) + gpiod_direction_output(led->enable_gpio, 0); + + if (led->regulator) { + ret = regulator_disable(led->regulator); + if (ret) + dev_err(&led->client->dev, + "Failed to disable regulator: %d\n", ret); + } + + return ret; +} + static int lm3692x_brightness_set(struct led_classdev *led_cdev, enum led_brightness brt_val) { @@ -463,23 +487,9 @@ static int lm3692x_remove(struct i2c_client *client) struct lm3692x_led *led = i2c_get_clientdata(client); int ret; - 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", - ret); + ret = lm3692x_leds_disable(led); + if (ret) return ret; - } - - if (led->enable_gpio) - gpiod_direction_output(led->enable_gpio, 0); - - if (led->regulator) { - ret = regulator_disable(led->regulator); - if (ret) - dev_err(&led->client->dev, - "Failed to disable regulator: %d\n", ret); - } - mutex_destroy(&led->lock); return 0; -- 2.23.0