Skip to contentSkip to conversation

Updated lp8860 led driver

PATCH Superseded Dan Murphy 2 participants 14 messages Dec 5, 2017 – Dec 7, 2017

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Dan Murphy

author
#0 lore raw

v2 cover Updated lp8860 led driver

All

v2 - Added an initial patch to bring the DT binding up to standard prior to adding the changes for the label and triggers.

v1 Cover letter repeat below

After creating a new LED driver for the LM3692x device I went back to the LP8860 driver that I authored and found some updates that need to be applied.

First the way the LP8860 retrieved the label from the DT was incorrect as the label should have been from a child node as opposed to the parent. This is now fixed with this series.

Second, since that device can be used to as either a backlight driver or as a string agnostic driver a trigger to the backlight needed to be added.

Finally there are changes to the driver that need to be made as either unnoticed bugs or updates to the driver to align with the current LED framework. For instance moving to the devm LED class registration, destroying the mutex upon driver removal and removing the in driver dependency on CONFIG_OF and moving it to the Kconfig.

With these changes this should at least bring the driver into a better shape.

There are additional changes coming for this driver but I wanted to get the driver up to snuff before adding a feature to it.

Dan

Dan Murphy (6):
dt: bindings: lp8860: Update bindings for lp8860
dt: bindings: lp8860: Update DT label binding
leds: lp8860: Update the dt parsing for LED labeling
dt: bindings: lp8860: Add trigger binding to the lp8860
leds: lp8860: Add DT parsing to retrieve the trigger node
leds: lp8860: Various fixes to align with LED framework

 .../devicetree/bindings/leds/leds-lp8860.txt       | 39 ++++++++++++++-------
 drivers/leds/Kconfig                               |  2 +-
 drivers/leds/leds-lp8860.c                         | 40 ++++++++++++----------
 3 files changed, 49 insertions(+), 32 deletions(-)
Signature · 1 line
2.15.0.124.g7668cbc60
author
#1 lore raw

PATCH v2 1/6 dt: bindings: lp8860: Update bindings for lp8860

Update the lp8860 bindings to fix various issues
found. Add address-cells and size-cells, rename
enable-gpio to enable-gpios, update the node name
to the device name and indent the node example.

---

v2 - New patch

 .../devicetree/bindings/leds/leds-lp8860.txt       | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/leds/leds-lp8860.txt +16 -12
index aad38dd94d4b..1b2fab05ec6a 100644
@@ -6,24 +6,28 @@ current sinks that can be controlled by a PWM input
 signal, a SPI/I2C master, or both.
 
 Required properties:
-	- compatible:
+	- compatible :
 		"ti,lp8860"
-	- reg -  I2C slave address
-	- label - Used for naming LEDs
+	- reg : I2C slave address
+	- label : Used for naming LEDs
+	- #address-cells : 1
+	- #size-cells : 0
 
 Optional properties:
-	- enable-gpio - gpio pin to enable/disable the device.
-	- supply - "vled" - LED supply
+	- enable-gpios : gpio pin to enable/disable the device.
+	- supply : "vled" - LED supply
 
 Example:
 
-leds: leds@6 {
-	compatible = "ti,lp8860";
-	reg = <0x2d>;
-	label = "display_cluster";
-	enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
-	vled-supply = <&vbatt>;
-}
+	lp8860@2d {
+		compatible = "ti,lp8860";
+		#address-cells: 1
+		#size-cells: 0
+		reg = <0x2d>;
+		label = "display_cluster";
+		enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+		vled-supply = <&vbatt>;
+	}
 
 For more product information please see the link below:
 http://www.ti.com/product/lp8860-q1
Signature · 6 lines
2.15.0.124.g7668cbc60

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#2 lore raw

Re: [PATCH v2 1/6] dt: bindings: lp8860: Update bindings for lp8860

Quoted 25 lines · Dan Murphy

Update the lp8860 bindings to fix various issues found. Add address-cells and size-cells, rename enable-gpio to enable-gpios, update the node name to the device name and indent the node example.

---

v2 - New patch

 .../devicetree/bindings/leds/leds-lp8860.txt       | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1 -2
index aad38dd94d4b..1b2fab05ec6a 100644
@@ -6,24 +6,28 @@ current sinks that can be controlled by a PWM input
 signal, a SPI/I2C master, or both.
 
 Required properties:
-	- compatible:
+	- compatible :
 		"ti,lp8860"
-	- reg -  I2C slave address

