From patchwork Wed Nov 15 19:52:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 118998 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp3899696edl; Wed, 15 Nov 2017 11:52:50 -0800 (PST) X-Google-Smtp-Source: AGs4zMYWD7fgdGebveDYVJeORHD6As/QSzn4USVNnWeb2rFmx06YQa5mj8iAw6ytJxr02v8LcRR2 X-Received: by 10.98.214.21 with SMTP id r21mr16187128pfg.74.1510775570321; Wed, 15 Nov 2017 11:52:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510775570; cv=none; d=google.com; s=arc-20160816; b=Pq7HnPp+ihgEr2e8PnKBj0kw8GYDGSoCuJJZvJbqLIiDIAcJfOHIJUle403qkDQAXY MEWmDIg/AgmxUEZVyiWGMw9/+Uqk0qeeib56dO0eo+2bIILowew7g1puodEGcDKNxB+o 9COGpB/IEeFwea6Yr3e2sf4oCHlBWmcoMTGVbbQTO+GrfQXaCAOUWABla5uRei4+RWSj 2IcqcpqAxieUKNfHkShzGLWriU5rTkdxMVJWsYQgfuCKwIySy5zWM89mg4QFk1lyQfvk N2CAScoAkvvPBzYihNLR4m0vEOe02AZzne9VjJaI9TB26ZUIIePUFkFbFkR8RA40RoXL qKEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=c4QluAXcGQbz26sdJZUMKC1ccSqR799T5IOE8hGogu8=; b=sqsdz733xRVTaGxN2hxoDJ39Qwu+s3i2ZpDvvjIS4MG9mgdke25K7iqimxQ0zQR3qk jB05i3eo4AwdnrMlbDGY9dZ3u/1dWHRmc/f2rKtIn4jInarmrpCFRM/e83HZOzTisOmE sVphIXtilipNbMuIm6TUcc62b2SVSm2yfz/XcWwegvWaF2iavT9YMGJMffVDe2NJDB/P MB1DLK9IYTaPUu9IG9g2BktmErpW5Svu+sxeRiQluS/M7LNQG8FXdsX9nKo529Q7dT17 vt97/4FZWfQBPZuipd0Njs0AQntCGzFNCcva6ZU+4ZANLDtrHzc4jfL0m/2rAZAdWFWb tqyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=kn188+29; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id az8si17793448plb.717.2017.11.15.11.52.50 for ; Wed, 15 Nov 2017 11:52:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=kn188+29; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758887AbdKOTwt (ORCPT ); Wed, 15 Nov 2017 14:52:49 -0500 Received: from fllnx210.ext.ti.com ([198.47.19.17]:58574 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755666AbdKOTwq (ORCPT ); Wed, 15 Nov 2017 14:52:46 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id vAFJqZ9V023554; Wed, 15 Nov 2017 13:52:35 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1510775555; bh=wJJlWKITVCsvLGrA/HwBTWwBAmLFAomy/KeuAnYJQvw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=kn188+29Sweg1DDhWUrw70RGqRPw+xkJ8X5Ox+Fbm/goHBbxhvWP9kZ0Gz+qGFiYC tR90a0O2V2k84MzoJdIP+x+EmIQQV7lfUlvaugOXF+NUNLqIFuUV4deGtVDZF8/dTm TgaKdWhLcxN0aNRJtGYYOJUbNbf+oQTVSBEX85UM= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id vAFJqZrm023833; Wed, 15 Nov 2017 13:52:35 -0600 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Wed, 15 Nov 2017 13:52:34 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Wed, 15 Nov 2017 13:52:34 -0600 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id vAFJqYHY018400; Wed, 15 Nov 2017 13:52:34 -0600 Received: from localhost (a0272616local-lt.dhcp.ti.com [172.22.167.247]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id vAFJqY300941; Wed, 15 Nov 2017 13:52:34 -0600 (CST) From: Dan Murphy To: , , CC: , , Dan Murphy Subject: [PATCH 2/2] leds: lp8860: Add regulator enable during init Date: Wed, 15 Nov 2017 13:52:13 -0600 Message-ID: <20171115195213.8404-2-dmurphy@ti.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20171115195213.8404-1-dmurphy@ti.com> References: <20171115195213.8404-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-leds-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Add the regulator enable call during initialization. If init fails then disable the regulator. Also during init the gpio gets set low even on a passing case so add if everything passes then return. Signed-off-by: Dan Murphy --- drivers/leds/leds-lp8860.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) -- 2.15.0.124.g7668cbc60 diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c index 91b6c5fbd361..f91a4fe25168 100644 --- a/drivers/leds/leds-lp8860.c +++ b/drivers/leds/leds-lp8860.c @@ -247,6 +247,15 @@ static int lp8860_init(struct lp8860_led *led) unsigned int read_buf; int ret, i, reg_count; + if (led->regulator) { + ret = regulator_enable(led->regulator); + if (ret) { + dev_err(&led->client->dev, + "Failed to enable regulator\n"); + return ret; + } + } + if (led->enable_gpio) gpiod_direction_output(led->enable_gpio, 1); @@ -282,12 +291,25 @@ static int lp8860_init(struct lp8860_led *led) ret = regmap_write(led->regmap, LP8860_EEPROM_CNTRL, LP8860_PROGRAM_EEPROM); - if (ret) + if (ret) { dev_err(&led->client->dev, "Failed programming EEPROM\n"); + goto out; + } + + return ret; + out: if (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\n"); + } + return ret; }