All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH leds + devicetree 00/13] leds: tca6507 cleanup
@ 2020-09-19 22:15 Marek Behún
  2020-09-19 22:15 ` [PATCH leds + devicetree 01/13] leds: tca6507: Absorb platform data Marek Behún
                   ` (12 more replies)
  0 siblings, 13 replies; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller, Tony Lindgren, Adam Ford,
	Viresh Kumar, Rob Herring, devicetree

Hi Pavel,

this is a cleanup of tca6507 LED driver.

This series applies on your for-next, but:
- the last patch should be added only after LED core parses
  `linux,default-trigger` property
- there is DT binding change and device tree change, I am not sure
  who should apply those patches

Mainly we are getting rid of platform data, but also a potential bug is
being fixed and bindings are DT being aligned.

Marek

Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Adam Ford <aford173@gmail.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org

Marek Behún (13):
  leds: tca6507: Absorb platform data
  leds: tca6507: use fwnode API instead of OF
  dt-bindings: leds: tca6507: convert to YAML
  ARM: dts: omap3: gta04: rename LED controlled subnodes
  leds: tca6507: do not set GPIO names
  leds: tca6507: cosmetic change: use helper variable
  leds: tca6507: register LEDs and GPIOs immediately after parsing
  leds: tca6507: remove binding comment
  leds: tca6507: use devres for LED and gpiochip registration
  leds: tca6507: let gpiolib set gpiochip's of_node
  leds: tca6507: fail on reg value conflict
  leds: tca6507: set registers to zero before LEDs/GPIOs registration
  leds: tca6507: use struct led_init_data when registering

 .../devicetree/bindings/leds/tca6507.txt      |  49 ----
 .../devicetree/bindings/leds/ti,tca6507.yaml  | 134 ++++++++++
 arch/arm/boot/dts/omap3-gta04.dtsi            |  12 +-
 drivers/leds/leds-tca6507.c                   | 234 ++++++------------
 include/linux/leds-tca6507.h                  |  21 --
 5 files changed, 217 insertions(+), 233 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/leds/tca6507.txt
 create mode 100644 Documentation/devicetree/bindings/leds/ti,tca6507.yaml
 delete mode 100644 include/linux/leds-tca6507.h


base-commit: a0e550dc351ab5fabe8ea86e45b974494a0a6bf8
-- 
2.26.2


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 01/13] leds: tca6507: Absorb platform data
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-20 17:09   ` H. Nikolaus Schaller
  2020-09-29 13:18   ` Linus Walleij
  2020-09-19 22:15 ` [PATCH leds + devicetree 02/13] leds: tca6507: use fwnode API instead of OF Marek Behún
                   ` (11 subsequent siblings)
  12 siblings, 2 replies; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller

The only in-tree usage of this driver is via device-tree. No on else
includes linux/leds-tca6507.h, so absorb the definition of platdata
structure.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/leds/leds-tca6507.c  | 11 ++++++++++-
 include/linux/leds-tca6507.h | 21 ---------------------
 2 files changed, 10 insertions(+), 22 deletions(-)
 delete mode 100644 include/linux/leds-tca6507.h

diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index a7e9fd85b6dd5..b5b5bafe2176e 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -95,7 +95,6 @@
 #include <linux/i2c.h>
 #include <linux/gpio/driver.h>
 #include <linux/workqueue.h>
-#include <linux/leds-tca6507.h>
 #include <linux/of.h>
 
 /* LED select registers determine the source that drives LED outputs */
@@ -108,6 +107,16 @@
 #define TCA6507_LS_BLINK0	0x6	/* Blink at Bank0 rate */
 #define TCA6507_LS_BLINK1	0x7	/* Blink at Bank1 rate */
 
