From patchwork Sat Sep 19 22:15:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255372 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADDC8C43465 for ; Sat, 19 Sep 2020 22:15:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72C1D2344C for ; Sat, 19 Sep 2020 22:15:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="FRxxRaAW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726680AbgISWPx (ORCPT ); Sat, 19 Sep 2020 18:15:53 -0400 Received: from mail.nic.cz ([217.31.204.67]:49976 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726617AbgISWPw (ORCPT ); Sat, 19 Sep 2020 18:15:52 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 0A8D7140A47; Sun, 20 Sep 2020 00:15:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600553750; bh=gFflTJB0pjcJQCo0ox/mMiuMmClTppQKAMVvJucj2Yo=; h=From:To:Date; b=FRxxRaAW1sFwE4ePul2glErSL6BxONvsgwpjTdD7rfkeo/T2GmOIcRNMTUQ0c1Kvm 0hd2Xg1hlypNvGe6heKtJbANY7RWz++aB6ZzG2L2Kxm7r5XSHn7/UxsY1PQrW9HFnb 9eF8EVZ+MY6bxwJr0iL+wHcEroWAhVUii5J+dhIY= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?Ma?= =?utf-8?q?rek_Beh=C3=BAn?= , NeilBrown , Linus Walleij , "H . Nikolaus Schaller" , Tony Lindgren , Adam Ford , Viresh Kumar , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH leds + devicetree 03/13] dt-bindings: leds: tca6507: convert to YAML Date: Sun, 20 Sep 2020 00:15:38 +0200 Message-Id: <20200919221548.29984-4-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200919221548.29984-1-marek.behun@nic.cz> References: <20200919221548.29984-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org This converts the tca6507 LED binding to yaml. Signed-off-by: Marek Behún Cc: NeilBrown Cc: Linus Walleij Cc: H. Nikolaus Schaller Cc: Tony Lindgren Cc: Adam Ford Cc: Viresh Kumar Cc: Rob Herring Cc: devicetree@vger.kernel.org Reviewed-by: Rob Herring --- .../devicetree/bindings/leds/tca6507.txt | 49 ------- .../devicetree/bindings/leds/ti,tca6507.yaml | 134 ++++++++++++++++++ 2 files changed, 134 insertions(+), 49 deletions(-) delete mode 100644 Documentation/devicetree/bindings/leds/tca6507.txt create mode 100644 Documentation/devicetree/bindings/leds/ti,tca6507.yaml diff --git a/Documentation/devicetree/bindings/leds/tca6507.txt b/Documentation/devicetree/bindings/leds/tca6507.txt deleted file mode 100644 index bad9102796f32..0000000000000 --- a/Documentation/devicetree/bindings/leds/tca6507.txt +++ /dev/null @@ -1,49 +0,0 @@ -LEDs connected to tca6507 - -Required properties: -- compatible : should be : "ti,tca6507". -- #address-cells: must be 1 -- #size-cells: must be 0 -- reg: typically 0x45. - -Optional properties: -- gpio-controller: allows lines to be used as output-only GPIOs. -- #gpio-cells: if present, must not be 0. - -Each led is represented as a sub-node of the ti,tca6507 device. - -LED sub-node properties: -- label : (optional) see Documentation/devicetree/bindings/leds/common.txt -- reg : number of LED line (could be from 0 to 6) -- linux,default-trigger : (optional) - see Documentation/devicetree/bindings/leds/common.txt -- compatible: either "led" (the default) or "gpio". - -Examples: - -tca6507@45 { - compatible = "ti,tca6507"; - #address-cells = <1>; - #size-cells = <0>; - reg = <0x45>; - - gpio-controller; - #gpio-cells = <2>; - - led0: red-aux@0 { - label = "red:aux"; - reg = <0x0>; - }; - - led1: green-aux@1 { - label = "green:aux"; - reg = <0x5>; - linux,default-trigger = "default-on"; - }; - - wifi-reset@6 { - reg = <0x6>; - compatible = "gpio"; - }; -}; - diff --git a/Documentation/devicetree/bindings/leds/ti,tca6507.yaml b/Documentation/devicetree/bindings/leds/ti,tca6507.yaml new file mode 100644 index 0000000000000..94c307c987621 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/ti,tca6507.yaml @@ -0,0 +1,134 @@ +# SPDX-License-Identifier: GPL-2.0-only +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/ti,tca6507.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TCA6507 LED and GPIO controller + +maintainers: + - NeilBrown + +description: + The TCA6507 is a programmable LED controller connected via I2C that can drive + 7 separate lines either by holding them low, or by pulsing them with modulated + width. + +properties: + compatible: + const: ti,tca6507 + + reg: + description: I2C slave address of the controller. + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + gpio-controller: true + + "#gpio-cells": + const: 2 + + gpio-line-names: true + +patternProperties: + "^led@[0-6]$": + type: object + + $ref: common.yaml# + + properties: + reg: + minimum: 0 + maximum: 6 + + required: + - reg + + "^gpio@[0-6]$": + type: object + + properties: + compatible: + const: gpio + + reg: + minimum: 0 + maximum: 6 + + additionalProperties: false + + required: + - reg + - compatible + +if: + patternProperties: + "^gpio@[0-6]$": + properties: + compatible: + contains: + const: gpio +then: + required: + - gpio-controller + - "#gpio-cells" + +additionalProperties: false + +examples: + - | + + #include + #include + + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + led-controller@45 { + compatible = "ti,tca6507"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x45>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = "wifi_reset@6"; + + led@0 { + label = "gta04:red:aux"; + reg = <0x0>; + }; + + led@1 { + label = "gta04:green:aux"; + reg = <0x1>; + }; + + led@3 { + reg = <0x3>; + color = ; + function = LED_FUNCTION_POWER; + linux,default-trigger = "default-on"; + }; + + led@4 { + color = ; + function = LED_FUNCTION_POWER; + reg = <0x4>; + }; + + gpio@6 { + compatible = "gpio"; + reg = <0x6>; + }; + }; + }; + +... From patchwork Sat Sep 19 22:15:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255373 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D848EC43464 for ; Sat, 19 Sep 2020 22:15:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18AC32311B for ; Sat, 19 Sep 2020 22:15:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="FKtu2sxE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726660AbgISWPw (ORCPT ); Sat, 19 Sep 2020 18:15:52 -0400 Received: from lists.nic.cz ([217.31.204.67]:49994 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726626AbgISWPw (ORCPT ); Sat, 19 Sep 2020 18:15:52 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 461AE140A7D; Sun, 20 Sep 2020 00:15:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600553750; bh=4GFIuoGep6B/Lp8izOufEKIIzt3hVVrrJhDzcEp36lM=; h=From:To:Date; b=FKtu2sxEEJJkm+ke71jJkOg+WzF+gAVwrp7Sgb5BjgEtWx5E3HD0F6ved0QRoIppT FYh39twpS6M6pzS7WeLPlPJ61vjgu5YrvEBTyci/gE8SIcIMaNSkueg62T9dGSDDFA dEEB2qeOlAKIhYqamW9QLAGOwZuqtO+eQwxS7GCk= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?Ma?= =?utf-8?q?rek_Beh=C3=BAn?= , NeilBrown , Linus Walleij , "H . Nikolaus Schaller" , Tony Lindgren , Adam Ford , Viresh Kumar , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH leds + devicetree 04/13] ARM: dts: omap3: gta04: rename LED controlled subnodes Date: Sun, 20 Sep 2020 00:15:39 +0200 Message-Id: <20200919221548.29984-5-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200919221548.29984-1-marek.behun@nic.cz> References: <20200919221548.29984-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Rename LED controller subnodes to format "led@[0-6]" or "gpio@[0-6]" to conform to the new YAML defined binding. Use the `gpio-line-names` property to define GPIO names. Signed-off-by: Marek Behún Cc: NeilBrown Cc: Linus Walleij Cc: H. Nikolaus Schaller Cc: Tony Lindgren Cc: Adam Ford Cc: Viresh Kumar Cc: Rob Herring Cc: devicetree@vger.kernel.org --- arch/arm/boot/dts/omap3-gta04.dtsi | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/arm/boot/dts/omap3-gta04.dtsi b/arch/arm/boot/dts/omap3-gta04.dtsi index ecc45862b4f34..a28fe1b07215c 100644 --- a/arch/arm/boot/dts/omap3-gta04.dtsi +++ b/arch/arm/boot/dts/omap3-gta04.dtsi @@ -541,28 +541,30 @@ tca6507: tca6507@45 { gpio-controller; #gpio-cells = <2>; - gta04_led0: red_aux@0 { + gpio-line-names = "wifi_reset@6"; + + gta04_led0: led@0 { label = "gta04:red:aux"; reg = <0x0>; }; - gta04_led1: green_aux@1 { + gta04_led1: led@1 { label = "gta04:green:aux"; reg = <0x1>; }; - gta04_led3: red_power@3 { + gta04_led3: led@3 { label = "gta04:red:power"; reg = <0x3>; linux,default-trigger = "default-on"; }; - gta04_led4: green_power@4 { + gta04_led4: led@4 { label = "gta04:green:power"; reg = <0x4>; }; - wifi_reset: wifi_reset@6 { /* reference as <&tca_gpios 0 0> since it is currently the only GPIO */ + wifi_reset: gpio@6 { /* reference as <&tca_gpios 0 0> since it is currently the only GPIO */ reg = <0x6>; compatible = "gpio"; }; From patchwork Sat Sep 19 22:15:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255370 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D2A8C433DB for ; Sat, 19 Sep 2020 22:15:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AAEE2084C for ; Sat, 19 Sep 2020 22:15:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="UHpOLkhr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726747AbgISWPy (ORCPT ); Sat, 19 Sep 2020 18:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726738AbgISWPx (ORCPT ); Sat, 19 Sep 2020 18:15:53 -0400 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87445C0613CE for ; Sat, 19 Sep 2020 15:15:53 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id A3EF2140A85; Sun, 20 Sep 2020 00:15:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600553750; bh=f9S4N5M9gA782ksCiLviXKNq7OXunh1ReTX4Dlb6uQM=; h=From:To:Date; b=UHpOLkhrjxdt02eiZ9J/G1gKrk1mmPJT2IXwWWoAWyvI1TRpP1Fo4Fg9tWUOZmnmi Z0+hy0TrvrEeQ5oNrR2S+ntB51XP6WpG+/1HpjGFhlDCZOoupDbSAsjrLjtB3c9gLf ACNyo7hb75BiI8EPoxHCmWdQJKmMl9RPmQG3FnSk= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?Ma?= =?utf-8?q?rek_Beh=C3=BAn?= , NeilBrown , Linus Walleij , "H . Nikolaus Schaller" Subject: [PATCH leds + devicetree 06/13] leds: tca6507: cosmetic change: use helper variable Date: Sun, 20 Sep 2020 00:15:41 +0200 Message-Id: <20200919221548.29984-7-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200919221548.29984-1-marek.behun@nic.cz> References: <20200919221548.29984-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Use helper variable dev instead of always writing &client->dev. Signed-off-by: Marek Behún Cc: NeilBrown Cc: Linus Walleij Cc: H. Nikolaus Schaller --- drivers/leds/leds-tca6507.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c index 58dcbddfa0b27..6323539e54ae7 100644 --- a/drivers/leds/leds-tca6507.c +++ b/drivers/leds/leds-tca6507.c @@ -635,7 +635,7 @@ static int tca6507_gpio_direction_output(struct gpio_chip *gc, return 0; } -static int tca6507_probe_gpios(struct i2c_client *client, +static int tca6507_probe_gpios(struct device *dev, struct tca6507_chip *tca, struct tca6507_platform_data *pdata) { @@ -659,9 +659,9 @@ static int tca6507_probe_gpios(struct i2c_client *client, tca->gpio.owner = THIS_MODULE; tca->gpio.direction_output = tca6507_gpio_direction_output; tca->gpio.set = tca6507_gpio_set_value; - tca->gpio.parent = &client->dev; + tca->gpio.parent = dev; #ifdef CONFIG_OF_GPIO - tca->gpio.of_node = of_node_get(dev_of_node(&client->dev)); + tca->gpio.of_node = of_node_get(dev_of_node(dev)); #endif err = gpiochip_add_data(&tca->gpio, tca); if (err) { @@ -677,7 +677,7 @@ static void tca6507_remove_gpio(struct tca6507_chip *tca) gpiochip_remove(&tca->gpio); } #else /* CONFIG_GPIOLIB */ -static int tca6507_probe_gpios(struct i2c_client *client, +static int tca6507_probe_gpios(struct device *dev, struct tca6507_chip *tca, struct tca6507_platform_data *pdata) { @@ -689,23 +689,23 @@ static void tca6507_remove_gpio(struct tca6507_chip *tca) #endif /* CONFIG_GPIOLIB */ static struct tca6507_platform_data * -tca6507_led_dt_init(struct i2c_client *client) +tca6507_led_dt_init(struct device *dev) { struct tca6507_platform_data *pdata; struct fwnode_handle *child; struct led_info *tca_leds; int count; - count = device_get_child_node_count(&client->dev); + count = device_get_child_node_count(dev); if (!count || count > NUM_LEDS) return ERR_PTR(-ENODEV); - tca_leds = devm_kcalloc(&client->dev, NUM_LEDS, sizeof(struct led_info), + tca_leds = devm_kcalloc(dev, NUM_LEDS, sizeof(struct led_info), GFP_KERNEL); if (!tca_leds) return ERR_PTR(-ENOMEM); - device_for_each_child_node(&client->dev, child) { + device_for_each_child_node(dev, child) { struct led_info led; u32 reg; int ret; @@ -730,7 +730,7 @@ tca6507_led_dt_init(struct i2c_client *client) tca_leds[reg] = led; } - pdata = devm_kzalloc(&client->dev, sizeof(struct tca6507_platform_data), + pdata = devm_kzalloc(dev, sizeof(struct tca6507_platform_data), GFP_KERNEL); if (!pdata) return ERR_PTR(-ENOMEM); @@ -753,8 +753,9 @@ MODULE_DEVICE_TABLE(of, of_tca6507_leds_match); static int tca6507_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct tca6507_chip *tca; + struct device *dev = &client->dev; struct i2c_adapter *adapter; + struct tca6507_chip *tca; struct tca6507_platform_data *pdata; int err; int i = 0; @@ -764,13 +765,12 @@ static int tca6507_probe(struct i2c_client *client, if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) return -EIO; - pdata = tca6507_led_dt_init(client); + pdata = tca6507_led_dt_init(dev); if (IS_ERR(pdata)) { - dev_err(&client->dev, "Need %d entries in platform-data list\n", - NUM_LEDS); + dev_err(dev, "Need %d entries in platform-data list\n", NUM_LEDS); return PTR_ERR(pdata); } - tca = devm_kzalloc(&client->dev, sizeof(*tca), GFP_KERNEL); + tca = devm_kzalloc(dev, sizeof(*tca), GFP_KERNEL); if (!tca) return -ENOMEM; @@ -791,13 +791,12 @@ static int tca6507_probe(struct i2c_client *client, l->led_cdev.brightness_set = tca6507_brightness_set; l->led_cdev.blink_set = tca6507_blink_set; l->bank = -1; - err = led_classdev_register(&client->dev, - &l->led_cdev); + err = led_classdev_register(dev, &l->led_cdev); if (err < 0) goto exit; } } - err = tca6507_probe_gpios(client, tca, pdata); + err = tca6507_probe_gpios(dev, tca, pdata); if (err) goto exit; /* set all registers to known state - zero */ From patchwork Sat Sep 19 22:15:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C187AC4346B for ; Sat, 19 Sep 2020 22:15:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97CBF2084C for ; Sat, 19 Sep 2020 22:15:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="CpB1sL+1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726755AbgISWPy (ORCPT ); Sat, 19 Sep 2020 18:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726749AbgISWPy (ORCPT ); Sat, 19 Sep 2020 18:15:54 -0400 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13FC3C0613CE for ; Sat, 19 Sep 2020 15:15:54 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 421C0140A84; Sun, 20 Sep 2020 00:15:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600553751; bh=vzSvdQrOWGNH1dxpbdbbhheFqh4N+DKhDr+pGP0PLTA=; h=From:To:Date; b=CpB1sL+1jKziJblJ6kj2JWsy7lhBHkdNLzyCkQHFv8wuu+z2VWUKaj5H5fYPOAWZ/ UzkUPcuIBVxVNlRoY8j7VJIWNi47aCTbqg3B087s5UyVKq/qSfNKVaeyem09PEBhsu MLvCqKDrIGZ0gDwjlgtYCLuR+9ZJJwVAmV6ANaMc= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?Ma?= =?utf-8?q?rek_Beh=C3=BAn?= , NeilBrown , Linus Walleij , "H . Nikolaus Schaller" Subject: [PATCH leds + devicetree 09/13] leds: tca6507: use devres for LED and gpiochip registration Date: Sun, 20 Sep 2020 00:15:44 +0200 Message-Id: <20200919221548.29984-10-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200919221548.29984-1-marek.behun@nic.cz> References: <20200919221548.29984-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org By using devres for LED and gpiochip registration the driver gets simpler. Signed-off-by: Marek Behún Cc: NeilBrown Cc: Linus Walleij Cc: H. Nikolaus Schaller --- drivers/leds/leds-tca6507.c | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c index 03858b61c7af1..e2be615855ae3 100644 --- a/drivers/leds/leds-tca6507.c +++ b/drivers/leds/leds-tca6507.c @@ -613,7 +613,7 @@ static int tca6507_register_gpios(struct device *dev, struct tca6507_chip *tca, unsigned long gpio_bitmap) { - int i, gpios, ret; + int i, gpios; if (!gpio_bitmap) return 0; @@ -631,17 +631,7 @@ static int tca6507_register_gpios(struct device *dev, #ifdef CONFIG_OF_GPIO tca->gpio.of_node = of_node_get(dev_of_node(dev)); #endif - ret = gpiochip_add_data(&tca->gpio, tca); - if (ret) - tca->gpio.ngpio = 0; - - return ret; -} - -static void tca6507_remove_gpio(struct tca6507_chip *tca) -{ - if (tca->gpio.ngpio) - gpiochip_remove(&tca->gpio); + return devm_gpiochip_add_data(dev, &tca->gpio, tca); } #else /* CONFIG_GPIOLIB */ static int tca6507_register_gpios(struct device *dev, @@ -650,9 +640,6 @@ static int tca6507_register_gpios(struct device *dev, { return 0; } -static void tca6507_remove_gpio(struct tca6507_chip *tca) -{ -} #endif /* CONFIG_GPIOLIB */ static int tca6507_register_leds_and_gpios(struct device *dev, @@ -699,7 +686,7 @@ static int tca6507_register_leds_and_gpios(struct device *dev, led->led_cdev.brightness_set = tca6507_brightness_set; led->led_cdev.blink_set = tca6507_blink_set; led->bank = -1; - ret = led_classdev_register(dev, &led->led_cdev); + ret = devm_led_classdev_register(dev, &led->led_cdev); if (ret) { dev_err(dev, "Failed to register LED for node %pfw\n", child); @@ -725,7 +712,7 @@ static int tca6507_probe(struct i2c_client *client, struct device *dev = &client->dev; struct i2c_adapter *adapter; struct tca6507_chip *tca; - int err, i; + int err; adapter = client->adapter; @@ -743,32 +730,19 @@ static int tca6507_probe(struct i2c_client *client, err = tca6507_register_leds_and_gpios(dev, tca); if (err) - goto exit; + return err; /* set all registers to known state - zero */ tca->reg_set = 0x7f; schedule_work(&tca->work); return 0; -exit: - for (i = 0; i < NUM_LEDS; ++i) - if (tca->leds[i].led_cdev.name) - led_classdev_unregister(&tca->leds[i].led_cdev); - - return err; } static int tca6507_remove(struct i2c_client *client) { - int i; struct tca6507_chip *tca = i2c_get_clientdata(client); - struct tca6507_led *tca_leds = tca->leds; - for (i = 0; i < NUM_LEDS; i++) { - if (tca_leds[i].led_cdev.name) - led_classdev_unregister(&tca_leds[i].led_cdev); - } - tca6507_remove_gpio(tca); cancel_work_sync(&tca->work); return 0; From patchwork Sat Sep 19 22:15:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255368 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3256CC43478 for ; Sat, 19 Sep 2020 22:15:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA5C12084C for ; Sat, 19 Sep 2020 22:15:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="pS5OnIlL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726753AbgISWPy (ORCPT ); Sat, 19 Sep 2020 18:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726740AbgISWPy (ORCPT ); Sat, 19 Sep 2020 18:15:54 -0400 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53518C0613CF for ; Sat, 19 Sep 2020 15:15:54 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id D54D9140A98; Sun, 20 Sep 2020 00:15:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600553752; bh=l5EZnvD0y3TF1B58/iFHlosNxgMfoWrFOqjt3P7RTFQ=; h=From:To:Date; b=pS5OnIlLoySwCSvP59eGRB0VIuuFRZILAb6UOAzAVdDG/33MqCZlw2qSqaGVkbsgH Gl4ovi5CoF8JBBWmnlSpHp8fBVr9RMz8i+98e10b4BDoHvRP15iGsG9CvOYtYXG1nL su2uwyeFvnr3IFr2I3gPtVZjZ2UsvcWuzRycrBrs= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?Ma?= =?utf-8?q?rek_Beh=C3=BAn?= , NeilBrown , Linus Walleij , "H . Nikolaus Schaller" Subject: [PATCH leds + devicetree 12/13] leds: tca6507: set registers to zero before LEDs/GPIOs registration Date: Sun, 20 Sep 2020 00:15:47 +0200 Message-Id: <20200919221548.29984-13-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200919221548.29984-1-marek.behun@nic.cz> References: <20200919221548.29984-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org The LED registering functions can internally call brightness changes. If we zero the registers only after LEDs are registered, then the values set by registration code are lost. Therefore set chip's registers to zero before registering LEDs/GPIOs. Signed-off-by: Marek Behún Cc: NeilBrown Cc: Linus Walleij Cc: H. Nikolaus Schaller --- drivers/leds/leds-tca6507.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c index e32e628f2e460..ad4af6b6e94c7 100644 --- a/drivers/leds/leds-tca6507.c +++ b/drivers/leds/leds-tca6507.c @@ -732,14 +732,14 @@ static int tca6507_probe(struct i2c_client *client, spin_lock_init(&tca->lock); i2c_set_clientdata(client, tca); + /* set all registers to known state - zero */ + tca->reg_set = 0x7f; + tca6507_work(&tca->work); + err = tca6507_register_leds_and_gpios(dev, tca); if (err) return err; - /* set all registers to known state - zero */ - tca->reg_set = 0x7f; - schedule_work(&tca->work); - return 0; } From patchwork Sat Sep 19 22:15:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CCB0C4361C for ; Sat, 19 Sep 2020 22:15:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4459C2084C for ; Sat, 19 Sep 2020 22:15:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="P81QVNtb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726617AbgISWPz (ORCPT ); Sat, 19 Sep 2020 18:15:55 -0400 Received: from lists.nic.cz ([217.31.204.67]:50122 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726707AbgISWPz (ORCPT ); Sat, 19 Sep 2020 18:15:55 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 1BD4A140A9E; Sun, 20 Sep 2020 00:15:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600553752; bh=NB5LiiD9QW3rkQMR/lNEjPEXNmou7qEgsAqeLCDs/T4=; h=From:To:Date; b=P81QVNtb1gfvpYbq8B9N4MEYhXtEPwepkRuGOmvBhFSb+c/uihE7z627EFmd7ugE7 iyW6JMlkB0tdvtVOGCGvmonGbZ/C6F9mdoNUCM9s/hiRA3eru8I4ZrceDo5qgJ307m pSxaedIWbNgTT3jvU8qx2LQhdp5kz/UEK/HMq0aM= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?Ma?= =?utf-8?q?rek_Beh=C3=BAn?= , NeilBrown , Linus Walleij , "H . Nikolaus Schaller" Subject: [PATCH leds + devicetree 13/13] leds: tca6507: use struct led_init_data when registering Date: Sun, 20 Sep 2020 00:15:48 +0200 Message-Id: <20200919221548.29984-14-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200919221548.29984-1-marek.behun@nic.cz> References: <20200919221548.29984-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org By using struct led_init_data when registering we do not need to parse `label` nor `linux,default-trigger` DT property. Moreover `label` is deprecated and if it is not present but `color` and `function` are, LED core will compose a name from these properties instead. Signed-off-by: Marek Behún Cc: NeilBrown Cc: Linus Walleij Cc: H. Nikolaus Schaller --- drivers/leds/leds-tca6507.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c index ad4af6b6e94c7..362dc9b3d97d0 100644 --- a/drivers/leds/leds-tca6507.c +++ b/drivers/leds/leds-tca6507.c @@ -654,6 +654,7 @@ static int tca6507_register_leds_and_gpios(struct device *dev, return -EINVAL; device_for_each_child_node(dev, child) { + struct led_init_data init_data = {}; struct tca6507_led *led; u32 reg; @@ -679,18 +680,14 @@ static int tca6507_register_leds_and_gpios(struct device *dev, led = &tca->leds[reg]; led->chip = tca; led->num = reg; - - if (fwnode_property_read_string(child, "label", - &led->led_cdev.name)) - led->led_cdev.name = fwnode_get_name(child); - - fwnode_property_read_string(child, "linux,default-trigger", - &led->led_cdev.default_trigger); - + led->bank = -1; led->led_cdev.brightness_set = tca6507_brightness_set; led->led_cdev.blink_set = tca6507_blink_set; - led->bank = -1; - ret = devm_led_classdev_register(dev, &led->led_cdev); + + init_data.fwnode = child; + + ret = devm_led_classdev_register_ext(dev, &led->led_cdev, + &init_data); if (ret) { dev_err(dev, "Failed to register LED for node %pfw\n", child);