Documentation/devicetree/bindings/leds/leds-lp8860.txt current sinks that can be controlled by a PWM input · line 17

Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +5 -3
-	- label - Used for naming LEDs
+	- reg : I2C slave address
+	- label : Used for naming LEDs
+	- #address-cells : 1
+	- #size-cells : 0
 
 Optional properties:
-	- enable-gpio - gpio pin to enable/disable the device.
-	- supply - "vled" - LED supply
+	- enable-gpios : gpio pin to enable/disable the device.

Needs to state active high or low.

Documentation/devicetree/bindings/leds/leds-lp8860.txt current sinks that can be controlled by a PWM input · line 18

Quoted 1 line
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1 -0
+	- supply : "vled" - LED supply

"vled-supply : ..."

Documentation/devicetree/bindings/leds/leds-lp8860.txt current sinks that can be controlled by a PWM input · line 22

Quoted 11 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1 -7
 Example:
 
-leds: leds@6 {
-	compatible = "ti,lp8860";
-	reg = <0x2d>;
-	label = "display_cluster";
-	enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
-	vled-supply = <&vbatt>;
-}
+	lp8860@2d {

leds@2d

There's not really any point in adding the indentation.

Documentation/devicetree/bindings/leds/leds-lp8860.txt current sinks that can be controlled by a PWM input · line 25

Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +3 -0
+		compatible = "ti,lp8860";
 
+		#address-cells: 1
+		#size-cells: 0

s/:/=/

Though, these aren't necessary without any child nodes. Is there more than 1 LED channel/driver?

Quoted 11 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +5 -0
+		reg = <0x2d>;
+		label = "display_cluster";
+		enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+		vled-supply = <&vbatt>;
+	}
 
 For more product information please see the link below:
 http://www.ti.com/product/lp8860-q1
Signature · 1 line
2.15.0.124.g7668cbc60
author
#3 lore raw

Re: [PATCH v2 1/6] dt: bindings: lp8860: Update bindings for lp8860

Rob

Thanks

Quoted 32 lines · Rob Herring
Quoted 31 lines · Dan Murphy

Update the lp8860 bindings to fix various issues found. Add address-cells and size-cells, rename enable-gpio to enable-gpios, update the node name to the device name and indent the node example.

---

v2 - New patch

 .../devicetree/bindings/leds/leds-lp8860.txt       | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/leds/leds-lp8860.txt +5 -3
index aad38dd94d4b..1b2fab05ec6a 100644
@@ -6,24 +6,28 @@ current sinks that can be controlled by a PWM input
 signal, a SPI/I2C master, or both.
 
 Required properties:
-	- compatible:
+	- compatible :
 		"ti,lp8860"
-	- reg -  I2C slave address
-	- label - Used for naming LEDs
+	- reg : I2C slave address
+	- label : Used for naming LEDs
+	- #address-cells : 1
+	- #size-cells : 0
 
Quoted 6 lines

Documentation/devicetree/bindings/leds/leds-lp8860.txt current sinks that can be controlled by a PWM input · line 17

Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1 -2
 Optional properties:
-	- enable-gpio - gpio pin to enable/disable the device.
-	- supply - "vled" - LED supply
+	- enable-gpios : gpio pin to enable/disable the device.

Needs to state active high or low.

Ack

Quoted 5 lines

Documentation/devicetree/bindings/leds/leds-lp8860.txt current sinks that can be controlled by a PWM input · line 18

Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1 -0
+	- supply : "vled" - LED supply

"vled-supply : ..."

Ack

Quoted 14 lines

Documentation/devicetree/bindings/leds/leds-lp8860.txt current sinks that can be controlled by a PWM input · line 22

Quoted 11 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1 -7
 Example:
 
-leds: leds@6 {
-	compatible = "ti,lp8860";
-	reg = <0x2d>;
-	label = "display_cluster";
-	enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
-	vled-supply = <&vbatt>;
-}
+	lp8860@2d {

leds@2d

Quoted 1 line

There's not really any point in adding the indentation.

OK I was just following convention of other child node LED bindings

I can remove the indents.

Quoted 11 lines

Documentation/devicetree/bindings/leds/leds-lp8860.txt current sinks that can be controlled by a PWM input · line 25

Quoted 5 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +3 -0
+		compatible = "ti,lp8860";
 
+		#address-cells: 1
+		#size-cells: 0

s/:/=/

Though, these aren't necessary without any child nodes. Is there more than 1 LED channel/driver?

Yes this device can be used to drive at least 4 different LED strings as well I will be adding this feature once I get this driver and binding cleaned up.

Dan

Quoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +5 -0
+		reg = <0x2d>;
+		label = "display_cluster";
+		enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+		vled-supply = <&vbatt>;
+	}
 
 For more product information please see the link below:
 http://www.ti.com/product/lp8860-q1