+struct tca6507_platform_data {
+	struct led_platform_data leds;
+#ifdef CONFIG_GPIOLIB
+	int gpio_base;
+	void (*setup)(unsigned gpio_base, unsigned ngpio);
+#endif
+};
+
+#define	TCA6507_MAKE_GPIO 1
+
 enum {
 	BANK0,
 	BANK1,
diff --git a/include/linux/leds-tca6507.h b/include/linux/leds-tca6507.h
deleted file mode 100644
index 50d330ed11005..0000000000000
--- a/include/linux/leds-tca6507.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * TCA6507 LED chip driver.
- *
- * Copyright (C) 2011 Neil Brown <neil@brown.name>
- */
-
-#ifndef __LINUX_TCA6507_H
-#define __LINUX_TCA6507_H
-#include <linux/leds.h>
-
-struct tca6507_platform_data {
-	struct led_platform_data leds;
-#ifdef CONFIG_GPIOLIB
-	int gpio_base;
-	void (*setup)(unsigned gpio_base, unsigned ngpio);
-#endif
-};
-
-#define	TCA6507_MAKE_GPIO 1
-#endif /* __LINUX_TCA6507_H*/
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 02/13] leds: tca6507: use fwnode API instead of OF
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
  2020-09-19 22:15 ` [PATCH leds + devicetree 01/13] leds: tca6507: Absorb platform data Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-19 22:31   ` Marek Behun
       [not found]   ` <BD25CCC6-343D-4624-9718-276B3C7C6510@goldelico.com>
  2020-09-19 22:15 ` [PATCH leds + devicetree 03/13] dt-bindings: leds: tca6507: convert to YAML Marek Behún
                   ` (10 subsequent siblings)
  12 siblings, 2 replies; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller

Convert to use fwnode API instead of OF. It is more generic and if
someone wants to use this driver without device-tree yet still, they
will be able to via swnode fwnodes.

Remove the gpio setup function from platdata.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/leds/leds-tca6507.c | 66 ++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 37 deletions(-)

diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index b5b5bafe2176e..3e01fe2510f7c 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -94,8 +94,8 @@
 #include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/gpio/driver.h>
+#include <linux/property.h>
 #include <linux/workqueue.h>
-#include <linux/of.h>
 
 /* LED select registers determine the source that drives LED outputs */
 #define TCA6507_LS_LED_OFF	0x0	/* Output HI-Z (off) */
@@ -111,7 +111,6 @@ struct tca6507_platform_data {
 	struct led_platform_data leds;
 #ifdef CONFIG_GPIOLIB
 	int gpio_base;
-	void (*setup)(unsigned gpio_base, unsigned ngpio);
 #endif
 };
 
@@ -672,8 +671,6 @@ static int tca6507_probe_gpios(struct i2c_client *client,
 		tca->gpio.ngpio = 0;
 		return err;
 	}
-	if (pdata->setup)
-		pdata->setup(tca->gpio.base, tca->gpio.ngpio);
 	return 0;
 }
 
@@ -694,44 +691,50 @@ static void tca6507_remove_gpio(struct tca6507_chip *tca)
 }
 #endif /* CONFIG_GPIOLIB */
 
-#ifdef CONFIG_OF
 static struct tca6507_platform_data *
 tca6507_led_dt_init(struct i2c_client *client)
 {
-	struct device_node *np = dev_of_node(&client->dev), *child;
 	struct tca6507_platform_data *pdata;
+	struct fwnode_handle *child;
 	struct led_info *tca_leds;
 	int count;
 
-	count = of_get_available_child_count(np);
+	count = device_get_child_node_count(&client->dev);
 	if (!count || count > NUM_LEDS)
 		return ERR_PTR(-ENODEV);
 
-	tca_leds = devm_kcalloc(&client->dev,
-			NUM_LEDS, sizeof(struct led_info), GFP_KERNEL);
+	tca_leds = devm_kcalloc(&client->dev, NUM_LEDS, sizeof(struct led_info),
+				GFP_KERNEL);
 	if (!tca_leds)
 		return ERR_PTR(-ENOMEM);
 
-	for_each_available_child_of_node(np, child) {
+	device_for_each_child_node(&client->dev, child) {
 		struct led_info led;
 		u32 reg;
 		int ret;
 
-		led.name =
-			of_get_property(child, "label", NULL) ? : child->name;
-		led.default_trigger =
-			of_get_property(child, "linux,default-trigger", NULL);
+		if (fwnode_property_read_string(child, "label", &led.name))
+			led.name = fwnode_get_name(child);
+
+		fwnode_property_read_string(child, "linux,default-trigger",
+					    &led.default_trigger);
+
 		led.flags = 0;
-		if (of_property_match_string(child, "compatible", "gpio") >= 0)
+		if (fwnode_property_match_string(child, "compatible",
+						 "gpio") >= 0)
 			led.flags |= TCA6507_MAKE_GPIO;
-		ret = of_property_read_u32(child, "reg", &reg);
-		if (ret != 0 || reg >= NUM_LEDS)
-			continue;
+
+		ret = fwnode_property_read_u32(child, "reg", &reg);
+		if (ret || reg >= NUM_LEDS) {
+			fwnode_handle_put(child);
+			return ERR_PTR(ret);
+		}
 
 		tca_leds[reg] = led;
 	}
-	pdata = devm_kzalloc(&client->dev,
-			sizeof(struct tca6507_platform_data), GFP_KERNEL);
+
+	pdata = devm_kzalloc(&client->dev, sizeof(struct tca6507_platform_data),
+			     GFP_KERNEL);
 	if (!pdata)
 		return ERR_PTR(-ENOMEM);
 
@@ -740,6 +743,7 @@ tca6507_led_dt_init(struct i2c_client *client)
 #ifdef CONFIG_GPIOLIB
 	pdata->gpio_base = -1;
 #endif
+
 	return pdata;
 }
 
@@ -749,15 +753,6 @@ static const struct of_device_id of_tca6507_leds_match[] = {
 };
 MODULE_DEVICE_TABLE(of, of_tca6507_leds_match);
 
-#else
-static struct tca6507_platform_data *
-tca6507_led_dt_init(struct i2c_client *client)
-{
-	return ERR_PTR(-ENODEV);
-}
-
-#endif
-
 static int tca6507_probe(struct i2c_client *client,
 		const struct i2c_device_id *id)
 {
@@ -768,18 +763,15 @@ static int tca6507_probe(struct i2c_client *client,
 	int i = 0;
 
 	adapter = client->adapter;
-	pdata = dev_get_platdata(&client->dev);
 
 	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
 		return -EIO;
 
-	if (!pdata || pdata->leds.num_leds != NUM_LEDS) {
-		pdata = tca6507_led_dt_init(client);
-		if (IS_ERR(pdata)) {
-			dev_err(&client->dev, "Need %d entries in platform-data list\n",
-				NUM_LEDS);
-			return PTR_ERR(pdata);
-		}
+	pdata = tca6507_led_dt_init(client);
+	if (IS_ERR(pdata)) {
+		dev_err(&client->dev, "Need %d entries in platform-data list\n",
+			NUM_LEDS);
+		return PTR_ERR(pdata);
 	}
 	tca = devm_kzalloc(&client->dev, sizeof(*tca), GFP_KERNEL);
 	if (!tca)
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 03/13] dt-bindings: leds: tca6507: convert to YAML
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
  2020-09-19 22:15 ` [PATCH leds + devicetree 01/13] leds: tca6507: Absorb platform data Marek Behún
  2020-09-19 22:15 ` [PATCH leds + devicetree 02/13] leds: tca6507: use fwnode API instead of OF Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-29 16:56   ` Rob Herring
  2020-09-19 22:15 ` [PATCH leds + devicetree 04/13] ARM: dts: omap3: gta04: rename LED controlled subnodes Marek Behún
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller, Tony Lindgren, Adam Ford,
	Viresh Kumar, Rob Herring, devicetree

This converts the tca6507 LED binding to yaml.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Adam Ford <aford173@gmail.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
---
 .../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 <neilb@suse.de>
+
+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 <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/leds/common.h>
+
+    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 = <LED_COLOR_ID_RED>;
+                function = LED_FUNCTION_POWER;
+                linux,default-trigger = "default-on";
+            };
+
+            led@4 {
+                color = <LED_COLOR_ID_GREEN>;
+                function = LED_FUNCTION_POWER;
+                reg = <0x4>;
+            };
+
+            gpio@6 {
+                compatible = "gpio";
+                reg = <0x6>;
+            };
+        };
+    };
+
+...
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 04/13] ARM: dts: omap3: gta04: rename LED controlled subnodes
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
                   ` (2 preceding siblings ...)
  2020-09-19 22:15 ` [PATCH leds + devicetree 03/13] dt-bindings: leds: tca6507: convert to YAML Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-30 17:00   ` Pavel Machek
  2020-09-19 22:15 ` [PATCH leds + devicetree 05/13] leds: tca6507: do not set GPIO names Marek Behún
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller, Tony Lindgren, Adam Ford,
	Viresh Kumar, Rob Herring, devicetree

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 <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Adam Ford <aford173@gmail.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
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";
 		};
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 05/13] leds: tca6507: do not set GPIO names
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
                   ` (3 preceding siblings ...)
  2020-09-19 22:15 ` [PATCH leds + devicetree 04/13] ARM: dts: omap3: gta04: rename LED controlled subnodes Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-19 22:15 ` [PATCH leds + devicetree 06/13] leds: tca6507: cosmetic change: use helper variable Marek Behún
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller

Do not set GPIO names. Let gpiolib determine GPIO names from the DT
property `gpio-line-names`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/leds/leds-tca6507.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index 3e01fe2510f7c..58dcbddfa0b27 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -197,7 +197,6 @@ struct tca6507_chip {
 	} leds[NUM_LEDS];
 #ifdef CONFIG_GPIOLIB
 	struct gpio_chip		gpio;
-	const char			*gpio_name[NUM_LEDS];
 	int				gpio_map[NUM_LEDS];
 #endif
 };
@@ -647,7 +646,6 @@ static int tca6507_probe_gpios(struct i2c_client *client,
 	for (i = 0; i < NUM_LEDS; i++)
 		if (pdata->leds.leds[i].name && pdata->leds.leds[i].flags) {
 			/* Configure as a gpio */
-			tca->gpio_name[gpios] = pdata->leds.leds[i].name;
 			tca->gpio_map[gpios] = i;
 			gpios++;
 		}
@@ -656,7 +654,6 @@ static int tca6507_probe_gpios(struct i2c_client *client,
 		return 0;
 
 	tca->gpio.label = "gpio-tca6507";
-	tca->gpio.names = tca->gpio_name;
 	tca->gpio.ngpio = gpios;
 	tca->gpio.base = pdata->gpio_base;
 	tca->gpio.owner = THIS_MODULE;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 06/13] leds: tca6507: cosmetic change: use helper variable
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
                   ` (4 preceding siblings ...)
  2020-09-19 22:15 ` [PATCH leds + devicetree 05/13] leds: tca6507: do not set GPIO names Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-30 17:01   ` Pavel Machek
  2020-09-19 22:15 ` [PATCH leds + devicetree 07/13] leds: tca6507: register LEDs and GPIOs immediately after parsing Marek Behún
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller

Use helper variable dev instead of always writing &client->dev.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
---
 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 */
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 07/13] leds: tca6507: register LEDs and GPIOs immediately after parsing
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
                   ` (5 preceding siblings ...)
  2020-09-19 22:15 ` [PATCH leds + devicetree 06/13] leds: tca6507: cosmetic change: use helper variable Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-19 22:15 ` [PATCH leds + devicetree 08/13] leds: tca6507: remove binding comment Marek Behún
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller

Register LEDs immediately after parsing the properties.
Register GPIOs afterwards, at the moment we know all their IDs.

This allows us to be rid of platdata structure.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/leds/leds-tca6507.c | 161 ++++++++++++++----------------------
 1 file changed, 62 insertions(+), 99 deletions(-)

diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index 6323539e54ae7..e9c7c19481702 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -107,15 +107,6 @@
 #define TCA6507_LS_BLINK0	0x6	/* Blink at Bank0 rate */
 #define TCA6507_LS_BLINK1	0x7	/* Blink at Bank1 rate */
 
-struct tca6507_platform_data {
-	struct led_platform_data leds;
-#ifdef CONFIG_GPIOLIB
-	int gpio_base;
-#endif
-};
-
-#define	TCA6507_MAKE_GPIO 1
-
 enum {
 	BANK0,
 	BANK1,
@@ -635,27 +626,21 @@ static int tca6507_gpio_direction_output(struct gpio_chip *gc,
 	return 0;
 }
 
-static int tca6507_probe_gpios(struct device *dev,
-			       struct tca6507_chip *tca,
-			       struct tca6507_platform_data *pdata)
+static int tca6507_register_gpios(struct device *dev,
+				  struct tca6507_chip *tca,
+				  unsigned long gpio_bitmap)
 {
-	int err;
-	int i = 0;
-	int gpios = 0;
-
-	for (i = 0; i < NUM_LEDS; i++)
-		if (pdata->leds.leds[i].name && pdata->leds.leds[i].flags) {
-			/* Configure as a gpio */
-			tca->gpio_map[gpios] = i;
-			gpios++;
-		}
+	int i, gpios, ret;
 
-	if (!gpios)
+	if (!gpio_bitmap)
 		return 0;
 
+	for_each_set_bit(i, &gpio_bitmap, NUM_LEDS)
+		tca->gpio_map[gpios++] = i;
+
 	tca->gpio.label = "gpio-tca6507";
 	tca->gpio.ngpio = gpios;
-	tca->gpio.base = pdata->gpio_base;
+	tca->gpio.base = -1;
 	tca->gpio.owner = THIS_MODULE;
 	tca->gpio.direction_output = tca6507_gpio_direction_output;
 	tca->gpio.set = tca6507_gpio_set_value;
@@ -663,12 +648,11 @@ static int tca6507_probe_gpios(struct device *dev,
 #ifdef CONFIG_OF_GPIO
 	tca->gpio.of_node = of_node_get(dev_of_node(dev));
 #endif
-	err = gpiochip_add_data(&tca->gpio, tca);
-	if (err) {
+	ret = gpiochip_add_data(&tca->gpio, tca);
+	if (ret)
 		tca->gpio.ngpio = 0;
-		return err;
-	}
-	return 0;
+
+	return ret;
 }
 
 static void tca6507_remove_gpio(struct tca6507_chip *tca)
@@ -677,9 +661,9 @@ static void tca6507_remove_gpio(struct tca6507_chip *tca)
 		gpiochip_remove(&tca->gpio);
 }
 #else /* CONFIG_GPIOLIB */
-static int tca6507_probe_gpios(struct device *dev,
-			       struct tca6507_chip *tca,
-			       struct tca6507_platform_data *pdata)
+static int tca6507_register_gpios(struct device *dev,
+				  struct tca6507_chip *tca,
+				  unsigned long gpio_bitmap)
 {
 	return 0;
 }
@@ -688,60 +672,62 @@ static void tca6507_remove_gpio(struct tca6507_chip *tca)
 }
 #endif /* CONFIG_GPIOLIB */
 
-static struct tca6507_platform_data *
-tca6507_led_dt_init(struct device *dev)
+static int tca6507_register_leds_and_gpios(struct device *dev,
+					   struct tca6507_chip *tca)
 {
-	struct tca6507_platform_data *pdata;
+	unsigned long gpio_bitmap = 0;
 	struct fwnode_handle *child;
-	struct led_info *tca_leds;
-	int count;
+	int count, ret;
 
 	count = device_get_child_node_count(dev);
-	if (!count || count > NUM_LEDS)
-		return ERR_PTR(-ENODEV);
-
-	tca_leds = devm_kcalloc(dev, NUM_LEDS, sizeof(struct led_info),
-				GFP_KERNEL);
-	if (!tca_leds)
-		return ERR_PTR(-ENOMEM);
+	if (!count)
+		return -ENODEV;
+	else if (count > NUM_LEDS)
+		return -EINVAL;
 
 	device_for_each_child_node(dev, child) {
-		struct led_info led;
+		struct tca6507_led *led;
 		u32 reg;
-		int ret;
-
-		if (fwnode_property_read_string(child, "label", &led.name))
-			led.name = fwnode_get_name(child);
-
-		fwnode_property_read_string(child, "linux,default-trigger",
-					    &led.default_trigger);
-
-		led.flags = 0;
-		if (fwnode_property_match_string(child, "compatible",
-						 "gpio") >= 0)
-			led.flags |= TCA6507_MAKE_GPIO;
 
 		ret = fwnode_property_read_u32(child, "reg", &reg);
 		if (ret || reg >= NUM_LEDS) {
-			fwnode_handle_put(child);
-			return ERR_PTR(ret);
+			dev_err(dev, "Invalid 'reg' property for node %pfw\n",
+				child);
+			goto err;
 		}
 
-		tca_leds[reg] = led;
-	}
+		if (fwnode_property_match_string(child, "compatible",
+						 "gpio") >= 0) {
+			gpio_bitmap |= BIT(reg);
+			continue;
+		}
 
-	pdata = devm_kzalloc(dev, sizeof(struct tca6507_platform_data),
-			     GFP_KERNEL);
-	if (!pdata)
-		return ERR_PTR(-ENOMEM);
+		led = &tca->leds[reg];
+		led->chip = tca;
+		led->num = reg;
 
-	pdata->leds.leds = tca_leds;
-	pdata->leds.num_leds = NUM_LEDS;
-#ifdef CONFIG_GPIOLIB
-	pdata->gpio_base = -1;
-#endif
+		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->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);
+		if (ret) {
+			dev_err(dev, "Failed to register LED for node %pfw\n",
+				child);
+			goto err;
+		}
+	}
 
-	return pdata;
+	return tca6507_register_gpios(dev, tca, gpio_bitmap);
+err:
+	fwnode_handle_put(child);
+	return ret;
 }
 
 static const struct of_device_id of_tca6507_leds_match[] = {
@@ -756,20 +742,13 @@ static int tca6507_probe(struct i2c_client *client,
 	struct device *dev = &client->dev;
 	struct i2c_adapter *adapter;
 	struct tca6507_chip *tca;
-	struct tca6507_platform_data *pdata;
-	int err;
-	int i = 0;
+	int err, i;
 
 	adapter = client->adapter;
 
 	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
 		return -EIO;
 
-	pdata = tca6507_led_dt_init(dev);
-	if (IS_ERR(pdata)) {
-		dev_err(dev, "Need %d entries in platform-data list\n", NUM_LEDS);
-		return PTR_ERR(pdata);
-	}
 	tca = devm_kzalloc(dev, sizeof(*tca), GFP_KERNEL);
 	if (!tca)
 		return -ENOMEM;
@@ -779,36 +758,20 @@ static int tca6507_probe(struct i2c_client *client,
 	spin_lock_init(&tca->lock);
 	i2c_set_clientdata(client, tca);
 
-	for (i = 0; i < NUM_LEDS; i++) {
-		struct tca6507_led *l = tca->leds + i;
-
-		l->chip = tca;
-		l->num = i;
-		if (pdata->leds.leds[i].name && !pdata->leds.leds[i].flags) {
-			l->led_cdev.name = pdata->leds.leds[i].name;
-			l->led_cdev.default_trigger
-				= pdata->leds.leds[i].default_trigger;
-			l->led_cdev.brightness_set = tca6507_brightness_set;
-			l->led_cdev.blink_set = tca6507_blink_set;
-			l->bank = -1;
-			err = led_classdev_register(dev, &l->led_cdev);
-			if (err < 0)
-				goto exit;
-		}
-	}
-	err = tca6507_probe_gpios(dev, tca, pdata);
+	err = tca6507_register_leds_and_gpios(dev, tca);
 	if (err)
 		goto exit;
+
 	/* set all registers to known state - zero */
 	tca->reg_set = 0x7f;
 	schedule_work(&tca->work);
 
 	return 0;
 exit:
-	while (i--) {
+	for (i = 0; i < NUM_LEDS; ++i)
 		if (tca->leds[i].led_cdev.name)
 			led_classdev_unregister(&tca->leds[i].led_cdev);
-	}
+
 	return err;
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 08/13] leds: tca6507: remove binding comment
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
                   ` (6 preceding siblings ...)
  2020-09-19 22:15 ` [PATCH leds + devicetree 07/13] leds: tca6507: register LEDs and GPIOs immediately after parsing Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-19 22:15 ` [PATCH leds + devicetree 09/13] leds: tca6507: use devres for LED and gpiochip registration Marek Behún
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller

Remove the binding comment at the beginning. The information for
platdata is now obsolete and DT binding is documented in device-tree
bindings.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/leds/leds-tca6507.c | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index e9c7c19481702..03858b61c7af1 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -69,23 +69,6 @@
  * defaulted.  Similarly the banks know if each time was explicit or a
  * default.  Defaults are permitted to be changed freely - they are
  * not recognised when matching.
- *
- *
- * An led-tca6507 device must be provided with platform data or
- * configured via devicetree.
- *
- * The platform-data lists for each output: the name, default trigger,
- * and whether the signal is being used as a GPIO rather than an LED.
- * 'struct led_plaform_data' is used for this.  If 'name' is NULL, the
- * output isn't used.  If 'flags' is TCA6507_MAKE_GPIO, the output is
- * a GPO.  The "struct led_platform_data" can be embedded in a "struct
- * tca6507_platform_data" which adds a 'gpio_base' for the GPIOs, and
- * a 'setup' callback which is called once the GPIOs are available.
- *
- * When configured via devicetree there is one child for each output.
- * The "reg" determines the output number and "compatible" determines
- * whether it is an LED or a GPIO.  "linux,default-trigger" can set a
- * default trigger.
  */
 
 #include <linux/module.h>
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 09/13] leds: tca6507: use devres for LED and gpiochip registration
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
                   ` (7 preceding siblings ...)
  2020-09-19 22:15 ` [PATCH leds + devicetree 08/13] leds: tca6507: remove binding comment Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-19 22:15 ` [PATCH leds + devicetree 10/13] leds: tca6507: let gpiolib set gpiochip's of_node Marek Behún
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller

By using devres for LED and gpiochip registration the driver gets
simpler.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
---
 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;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 10/13] leds: tca6507: let gpiolib set gpiochip's of_node
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
                   ` (8 preceding siblings ...)
  2020-09-19 22:15 ` [PATCH leds + devicetree 09/13] leds: tca6507: use devres for LED and gpiochip registration Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-19 22:15 ` [PATCH leds + devicetree 11/13] leds: tca6507: fail on reg value conflict Marek Behún
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller

Do not set gpiochip's of_node. It is done by gpiolib since we are
setting gpiochip's parent device.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/leds/leds-tca6507.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index e2be615855ae3..77a36e4da2508 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -628,9 +628,7 @@ static int tca6507_register_gpios(struct device *dev,
 	tca->gpio.direction_output = tca6507_gpio_direction_output;
 	tca->gpio.set = tca6507_gpio_set_value;
 	tca->gpio.parent = dev;
-#ifdef CONFIG_OF_GPIO
-	tca->gpio.of_node = of_node_get(dev_of_node(dev));
-#endif
+
 	return devm_gpiochip_add_data(dev, &tca->gpio, tca);
 }
 #else /* CONFIG_GPIOLIB */
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 11/13] leds: tca6507: fail on reg value conflict
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
                   ` (9 preceding siblings ...)
  2020-09-19 22:15 ` [PATCH leds + devicetree 10/13] leds: tca6507: let gpiolib set gpiochip's of_node Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-30 17:01   ` Pavel Machek
  2020-09-19 22:15 ` [PATCH leds + devicetree 12/13] leds: tca6507: set registers to zero before LEDs/GPIOs registration Marek Behún
  2020-09-19 22:15 ` [PATCH leds + devicetree 13/13] leds: tca6507: use struct led_init_data when registering Marek Behún
  12 siblings, 1 reply; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller

Fail if two child nodes have the same `reg` property value.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/leds/leds-tca6507.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index 77a36e4da2508..e32e628f2e460 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -643,7 +643,7 @@ static int tca6507_register_gpios(struct device *dev,
 static int tca6507_register_leds_and_gpios(struct device *dev,
 					   struct tca6507_chip *tca)
 {
-	unsigned long gpio_bitmap = 0;
+	unsigned long gpio_bitmap = 0, led_bitmap = 0;
 	struct fwnode_handle *child;
 	int count, ret;
 
@@ -662,12 +662,18 @@ static int tca6507_register_leds_and_gpios(struct device *dev,
 			dev_err(dev, "Invalid 'reg' property for node %pfw\n",
 				child);
 			goto err;
+		} else if ((gpio_bitmap | led_bitmap) & BIT(reg)) {
+			dev_err(dev, "LED channel already used for node %pfw\n",
+				child);
+			goto err;
 		}
 
 		if (fwnode_property_match_string(child, "compatible",
 						 "gpio") >= 0) {
 			gpio_bitmap |= BIT(reg);
 			continue;
+		} else {
+			led_bitmap |= BIT(reg);
 		}
 
 		led = &tca->leds[reg];
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 12/13] leds: tca6507: set registers to zero before LEDs/GPIOs registration
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
                   ` (10 preceding siblings ...)
  2020-09-19 22:15 ` [PATCH leds + devicetree 11/13] leds: tca6507: fail on reg value conflict Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-19 22:15 ` [PATCH leds + devicetree 13/13] leds: tca6507: use struct led_init_data when registering Marek Behún
  12 siblings, 0 replies; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller

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 <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
---
 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;
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH leds + devicetree 13/13] leds: tca6507: use struct led_init_data when registering
  2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
                   ` (11 preceding siblings ...)
  2020-09-19 22:15 ` [PATCH leds + devicetree 12/13] leds: tca6507: set registers to zero before LEDs/GPIOs registration Marek Behún
@ 2020-09-19 22:15 ` Marek Behún
  2020-09-25  6:49   ` Jacek Anaszewski
  12 siblings, 1 reply; 29+ messages in thread
From: Marek Behún @ 2020-09-19 22:15 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, Marek Behún, NeilBrown,
	Linus Walleij, H . Nikolaus Schaller

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 <marek.behun@nic.cz>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
---
 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);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 02/13] leds: tca6507: use fwnode API instead of OF
  2020-09-19 22:15 ` [PATCH leds + devicetree 02/13] leds: tca6507: use fwnode API instead of OF Marek Behún
@ 2020-09-19 22:31   ` Marek Behun
       [not found]   ` <BD25CCC6-343D-4624-9718-276B3C7C6510@goldelico.com>
  1 sibling, 0 replies; 29+ messages in thread
From: Marek Behun @ 2020-09-19 22:31 UTC (permalink / raw)
  To: linux-leds
  Cc: Pavel Machek, Dan Murphy, NeilBrown, Linus Walleij,
	H . Nikolaus Schaller

This patch should also remove the use of of_match_ptr, since the
definition of variable of_tca6507_leds_match isn't guarded by CONFIG_OF
anymore. (If kernel test robot enables this driver but disables
CONFIG_OF, a warning will be issued).

Pavel, should I respin this, or send another patch afterwards?

Marek

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 01/13] leds: tca6507: Absorb platform data
  2020-09-19 22:15 ` [PATCH leds + devicetree 01/13] leds: tca6507: Absorb platform data Marek Behún
@ 2020-09-20 17:09   ` H. Nikolaus Schaller
  2020-09-29 13:18   ` Linus Walleij
  1 sibling, 0 replies; 29+ messages in thread
From: H. Nikolaus Schaller @ 2020-09-20 17:09 UTC (permalink / raw)
  To: Marek Behún
  Cc: linux-leds, Pavel Machek, Dan Murphy, NeilBrown, Linus Walleij


> Am 20.09.2020 um 00:15 schrieb Marek Behún <marek.behun@nic.cz>:
> 
> The only in-tree usage of this driver is via device-tree. No on else
> includes linux/leds-tca6507.h, so absorb the definition of platdata
> structure.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Cc: NeilBrown <neilb@suse.de>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: H. Nikolaus Schaller <hns@goldelico.com>

Tested-by: H. Nikolaus Schaller <hns@goldelico.com>

on GTA04 (omap3-gta04.dtsi).

> ---
> drivers/leds/leds-tca6507.c  | 11 ++++++++++-
> include/linux/leds-tca6507.h | 21 ---------------------
> 2 files changed, 10 insertions(+), 22 deletions(-)
> delete mode 100644 include/linux/leds-tca6507.h
> 
> diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
> index a7e9fd85b6dd5..b5b5bafe2176e 100644
> --- a/drivers/leds/leds-tca6507.c
> +++ b/drivers/leds/leds-tca6507.c
> @@ -95,7 +95,6 @@
> #include <linux/i2c.h>
> #include <linux/gpio/driver.h>
> #include <linux/workqueue.h>
> -#include <linux/leds-tca6507.h>
> #include <linux/of.h>
> 
> /* LED select registers determine the source that drives LED outputs */
> @@ -108,6 +107,16 @@
> #define TCA6507_LS_BLINK0	0x6	/* Blink at Bank0 rate */
> #define TCA6507_LS_BLINK1	0x7	/* Blink at Bank1 rate */
> 
> +struct tca6507_platform_data {
> +	struct led_platform_data leds;
> +#ifdef CONFIG_GPIOLIB
> +	int gpio_base;
> +	void (*setup)(unsigned gpio_base, unsigned ngpio);
> +#endif
> +};
> +
> +#define	TCA6507_MAKE_GPIO 1
> +
> enum {
> 	BANK0,
> 	BANK1,
> diff --git a/include/linux/leds-tca6507.h b/include/linux/leds-tca6507.h
> deleted file mode 100644
> index 50d330ed11005..0000000000000
> --- a/include/linux/leds-tca6507.h
> +++ /dev/null
> @@ -1,21 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0-only */
> -/*
> - * TCA6507 LED chip driver.
> - *
> - * Copyright (C) 2011 Neil Brown <neil@brown.name>
> - */
> -
> -#ifndef __LINUX_TCA6507_H
> -#define __LINUX_TCA6507_H
> -#include <linux/leds.h>
> -
> -struct tca6507_platform_data {
> -	struct led_platform_data leds;
> -#ifdef CONFIG_GPIOLIB
> -	int gpio_base;
> -	void (*setup)(unsigned gpio_base, unsigned ngpio);
> -#endif
> -};
> -
> -#define	TCA6507_MAKE_GPIO 1
> -#endif /* __LINUX_TCA6507_H*/
> -- 
> 2.26.2
> 


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 02/13] leds: tca6507: use fwnode API instead of OF
       [not found]   ` <BD25CCC6-343D-4624-9718-276B3C7C6510@goldelico.com>
