From patchwork Mon Dec 4 21:20:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 120594 Delivered-To: patch@linaro.org Received: by 10.80.152.193 with SMTP id j59csp1379720edb; Mon, 4 Dec 2017 13:20:58 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ8G4KcuMJoJECElHADyoRP6OFWePf7ePGPtfrr3LK40+cbTbhzhtuTslU/VbzbZwdGvB3D X-Received: by 10.84.164.104 with SMTP id m37mr15720361plg.98.1512422457870; Mon, 04 Dec 2017 13:20:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512422457; cv=none; d=google.com; s=arc-20160816; b=N5RPuJXJb/qDPrlY3xesw/BpabPZJ9z0juS+kjJE49GRF/w6YAT5kFeaG88Np9Wwvj /5ftr/6OETZ5QY1YimAZyS1ffhCzZQ6KoTstfVzRtqcELRsaLFIt00RZ+8EI1A9WbmBs U5/1WV62MZ9z94vgoxYVe6Hr+AWEm+ypqGprzYuNS/dIW3SESL9CdtFHepTIT5/jcX0U tT7iXYLX2Xqc2agC9MBHKiS/rk/bmfDgG2WMMjJvabXiaGMDvjYZdf1NBb9ii2trYv0B /ZedJLhfWbiL3n4riFi8JiChzyHPCRSezlh0F4IuaqNG1wZrCR9aEtgsjSVgSVq3WZEa 9Bcg== 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=FhDphjRxxI2x7eHfpIR7qBeQ3czsw+wjt+cLGEhwYyc=; b=eA4BbC4reQCrX2OIaSx2V8HOtxccQL0UbFguSKr+XJlx+HHxG9OVlMmpiWQaMCuE04 4Is1bvjKCahRMZcwc21lJLyyPzbfzVC9vnpET6q8/PF1C/WQVuQJ0b7th3hv1RCG+Ly/ Q4qMi6aWd8Ru0xKD3cD4qJoLwgQgdaqsSr+zKrJm70povm7zZbN2z/axHd1jCKoyibms Fvzx2puBW/WP9ywAqeBG5OqA9IVXs6Xrpes2JHqhXYPCnBJNUVw6vBKtZpxt41Vu72Jx VMJuAp+yi0wCkqw1p6dypGuBalqywEUcYlX5DbahzPgXRN7PI3HR63kKD1C5aXxegvI2 vIIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Olepw3+L; 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; 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 z9si8441558pgs.442.2017.12.04.13.20.57; Mon, 04 Dec 2017 13:20:57 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Olepw3+L; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752707AbdLDVUz (ORCPT + 28 others); Mon, 4 Dec 2017 16:20:55 -0500 Received: from fllnx210.ext.ti.com ([198.47.19.17]:41302 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752552AbdLDVUr (ORCPT ); Mon, 4 Dec 2017 16:20:47 -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 vB4LKTGP016043; Mon, 4 Dec 2017 15:20:29 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1512422429; bh=MMZdk8udmIM1orgYAmPto7fFcqRKxuWqV9pv7zUF7xc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Olepw3+LYOZNu5+slmKj+qVuNcVRUr4DqXiePDZ8nPF79N1xCym8r2ZIu8cXOPiLx TirlEgcGFOIlHdSDbbumDP5WzWLJhfv5DCbVOIbGqWV5zXh41LXr8xKJtE0t5lmG12 zIZvjFMe8UWsCosO5kh6MKjjnpDzduNqgOg34OxE= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id vB4LKTv6004466; Mon, 4 Dec 2017 15:20:29 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Mon, 4 Dec 2017 15:20:29 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Mon, 4 Dec 2017 15:20:29 -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 vB4LKTVe027153; Mon, 4 Dec 2017 15:20:29 -0600 Received: from localhost (a0272616local-lt.dhcp.ti.com [172.22.83.187]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id vB4LKS323335; Mon, 4 Dec 2017 15:20:28 -0600 (CST) From: Dan Murphy To: , , , , CC: , , Dan Murphy Subject: [PATCH 2/5] leds: lp8860: Update the dt parsing for LED labeling Date: Mon, 4 Dec 2017 15:20:23 -0600 Message-ID: <20171204212026.14214-3-dmurphy@ti.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20171204212026.14214-1-dmurphy@ti.com> References: <20171204212026.14214-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Update the DT parsing for the label node so that the label is retrieved from the device child as opposed to being part of the parent. This will align this driver with the LED binding documentation Documentation/devicetree/bindings/leds/common.txt Signed-off-by: Dan Murphy --- drivers/leds/leds-lp8860.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) -- 2.15.0.124.g7668cbc60 diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c index 3e70775a2d54..13d6210cba85 100644 --- a/drivers/leds/leds-lp8860.c +++ b/drivers/leds/leds-lp8860.c @@ -22,6 +22,7 @@ #include #include #include +#include #define LP8860_DISP_CL1_BRT_MSB 0x00 #define LP8860_DISP_CL1_BRT_LSB 0x01 @@ -86,8 +87,6 @@ #define LP8860_CLEAR_FAULTS 0x01 -#define LP8860_DISP_LED_NAME "display_cluster" - /** * struct lp8860_led - * @lock - Lock for reading/writing the device @@ -107,7 +106,7 @@ struct lp8860_led { struct regmap *eeprom_regmap; struct gpio_desc *enable_gpio; struct regulator *regulator; - const char *label; + char label[LED_MAX_NAME_SIZE]; }; struct lp8860_eeprom_reg { @@ -365,19 +364,21 @@ static int lp8860_probe(struct i2c_client *client, int ret; struct lp8860_led *led; struct device_node *np = client->dev.of_node; + struct device_node *child_node; + const char *name; led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; - led->label = LP8860_DISP_LED_NAME; - - if (client->dev.of_node) { - ret = of_property_read_string(np, "label", &led->label); - if (ret) { - dev_err(&client->dev, "Missing label in dt\n"); - return -EINVAL; - } + for_each_available_child_of_node(np, child_node) { + ret = of_property_read_string(child_node, "label", &name); + if (!ret) + snprintf(led->label, sizeof(led->label), "%s:%s", + np->name, name); + else + snprintf(led->label, sizeof(led->label), + "%s::display_cluster", np->name); } led->enable_gpio = devm_gpiod_get_optional(&client->dev, From patchwork Mon Dec 4 21:20:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 120595 Delivered-To: patch@linaro.org Received: by 10.80.152.193 with SMTP id j59csp1380037edb; Mon, 4 Dec 2017 13:21:21 -0800 (PST) X-Google-Smtp-Source: AGs4zMYwHo8ajqGMF9UnAICPjU9Q7ptKCoij4G4NwObkXZHAs1o8f5yqvAT9nz7jFZ1nREDiror0 X-Received: by 10.84.132.40 with SMTP id 37mr16135626ple.246.1512422481113; Mon, 04 Dec 2017 13:21:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512422481; cv=none; d=google.com; s=arc-20160816; b=xApWI2R6dMOj1yQFFVCN6GrUv+xqF94FzUdt/tuXzfFXdQNNWAn3GD67WrN4xLG8+x Vkm0ZoO6LpvGSL7R5vGNv9RseHPg7X8RbNYw1G5InI4Ag1CR/Lozqmzqj/B388UIn6Je KoDEoxjrESD1r3aMLwQmyLAPBsvoAOaY4gpXtyjfF8+qBfTtse3vT665sWpSafp5ldCj fLnDyiyGqre72cUmUnfb5cBXDPethvnck0uXpBvlacqEbx/+czrBEuTQlZkFGn6zxwQi a8156M5YXbZYTGk0Z4Vhbytgaq5I8dtKDHzfKqtt0Vtms1xU6HU+DK6AGm3sDXIohPpg plLQ== 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=pJQWWZ3oFw9swEViW/q0eIQ4mG84fE2o7JcvzKQ7UGM=; b=Vq6K0mmvshqet6Wv1hI+OEcEBmqla0cRx/2su2FEcFQmeJu2ehbXx5Z84BGYWebZ6V 6xNhMOgikCKclF6YsiKUdKWfTdbgCGqixse1yxKcTj7BVP/TbK9mBk6wB6Iuvcs/gOVC mGUZmVBA0psU9VtEAQQjZNDrCvKGUCOC5YD6d8NsW9QTSvOsuUtJmjcHCaft3FlF2SoJ MBgrQ1U+FFfi7tYsBTaVwpwuCBJmquVYC2QFiu1V7YN7hdDuQxAst7D7temz6gYkUIGc j6mPYCuhVdcrV3xwGMlrkHWQhIaqb+9XAFsqhKWA4wwUfXeyhS7H+V0qN4tLVZYFtgWO kr5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Fc9sHZ3X; 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; 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 y34si10309802plb.377.2017.12.04.13.21.20; Mon, 04 Dec 2017 13:21:21 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Fc9sHZ3X; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752670AbdLDVUx (ORCPT + 28 others); Mon, 4 Dec 2017 16:20:53 -0500 Received: from lelnx194.ext.ti.com ([198.47.27.80]:16897 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752506AbdLDVUr (ORCPT ); Mon, 4 Dec 2017 16:20:47 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id vB4LKVIh014323; Mon, 4 Dec 2017 15:20:31 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1512422431; bh=KCMIwXPnZiAMYMtfyt7zEzA8ebulcfT+1av5AmtXBr8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Fc9sHZ3X0m7vFYogHwkPuB6NxKP/20ODXxG2UdX0qMufB/Agxv+GLxXsVm1BcnELS gDTtLDOHYUQ1lJHJwawydyc8UgCEtkZbK/yoBnYZBNVrLR0Mpuv/Zpvpg+WunoGpJ+ 32M3+6Ozk0XuWidfXPLL1oDrPNG1fgLa2j1Ypy9w= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id vB4LKVJY017161; Mon, 4 Dec 2017 15:20:31 -0600 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Mon, 4 Dec 2017 15:20:30 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Mon, 4 Dec 2017 15:20:30 -0600 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id vB4LKUQa005442; Mon, 4 Dec 2017 15:20:30 -0600 Received: from localhost (a0272616local-lt.dhcp.ti.com [172.22.83.187]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id vB4LKU323347; Mon, 4 Dec 2017 15:20:30 -0600 (CST) From: Dan Murphy To: , , , , CC: , , Dan Murphy Subject: [PATCH 5/5] leds: lp8860: Various fixes to align with LED framework Date: Mon, 4 Dec 2017 15:20:26 -0600 Message-ID: <20171204212026.14214-6-dmurphy@ti.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20171204212026.14214-1-dmurphy@ti.com> References: <20171204212026.14214-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Update the driver to conform with the LED framework. Use devm_led_classdev_register Destroy mutex on exit Remove dependency on CONFIG_OF in the driver and move to the Kconfig Update the MODULE_LICENSE to GPL v2 Remove setting of MAX brightness as the LED framework does this. Signed-off-by: Dan Murphy --- drivers/leds/Kconfig | 2 +- drivers/leds/leds-lp8860.c | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) -- 2.15.0.124.g7668cbc60 diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 318a28fd58fe..ac4d9d8bf96b 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -347,7 +347,7 @@ config LEDS_LP8788 config LEDS_LP8860 tristate "LED support for the TI LP8860 4 channel LED driver" - depends on LEDS_CLASS && I2C + depends on LEDS_CLASS && I2C && OF select REGMAP_I2C help If you say yes here you get support for the TI LP8860 4 channel diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c index 4fed603ee728..e94041e0e693 100644 --- a/drivers/leds/leds-lp8860.c +++ b/drivers/leds/leds-lp8860.c @@ -399,7 +399,6 @@ static int lp8860_probe(struct i2c_client *client, led->client = client; led->led_dev.name = led->label; - led->led_dev.max_brightness = LED_FULL; led->led_dev.brightness_set_blocking = lp8860_brightness_set; mutex_init(&led->lock); @@ -426,7 +425,7 @@ static int lp8860_probe(struct i2c_client *client, if (ret) return ret; - ret = led_classdev_register(&client->dev, &led->led_dev); + ret = devm_led_classdev_register(&client->dev, &led->led_dev); if (ret) { dev_err(&client->dev, "led register err: %d\n", ret); return ret; @@ -440,8 +439,6 @@ static int lp8860_remove(struct i2c_client *client) struct lp8860_led *led = i2c_get_clientdata(client); int ret; - led_classdev_unregister(&led->led_dev); - if (led->enable_gpio) gpiod_direction_output(led->enable_gpio, 0); @@ -452,6 +449,8 @@ static int lp8860_remove(struct i2c_client *client) "Failed to disable regulator\n"); } + mutex_destroy(&led->lock); + return 0; } @@ -461,18 +460,16 @@ static const struct i2c_device_id lp8860_id[] = { }; MODULE_DEVICE_TABLE(i2c, lp8860_id); -#ifdef CONFIG_OF static const struct of_device_id of_lp8860_leds_match[] = { { .compatible = "ti,lp8860", }, {}, }; MODULE_DEVICE_TABLE(of, of_lp8860_leds_match); -#endif static struct i2c_driver lp8860_driver = { .driver = { .name = "lp8860", - .of_match_table = of_match_ptr(of_lp8860_leds_match), + .of_match_table = of_lp8860_leds_match, }, .probe = lp8860_probe, .remove = lp8860_remove, @@ -482,4 +479,4 @@ module_i2c_driver(lp8860_driver); MODULE_DESCRIPTION("Texas Instruments LP8860 LED driver"); MODULE_AUTHOR("Dan Murphy "); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2");