Signature · 1 line
2.15.0.124.g7668cbc60
Signature · 2 lines
------------------
Dan Murphy
maintainer
#4 lore raw

Re: [PATCH v2 1/6] dt: bindings: lp8860: Update bindings for lp8860

In reply to Dan Murphy
Quoted 20 lines · Dan Murphy

Update the lp8860 bindings to fix various issues found. Add address-cells and size-cells, rename enable-gpio to enable-gpios, update the node name to the device name and indent the node example.

---

v2 - New patch

 .../devicetree/bindings/leds/leds-lp8860.txt       | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/leds/leds-lp8860.txt +0 -0
index aad38dd94d4b..1b2fab05ec6a 100644
@@ -6,24 +6,28 @@ current sinks that can be controlled by a PWM input
 signal, a SPI/I2C master, or both.
 

Documentation/devicetree/bindings/leds/leds-lp8860.txt current sinks that can be controlled by a PWM input · line 14

Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +5 -3
 Required properties:
-	- compatible:
+	- compatible :
 		"ti,lp8860"
-	- reg -  I2C slave address
-	- label - Used for naming LEDs
+	- reg : I2C slave address
+	- label : Used for naming LEDs
+	- #address-cells : 1
+	- #size-cells : 0

This should be added in the next patch when you have child nodes.

Rob

author
#5 lore raw

Re: [PATCH v2 1/6] dt: bindings: lp8860: Update bindings for lp8860

Rob

Quoted 21 lines · Rob Herring
Quoted 20 lines · Dan Murphy

Update the lp8860 bindings to fix various issues found. Add address-cells and size-cells, rename enable-gpio to enable-gpios, update the node name to the device name and indent the node example.

---

v2 - New patch

 .../devicetree/bindings/leds/leds-lp8860.txt       | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/leds/leds-lp8860.txt +0 -0
index aad38dd94d4b..1b2fab05ec6a 100644
@@ -6,24 +6,28 @@ current sinks that can be controlled by a PWM input
 signal, a SPI/I2C master, or both.
 
Quoted 13 lines

Documentation/devicetree/bindings/leds/leds-lp8860.txt current sinks that can be controlled by a PWM input · line 14

Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +5 -3
 Required properties:
-	- compatible:
+	- compatible :
 		"ti,lp8860"
-	- reg -  I2C slave address
-	- label - Used for naming LEDs
+	- reg : I2C slave address
+	- label : Used for naming LEDs
+	- #address-cells : 1
+	- #size-cells : 0

This should be added in the next patch when you have child nodes.

Ack

Quoted 2 lines

Rob

Signature · 2 lines
------------------
Dan Murphy
author
#6 lore raw

PATCH v2 2/6 dt: bindings: lp8860: Update DT label binding

In reply to Dan Murphy

Update the lp8860 label binding to the LED
standard as documented in

Documentation/devicetree/bindings/leds/common.txt

---

v2 - Added reg to child node and made it required

 Documentation/devicetree/bindings/leds/leds-lp8860.txt | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/leds/leds-lp8860.txt +10 -2
index 1b2fab05ec6a..22b594d95162 100644
@@ -9,7 +9,6 @@ Required properties:
 	- compatible :
 		"ti,lp8860"
 	- reg : I2C slave address
-	- label : Used for naming LEDs
 	- #address-cells : 1
 	- #size-cells : 0
 
@@ -17,6 +16,12 @@ Optional properties:
 	- enable-gpios : gpio pin to enable/disable the device.
 	- supply : "vled" - LED supply
 
+Required child properties:
+	- reg : 0
+
+Optional child properties:
+	- label : see Documentation/devicetree/bindings/leds/common.txt
+
 Example:
 
 	lp8860@2d {
@@ -24,9 +29,12 @@ Example:
 		#address-cells: 1
 		#size-cells: 0
 		reg = <0x2d>;
-		label = "display_cluster";
 		enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
 		vled-supply = <&vbatt>;
+		display_cluster: display_cluster@0 {
+			reg=<0>;
+			label = "display_cluster";
+		};
 	}
 
 For more product information please see the link below:
Signature · 6 lines
2.15.0.124.g7668cbc60

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#7 lore raw

Re: [PATCH v2 2/6] dt: bindings: lp8860: Update DT label binding

Quoted 39 lines · Dan Murphy

Update the lp8860 label binding to the LED
standard as documented in

Documentation/devicetree/bindings/leds/common.txt

---

v2 - Added reg to child node and made it required

 Documentation/devicetree/bindings/leds/leds-lp8860.txt | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/leds/leds-lp8860.txt +6 -1
index 1b2fab05ec6a..22b594d95162 100644
@@ -9,7 +9,6 @@ Required properties:
 	- compatible :
 		"ti,lp8860"
 	- reg : I2C slave address
-	- label : Used for naming LEDs
 	- #address-cells : 1
 	- #size-cells : 0
 
@@ -17,6 +16,12 @@ Optional properties:
 	- enable-gpios : gpio pin to enable/disable the device.
 	- supply : "vled" - LED supply
 
+Required child properties:
+	- reg : 0
+
+Optional child properties:
+	- label : see Documentation/devicetree/bindings/leds/common.txt
+
 Example:
 
 	lp8860@2d {

Documentation/devicetree/bindings/leds/leds-lp8860.txt Example: · line 34

Quoted 7 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1 -1
@@ -24,9 +29,12 @@ Example:
 		#address-cells: 1
 		#size-cells: 0
 		reg = <0x2d>;
-		label = "display_cluster";
 		enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
 		vled-supply = <&vbatt>;
+		display_cluster: display_cluster@0 {

led@0 {

Do you really need a (dts) label here?

Documentation/devicetree/bindings/leds/leds-lp8860.txt Example: · line 35

Quoted 1 line
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1 -0
+			reg=<0>;

spaces around the '='.

Quoted 8 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +2 -0
+			label = "display_cluster";
+		};
 	}
 
 For more product information please see the link below:
Signature · 1 line
2.15.0.124.g7668cbc60
author
#8 lore raw

Re: [PATCH v2 2/6] dt: bindings: lp8860: Update DT label binding

Rob

Quoted 50 lines · Rob Herring
Quoted 39 lines · Dan Murphy

Update the lp8860 label binding to the LED
standard as documented in

Documentation/devicetree/bindings/leds/common.txt

---

v2 - Added reg to child node and made it required

 Documentation/devicetree/bindings/leds/leds-lp8860.txt | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/leds/leds-lp8860.txt +6 -1
index 1b2fab05ec6a..22b594d95162 100644
@@ -9,7 +9,6 @@ Required properties:
 	- compatible :
 		"ti,lp8860"
 	- reg : I2C slave address
-	- label : Used for naming LEDs
 	- #address-cells : 1
 	- #size-cells : 0
 
@@ -17,6 +16,12 @@ Optional properties:
 	- enable-gpios : gpio pin to enable/disable the device.
 	- supply : "vled" - LED supply
 
+Required child properties:
+	- reg : 0
+
+Optional child properties:
+	- label : see Documentation/devicetree/bindings/leds/common.txt
+
 Example:
 
 	lp8860@2d {

Documentation/devicetree/bindings/leds/leds-lp8860.txt Example: · line 34

Quoted 7 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1 -1
@@ -24,9 +29,12 @@ Example:
 		#address-cells: 1
 		#size-cells: 0
 		reg = <0x2d>;
-		label = "display_cluster";
 		enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
 		vled-supply = <&vbatt>;
+		display_cluster: display_cluster@0 {

led@0 {

Quoted 1 line

Do you really need a (dts) label here?

We will when I add LED string support.

Quoted 4 lines

Documentation/devicetree/bindings/leds/leds-lp8860.txt Example: · line 35

Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1 -0
+			reg=<0>;

spaces around the '='.

Ack

Quoted 9 lines
Quoted 9 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +2 -0
+			label = "display_cluster";
+		};
 	}
 
 For more product information please see the link below:
Signature · 1 line
2.15.0.124.g7668cbc60
Signature · 2 lines
------------------
Dan Murphy
author
#9 lore raw

PATCH v2 3/6 leds: lp8860: Update the dt parsing for LED labeling

In reply to Dan Murphy

Update the DT parsing for the label node so that
the label is retrieved from the device child as
opposed to being part of the parent.

This will align this driver with the LED
binding documentation

Documentation/devicetree/bindings/leds/common.txt

---

v2 - no changes

 drivers/leds/leds-lp8860.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/leds/leds-lp8860.c +12 -11
index 3e70775a2d54..13d6210cba85 100644
@@ -22,6 +22,7 @@
 #include <linux/of_gpio.h>
 #include <linux/gpio/consumer.h>
 #include <linux/slab.h>
+#include <uapi/linux/uleds.h>
 
 #define LP8860_DISP_CL1_BRT_MSB		0x00
 #define LP8860_DISP_CL1_BRT_LSB		0x01
@@ -86,8 +87,6 @@
 
 #define LP8860_CLEAR_FAULTS		0x01
 
-#define LP8860_DISP_LED_NAME		"display_cluster"
-
 /**
  * struct lp8860_led -
  * @lock - Lock for reading/writing the device
@@ -107,7 +106,7 @@ struct lp8860_led {
 	struct regmap *eeprom_regmap;
 	struct gpio_desc *enable_gpio;
 	struct regulator *regulator;
-	const char *label;
+	char label[LED_MAX_NAME_SIZE];
 };
 
 struct lp8860_eeprom_reg {
@@ -365,19 +364,21 @@ static int lp8860_probe(struct i2c_client *client,
 	int ret;
 	struct lp8860_led *led;
 	struct device_node *np = client->dev.of_node;
+	struct device_node *child_node;
+	const char *name;
 
 	led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL);
 	if (!led)
 		return -ENOMEM;
 
-	led->label = LP8860_DISP_LED_NAME;
-
-	if (client->dev.of_node) {
-		ret = of_property_read_string(np, "label", &led->label);
-		if (ret) {
-			dev_err(&client->dev, "Missing label in dt\n");
-			return -EINVAL;
-		}
+	for_each_available_child_of_node(np, child_node) {
+		ret = of_property_read_string(child_node, "label", &name);
+		if (!ret)
+		    snprintf(led->label, sizeof(led->label), "%s:%s",
+					np->name, name);
+		else
+		    snprintf(led->label, sizeof(led->label),
+			     "%s::display_cluster", np->name);
 	}
 
 	led->enable_gpio = devm_gpiod_get_optional(&client->dev,
Signature · 1 line
2.15.0.124.g7668cbc60
author
#10 lore raw

PATCH v2 4/6 dt: bindings: lp8860: Add trigger binding to the lp8860

In reply to Dan Murphy

Add a default trigger optional node to the child node. This will allow the driver to set the trigger for a backlight.

---

v2 - Moved binding changes to first patch in the series.

 Documentation/devicetree/bindings/leds/leds-lp8860.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/leds/leds-lp8860.txt +3 -0
index 22b594d95162..3452c9c10499 100644
@@ -21,6 +21,8 @@ Required child properties:
 
 Optional child properties:
 	- label : see Documentation/devicetree/bindings/leds/common.txt
+	- linux,default-trigger : (optional)
+	   see Documentation/devicetree/bindings/leds/common.txt
 
 Example:
 
@@ -34,6 +36,7 @@ Example:
 		display_cluster: display_cluster@0 {
 			reg=<0>;
 			label = "display_cluster";
+			linux,default-trigger = "backlight";
 		};
 	}
 
Signature · 6 lines
2.15.0.124.g7668cbc60

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#11 lore raw

Re: [PATCH v2 4/6] dt: bindings: lp8860: Add trigger binding to the lp8860

Quoted 16 lines · Dan Murphy

Add a default trigger optional node to the child node. This will allow the driver to set the trigger for a backlight.

---

v2 - Moved binding changes to first patch in the series.

 Documentation/devicetree/bindings/leds/leds-lp8860.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/leds/leds-lp8860.txt +0 -0
index 22b594d95162..3452c9c10499 100644

Documentation/devicetree/bindings/leds/leds-lp8860.txt Required child properties: · line 24

Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1 -0
@@ -21,6 +21,8 @@ Required child properties:
 
 Optional child properties:
 	- label : see Documentation/devicetree/bindings/leds/common.txt
+	- linux,default-trigger : (optional)

You already said this is optional.

Quoted 15 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +2 -0
+	   see Documentation/devicetree/bindings/leds/common.txt
 
 Example:
 
@@ -34,6 +36,7 @@ Example:
 		display_cluster: display_cluster@0 {
 			reg=<0>;
 			label = "display_cluster";
+			linux,default-trigger = "backlight";
 		};
 	}
 
Signature · 1 line
2.15.0.124.g7668cbc60
author
#12 lore raw

PATCH v2 5/6 leds: lp8860: Add DT parsing to retrieve the trigger node

In reply to Dan Murphy

Add the ability to parse the DT and set the default trigger mode for the LED.

---

v2 - no changes

 drivers/leds/leds-lp8860.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/leds/leds-lp8860.c +4 -0
index 13d6210cba85..4fed603ee728 100644
@@ -372,6 +372,10 @@ static int lp8860_probe(struct i2c_client *client,
 		return -ENOMEM;
 
 	for_each_available_child_of_node(np, child_node) {
+		led->led_dev.default_trigger = of_get_property(child_node,
+						    "linux,default-trigger",
+						    NULL);
+
 		ret = of_property_read_string(child_node, "label", &name);
 		if (!ret)
 		    snprintf(led->label, sizeof(led->label), "%s:%s",
Signature · 1 line
2.15.0.124.g7668cbc60
author
#13 lore raw

PATCH v2 6/6 leds: lp8860: Various fixes to align with LED framework

In reply to Dan Murphy

Update the driver to conform with the LED framework. Use devm_led_classdev_register
Destroy mutex on exit
Remove dependency on CONFIG_OF in the driver and move to the Kconfig
Update the MODULE_LICENSE to GPL v2
Remove setting of MAX brightness as the LED framework does this.

---

v2 - no changes

 drivers/leds/Kconfig       |  2 +-
 drivers/leds/leds-lp8860.c | 13 +++++--------
 2 files changed, 6 insertions(+), 9 deletions(-)
drivers/leds/Kconfig +1 -1
index 318a28fd58fe..ac4d9d8bf96b 100644
@@ -347,7 +347,7 @@ config LEDS_LP8788
 
 config LEDS_LP8860
 	tristate "LED support for the TI LP8860 4 channel LED driver"
-	depends on LEDS_CLASS && I2C
+	depends on LEDS_CLASS && I2C && OF
 	select REGMAP_I2C
 	help
 	  If you say yes here you get support for the TI LP8860 4 channel
drivers/leds/leds-lp8860.c +5 -8
index 4fed603ee728..e94041e0e693 100644
@@ -399,7 +399,6 @@ static int lp8860_probe(struct i2c_client *client,
 
 	led->client = client;
 	led->led_dev.name = led->label;
-	led->led_dev.max_brightness = LED_FULL;
 	led->led_dev.brightness_set_blocking = lp8860_brightness_set;
 
 	mutex_init(&led->lock);
@@ -426,7 +425,7 @@ static int lp8860_probe(struct i2c_client *client,
 	if (ret)
 		return ret;
 
-	ret = led_classdev_register(&client->dev, &led->led_dev);
+	ret = devm_led_classdev_register(&client->dev, &led->led_dev);
 	if (ret) {
 		dev_err(&client->dev, "led register err: %d\n", ret);
 		return ret;
@@ -440,8 +439,6 @@ static int lp8860_remove(struct i2c_client *client)
 	struct lp8860_led *led = i2c_get_clientdata(client);
 	int ret;
 
-	led_classdev_unregister(&led->led_dev);
-
 	if (led->enable_gpio)
 		gpiod_direction_output(led->enable_gpio, 0);
 
@@ -452,6 +449,8 @@ static int lp8860_remove(struct i2c_client *client)
 				"Failed to disable regulator\n");
 	}
 
+	mutex_destroy(&led->lock);
+
 	return 0;
 }
 
@@ -461,18 +460,16 @@ static const struct i2c_device_id lp8860_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, lp8860_id);
 
-#ifdef CONFIG_OF
 static const struct of_device_id of_lp8860_leds_match[] = {
 	{ .compatible = "ti,lp8860", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, of_lp8860_leds_match);
-#endif
 
 static struct i2c_driver lp8860_driver = {
 	.driver = {
 		.name	= "lp8860",
-		.of_match_table = of_match_ptr(of_lp8860_leds_match),
+		.of_match_table = of_lp8860_leds_match,
 	},
 	.probe		= lp8860_probe,
 	.remove		= lp8860_remove,
@@ -482,4 +479,4 @@ module_i2c_driver(lp8860_driver);
 
 MODULE_DESCRIPTION("Texas Instruments LP8860 LED driver");
 MODULE_AUTHOR("Dan Murphy <[email protected]>");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
Signature · 1 line
2.15.0.124.g7668cbc60