@ 2020-09-20 17:35     ` Marek Behun
  2020-09-20 17:39       ` Marek Behun
  0 siblings, 1 reply; 29+ messages in thread
From: Marek Behun @ 2020-09-20 17:35 UTC (permalink / raw)
  To: H. Nikolaus Schaller
  Cc: linux-leds, Pavel Machek, Dan Murphy, NeilBrown, Linus Walleij

On Sun, 20 Sep 2020 19:10:19 +0200
H. Nikolaus Schaller <hns@goldelico.com> wrote:

> I wanted to test, but was not able to git am this patch to my working
> environment (v5.9-rc5 or linux-next). So maybe some prerequisite is missing.

Could you try applying on Pavel's for-next?

https://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git/log/?h=for-next

Marek

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 02/13] leds: tca6507: use fwnode API instead of OF
  2020-09-20 17:35     ` Marek Behun
@ 2020-09-20 17:39       ` Marek Behun
  2020-09-20 18:09         ` H. Nikolaus Schaller
  0 siblings, 1 reply; 29+ messages in thread
From: Marek Behun @ 2020-09-20 17:39 UTC (permalink / raw)
  To: H. Nikolaus Schaller
  Cc: linux-leds, Pavel Machek, Dan Murphy, NeilBrown, Linus Walleij

On Sun, 20 Sep 2020 19:35:03 +0200
Marek Behun <marek.behun@nic.cz> wrote:

> On Sun, 20 Sep 2020 19:10:19 +0200
> H. Nikolaus Schaller <hns@goldelico.com> wrote:
> 
> > I wanted to test, but was not able to git am this patch to my working
> > environment (v5.9-rc5 or linux-next). So maybe some prerequisite is missing.
> 
> Could you try applying on Pavel's for-next?
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git/log/?h=for-next
> 
> Marek

Or even better, could you try my branch leds-cleanup-for-pavel? This is
applied on top of Pavel's for-next branch.

https://git.kernel.org/pub/scm/linux/kernel/git/kabel/linux.git/log/?h=leds-cleanup-for-pavel

Marek
Marek

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 02/13] leds: tca6507: use fwnode API instead of OF
  2020-09-20 17:39       ` Marek Behun
@ 2020-09-20 18:09         ` H. Nikolaus Schaller
  2020-09-22 19:29           ` H. Nikolaus Schaller
  0 siblings, 1 reply; 29+ messages in thread
From: H. Nikolaus Schaller @ 2020-09-20 18:09 UTC (permalink / raw)
  To: Marek Behun
  Cc: linux-leds, Pavel Machek, Dan Murphy, NeilBrown, Linus Walleij


> Am 20.09.2020 um 19:39 schrieb Marek Behun <marek.behun@nic.cz>:
> 
> On Sun, 20 Sep 2020 19:35:03 +0200
> Marek Behun <marek.behun@nic.cz> wrote:
> 
>> On Sun, 20 Sep 2020 19:10:19 +0200
>> H. Nikolaus Schaller <hns@goldelico.com> wrote:
>> 
>>> I wanted to test, but was not able to git am this patch to my working
>>> environment (v5.9-rc5 or linux-next). So maybe some prerequisite is missing.
>> 
>> Could you try applying on Pavel's for-next?
>> 
>> https://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git/log/?h=for-next
>> 
>> Marek
> 
> Or even better, could you try my branch leds-cleanup-for-pavel? This is
> applied on top of Pavel's for-next branch.
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/kabel/linux.git/log/?h=leds-cleanup-for-pavel

Ok, seems to depend on:

leds: various: use only available OF children
leds: various: use dev_of_node(dev) instead of dev->of_node

Will try tomorrow.

