From patchwork Tue Aug 13 18:11:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 171205 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1236865ily; Tue, 13 Aug 2019 11:12:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDrIhHQk5VyiLugSTA2b68K6cRwRkvydllV2JX1KGoOlzByqxR6hi44JCnRp9+roWFRjtf X-Received: by 2002:a63:2887:: with SMTP id o129mr28943669pgo.179.1565719931066; Tue, 13 Aug 2019 11:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565719931; cv=none; d=google.com; s=arc-20160816; b=KHg6mMFMSjFKuI+pfxefnV0925lOvAlc0pyHqTUVMhK5PVhKq2EAm107irhX7mS6Io WXBZTafL5Mc+S9ZK6R1ippE5ntA7lllUZo7YuwLaT5Hk16sTaFY2GFlxOb45bDauT4Ss Riaqq4Ri1usqyn8og/XurxwgOpFyi0zy3m3uB9ISuLwUFROxLu1bg7Ct5Ly/1aPNTUmg tSRiN8i7WUdaAA/M6pdY8lPIdO0vgCVmJ4QdC6ESBOJrpeJxmJCsluvls8Z7A4zaN87k xtpFyOUDfoWxgFnBGiwZeBXTb1Q8GfrH4MP0DOyOtdNMCljh0Yap9SiMq/4tCWtkRSqM g3BA== 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:cc:to:from :dkim-signature; bh=I/IFBZHJxBn9bBq7cBF0dvoXV8U66cz6/84fF3yjhzY=; b=plyNnnuCZG9NigSBWkF6AJOOUrsyQpCM41GWagdf8OyC51u7weLLMpWaivOq+TT526 fp7gtWvoLBE5mUE3Mvp65IwyzCnVL2bJWGrpuWiJOeSpEJFjjhmSAYlMaZ28y/J3VSVZ IG8dB4zIvV0T/tMOwsqokesLToIb1O9YFMkl/gfPVV0Nceb0dwUNlcInSZRtIFP0qKZ6 HMXMoha3Yx8ZLeHmxZ/0OxqCQIj9Zakhy8DjTFJ04oFMAynU+AhlHLavFIXRDsWjWI8P uIQPiLdePidiM68QYjDTg6bxiD7kzjNhYGDWG6q2XQRHUzdQcDnAqp8V/uzYwS1pTOkb QtnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CSKoW6X7; 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 p4si64715998pgh.350.2019.08.13.11.12.10; Tue, 13 Aug 2019 11:12:11 -0700 (PDT) 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=CSKoW6X7; 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 S1728345AbfHMSMK (ORCPT + 1 other); Tue, 13 Aug 2019 14:12:10 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:33206 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727517AbfHMSMK (ORCPT ); Tue, 13 Aug 2019 14:12:10 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x7DIBx0o013157; Tue, 13 Aug 2019 13:11:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1565719919; bh=I/IFBZHJxBn9bBq7cBF0dvoXV8U66cz6/84fF3yjhzY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=CSKoW6X7HPWwS89l7MXgLiHGIQgJqolBzYS4OFxTZ3Nhr0D8h708kMusV4DWZUw6/ IkHYDhudbXN9LpXpnF4Z9PXV8REZxyO0wCbNIc1SEOL99XTScSGeZykccXqz4i9f8/ GcFP4Z4zQw2yNs/HA94qu9aTFxq3c2CG+fTm7cmk= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x7DIBx79004380 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 13 Aug 2019 13:11:59 -0500 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 13 Aug 2019 13:11:59 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 13 Aug 2019 13:11:59 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x7DIBxgn013188; Tue, 13 Aug 2019 13:11:59 -0500 From: Dan Murphy To: , , , , , , CC: , , Dan Murphy Subject: [PATCH v2 2/4] leds: lm3532: Fixes for the driver for stability Date: Tue, 13 Aug 2019 13:11:52 -0500 Message-ID: <20190813181154.6614-2-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190813181154.6614-1-dmurphy@ti.com> References: <20190813181154.6614-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 Fixed misspelled words, added error check during probe on the init of the registers, and fixed ALS/I2C control mode. Fixes: e37a7f8d77e1 ("leds: lm3532: Introduce the lm3532 LED driver") Reported-by: Pavel Machek Signed-off-by: Dan Murphy --- v2 - New patch due to separating out random fixes and brightness control fix - https://lore.kernel.org/patchwork/patch/1109502/ drivers/leds/leds-lm3532.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) -- 2.22.0.214.g8dca754b1e diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c index b28b7f63198b..ef4c74cbcdc0 100644 --- a/drivers/leds/leds-lm3532.c +++ b/drivers/leds/leds-lm3532.c @@ -43,7 +43,7 @@ #define LM3532_REG_ZONE_TRGT_C 0x7a #define LM3532_REG_MAX 0x7e -/* Contorl Enable */ +/* Control Enable */ #define LM3532_CTRL_A_ENABLE BIT(0) #define LM3532_CTRL_B_ENABLE BIT(1) #define LM3532_CTRL_C_ENABLE BIT(2) @@ -307,7 +307,7 @@ static int lm3532_led_disable(struct lm3532_led *led_data) int ret; ret = regmap_update_bits(led_data->priv->regmap, LM3532_REG_ENABLE, - ctrl_en_val, ~ctrl_en_val); + ctrl_en_val, 0); if (ret) { dev_err(led_data->priv->dev, "Failed to set ctrl:%d\n", ret); return ret; @@ -326,7 +326,7 @@ static int lm3532_brightness_set(struct led_classdev *led_cdev, mutex_lock(&led->priv->lock); - if (led->mode == LM3532_BL_MODE_ALS) { + if (led->mode == LM3532_ALS_CTRL) { if (brt_val > LED_OFF) ret = lm3532_led_enable(led); else @@ -561,11 +561,14 @@ static int lm3532_parse_node(struct lm3532_data *priv) } if (led->mode == LM3532_BL_MODE_ALS) { + led->mode = LM3532_ALS_CTRL; ret = lm3532_parse_als(priv); if (ret) dev_err(&priv->client->dev, "Failed to parse als\n"); else lm3532_als_configure(priv, led); + } else { + led->mode = LM3532_I2C_CTRL; } led->num_leds = fwnode_property_count_u32(child, "led-sources"); @@ -606,7 +609,13 @@ static int lm3532_parse_node(struct lm3532_data *priv) goto child_out; } - lm3532_init_registers(led); + ret = lm3532_init_registers(led); + if (ret) { + dev_err(&priv->client->dev, "register init err: %d\n", + ret); + fwnode_handle_put(child); + goto child_out; + } i++; }