BR and thanks,
Nikolaus


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 02/13] leds: tca6507: use fwnode API instead of OF
  2020-09-20 18:09         ` H. Nikolaus Schaller
@ 2020-09-22 19:29           ` H. Nikolaus Schaller
  2020-09-24 12:14             ` Pavel Machek
  0 siblings, 1 reply; 29+ messages in thread
From: H. Nikolaus Schaller @ 2020-09-22 19:29 UTC (permalink / raw)
  To: Marek Behun
  Cc: linux-leds, Pavel Machek, Dan Murphy, NeilBrown, Linus Walleij


> Am 20.09.2020 um 20:09 schrieb H. Nikolaus Schaller <hns@goldelico.com>:
> 
> 
>> Am 20.09.2020 um 19:39 schrieb Marek Behun <marek.behun@nic.cz>:
>> 
>> On Sun, 20 Sep 2020 19:35:03 +0200
>> Marek Behun <marek.behun@nic.cz> wrote:
>> 
>>> On Sun, 20 Sep 2020 19:10:19 +0200
>>> H. Nikolaus Schaller <hns@goldelico.com> wrote:
>>> 
>>>> I wanted to test, but was not able to git am this patch to my working
>>>> environment (v5.9-rc5 or linux-next). So maybe some prerequisite is missing.
>>> 
>>> Could you try applying on Pavel's for-next?
>>> 
>>> https://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git/log/?h=for-next
>>> 
>>> Marek
>> 
>> Or even better, could you try my branch leds-cleanup-for-pavel? This is
>> applied on top of Pavel's for-next branch.
>> 
>> https://git.kernel.org/pub/scm/linux/kernel/git/kabel/linux.git/log/?h=leds-cleanup-for-pavel
> 
> Ok, seems to depend on:
> 
> leds: various: use only available OF children
> leds: various: use dev_of_node(dev) instead of dev->of_node
> 
> Will try tomorrow.

Ok, I have not found a negative effect on GTA04...
Well, it only uses DT for ages.

BR,
Nikolaus

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 02/13] leds: tca6507: use fwnode API instead of OF
  2020-09-22 19:29           ` H. Nikolaus Schaller
@ 2020-09-24 12:14             ` Pavel Machek
  0 siblings, 0 replies; 29+ messages in thread
From: Pavel Machek @ 2020-09-24 12:14 UTC (permalink / raw)
  To: H. Nikolaus Schaller
  Cc: Marek Behun, linux-leds, Dan Murphy, NeilBrown, Linus Walleij

[-- Attachment #1: Type: text/plain, Size: 654 bytes --]

Hi!

> > leds: various: use only available OF children
> > leds: various: use dev_of_node(dev) instead of dev->of_node
> > 
> > Will try tomorrow.
> 
> Ok, I have not found a negative effect on GTA04...
> Well, it only uses DT for ages.

Thanks, I applied 1 and 2 of the series.

Device tree and documentation changes are not really for me (I can
take the documentation ones if I get and ack). The rest does not look bad,
but I would not mind someone testing them.

Best regards,

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 13/13] leds: tca6507: use struct led_init_data when registering
  2020-09-19 22:15 ` [PATCH leds + devicetree 13/13] leds: tca6507: use struct led_init_data when registering Marek Behún
@ 2020-09-25  6:49   ` Jacek Anaszewski
  2020-09-25 14:36     ` Marek Behun
  0 siblings, 1 reply; 29+ messages in thread
From: Jacek Anaszewski @ 2020-09-25  6:49 UTC (permalink / raw)
  To: Marek Behún, linux-leds
  Cc: Pavel Machek, Dan Murphy, NeilBrown, Linus Walleij,
	H . Nikolaus Schaller

Hi Marek,

On 9/20/20 12:15 AM, Marek Behún wrote:
> 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 <marek.behun@nic.cz>
> Cc: NeilBrown <neilb@suse.de>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: H. Nikolaus Schaller <hns@goldelico.com>
> ---
>   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);
> 

For all drivers you switch to using *ext() API DT bindings should be
updated as well to let people know that they can now use 'function'
and 'color' properties.

-- 
Best regards,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 13/13] leds: tca6507: use struct led_init_data when registering
  2020-09-25  6:49   ` Jacek Anaszewski
@ 2020-09-25 14:36     ` Marek Behun
  0 siblings, 0 replies; 29+ messages in thread
From: Marek Behun @ 2020-09-25 14:36 UTC (permalink / raw)
  To: Jacek Anaszewski
  Cc: linux-leds, Pavel Machek, Dan Murphy, NeilBrown, Linus Walleij,
	H . Nikolaus Schaller

On Fri, 25 Sep 2020 08:49:43 +0200
Jacek Anaszewski <jacek.anaszewski@gmail.com> wrote:

> For all drivers you switch to using *ext() API DT bindings should be
> updated as well to let people know that they can now use 'function'
> and 'color' properties.
> 

I will look into this, thanks.
Marek

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 01/13] leds: tca6507: Absorb platform data
  2020-09-19 22:15 ` [PATCH leds + devicetree 01/13] leds: tca6507: Absorb platform data Marek Behún
  2020-09-20 17:09   ` H. Nikolaus Schaller
@ 2020-09-29 13:18   ` Linus Walleij
  1 sibling, 0 replies; 29+ messages in thread
From: Linus Walleij @ 2020-09-29 13:18 UTC (permalink / raw)
  To: Marek Behún
  Cc: Linux LED Subsystem, Pavel Machek, Dan Murphy, NeilBrown,
	H . Nikolaus Schaller

On Sun, Sep 20, 2020 at 12:15 AM Marek Behún <marek.behun@nic.cz> wrote:

> The only in-tree usage of this driver is via device-tree. No on else
> includes linux/leds-tca6507.h, so absorb the definition of platdata
> structure.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Cc: NeilBrown <neilb@suse.de>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: H. Nikolaus Schaller <hns@goldelico.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 03/13] dt-bindings: leds: tca6507: convert to YAML
  2020-09-19 22:15 ` [PATCH leds + devicetree 03/13] dt-bindings: leds: tca6507: convert to YAML Marek Behún
@ 2020-09-29 16:56   ` Rob Herring
  2020-09-30 16:59     ` Pavel Machek
  0 siblings, 1 reply; 29+ messages in thread
From: Rob Herring @ 2020-09-29 16:56 UTC (permalink / raw)
  To: Marek Behún
  Cc: devicetree, linux-leds, Linus Walleij, H . Nikolaus Schaller,
	Tony Lindgren, Adam Ford, Viresh Kumar, NeilBrown, Dan Murphy,
	Rob Herring, Pavel Machek

On Sun, 20 Sep 2020 00:15:38 +0200, Marek Behún wrote:
> This converts the tca6507 LED binding to yaml.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Cc: NeilBrown <neilb@suse.de>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: H. Nikolaus Schaller <hns@goldelico.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Adam Ford <aford173@gmail.com>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree@vger.kernel.org
> ---
>  .../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
> 

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 03/13] dt-bindings: leds: tca6507: convert to YAML
  2020-09-29 16:56   ` Rob Herring
@ 2020-09-30 16:59     ` Pavel Machek
  0 siblings, 0 replies; 29+ messages in thread
From: Pavel Machek @ 2020-09-30 16:59 UTC (permalink / raw)
  To: Rob Herring
  Cc: Marek Behún, devicetree, linux-leds, Linus Walleij,
	H . Nikolaus Schaller, Tony Lindgren, Adam Ford, Viresh Kumar,
	NeilBrown, Dan Murphy, Rob Herring

[-- Attachment #1: Type: text/plain, Size: 1143 bytes --]

On Tue 2020-09-29 11:56:06, Rob Herring wrote:
> On Sun, 20 Sep 2020 00:15:38 +0200, Marek Behún wrote:
> > This converts the tca6507 LED binding to yaml.
> > 
> > Signed-off-by: Marek Behún <marek.behun@nic.cz>
> > Cc: NeilBrown <neilb@suse.de>
> > Cc: Linus Walleij <linus.walleij@linaro.org>
> > Cc: H. Nikolaus Schaller <hns@goldelico.com>
> > Cc: Tony Lindgren <tony@atomide.com>
> > Cc: Adam Ford <aford173@gmail.com>
> > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: devicetree@vger.kernel.org
> > ---
> >  .../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
> > 
> 
> Reviewed-by: Rob Herring <robh@kernel.org>

Thanks, applied.

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 04/13] ARM: dts: omap3: gta04: rename LED controlled subnodes
  2020-09-19 22:15 ` [PATCH leds + devicetree 04/13] ARM: dts: omap3: gta04: rename LED controlled subnodes Marek Behún
@ 2020-09-30 17:00   ` Pavel Machek
  0 siblings, 0 replies; 29+ messages in thread
From: Pavel Machek @ 2020-09-30 17:00 UTC (permalink / raw)
  To: Marek Behún
  Cc: linux-leds, Dan Murphy, NeilBrown, Linus Walleij,
	H . Nikolaus Schaller, Tony Lindgren, Adam Ford, Viresh Kumar,
	Rob Herring, devicetree

[-- Attachment #1: Type: text/plain, Size: 491 bytes --]

On Sun 2020-09-20 00:15:39, Marek Behún wrote:
> 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 <marek.behun@nic.cz>

Not for me, dt maintainers should take this.

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 06/13] leds: tca6507: cosmetic change: use helper variable
  2020-09-19 22:15 ` [PATCH leds + devicetree 06/13] leds: tca6507: cosmetic change: use helper variable Marek Behún
@ 2020-09-30 17:01   ` Pavel Machek
  0 siblings, 0 replies; 29+ messages in thread
From: Pavel Machek @ 2020-09-30 17:01 UTC (permalink / raw)
  To: Marek Behún
  Cc: linux-leds, Dan Murphy, NeilBrown, Linus Walleij, H . Nikolaus Schaller

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

Hi!

> Use helper variable dev instead of always writing &client->dev.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

I applied series up to here, plus the "leds: tca6507: remove binding
comment". I got rejects on the others.

Best regards,
								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH leds + devicetree 11/13] leds: tca6507: fail on reg value conflict
  2020-09-19 22:15 ` [PATCH leds + devicetree 11/13] leds: tca6507: fail on reg value conflict Marek Behún
@ 2020-09-30 17:01   ` Pavel Machek
  0 siblings, 0 replies; 29+ messages in thread
From: Pavel Machek @ 2020-09-30 17:01 UTC (permalink / raw)
  To: Marek Behún
  Cc: linux-leds, Dan Murphy, NeilBrown, Linus Walleij, H . Nikolaus Schaller

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

Hi!

>  		if (fwnode_property_match_string(child, "compatible",
>  						 "gpio") >= 0) {
>  			gpio_bitmap |= BIT(reg);
>  			continue;
> +		} else {
> +			led_bitmap |= BIT(reg);
>  		}
>  

You have "continue" above, so you don't really need the else branch.

Thanks,
									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2020-09-30 17:01 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-19 22:15 [PATCH leds + devicetree 00/13] leds: tca6507 cleanup Marek Behún
2020-09-19 22:15 ` [PATCH leds + devicetree 01/13] leds: tca6507: Absorb platform data Marek Behún
2020-09-20 17:09   ` H. Nikolaus Schaller
2020-09-29 13:18   ` Linus Walleij
2020-09-19 22:15 ` [PATCH leds + devicetree 02/13] leds: tca6507: use fwnode API instead of OF Marek Behún
2020-09-19 22:31   ` Marek Behun
     [not found]   ` <BD25CCC6-343D-4624-9718-276B3C7C6510@goldelico.com>
2020-09-20 17:35     ` Marek Behun
2020-09-20 17:39       ` Marek Behun
2020-09-20 18:09         ` H. Nikolaus Schaller
2020-09-22 19:29           ` H. Nikolaus Schaller
2020-09-24 12:14             ` Pavel Machek
2020-09-19 22:15 ` [PATCH leds + devicetree 03/13] dt-bindings: leds: tca6507: convert to YAML Marek Behún
2020-09-29 16:56   ` Rob Herring
2020-09-30 16:59     ` Pavel Machek
2020-09-19 22:15 ` [PATCH leds + devicetree 04/13] ARM: dts: omap3: gta04: rename LED controlled subnodes Marek Behún
2020-09-30 17:00   ` Pavel Machek
2020-09-19 22:15 ` [PATCH leds + devicetree 05/13] leds: tca6507: do not set GPIO names Marek Behún
2020-09-19 22:15 ` [PATCH leds + devicetree 06/13] leds: tca6507: cosmetic change: use helper variable Marek Behún
2020-09-30 17:01   ` Pavel Machek
2020-09-19 22:15 ` [PATCH leds + devicetree 07/13] leds: tca6507: register LEDs and GPIOs immediately after parsing Marek Behún
2020-09-19 22:15 ` [PATCH leds + devicetree 08/13] leds: tca6507: remove binding comment Marek Behún
2020-09-19 22:15 ` [PATCH leds + devicetree 09/13] leds: tca6507: use devres for LED and gpiochip registration Marek Behún
2020-09-19 22:15 ` [PATCH leds + devicetree 10/13] leds: tca6507: let gpiolib set gpiochip's of_node Marek Behún
2020-09-19 22:15 ` [PATCH leds + devicetree 11/13] leds: tca6507: fail on reg value conflict Marek Behún
2020-09-30 17:01   ` Pavel Machek
2020-09-19 22:15 ` [PATCH leds + devicetree 12/13] leds: tca6507: set registers to zero before LEDs/GPIOs registration Marek Behún
2020-09-19 22:15 ` [PATCH leds + devicetree 13/13] leds: tca6507: use struct led_init_data when registering Marek Behún
2020-09-25  6:49   ` Jacek Anaszewski
2020-09-25 14:36     ` Marek Behun

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.