leds: Add new API to derive a LED name
Subsystems (2)
PATCH v6 1/6 leds: Add new API to derive a LED name
Create an API that is called to derive the LED name from either the DT label in the child node or if that does not exist from the parent node name and an alternate label that is passed in.
---
v6 - New patch to add the api to generate a LED label
drivers/leds/led-class.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/leds.h | 6 ++++++ 2 files changed, 40 insertions(+)
drivers/leds/led-class.c +34 -0
@@ -17,6 +17,7 @@#include <linux/leds.h> #include <linux/list.h> #include <linux/module.h> +#include <linux/of.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/timer.h>
@@ -243,6 +244,39 @@ static int led_classdev_next_name(const char *init_name, char *name,return i; } +/** +* of_led_compose_name - derive the LED name based on DT or alternate name. +* +* @parent: parent of LED device +* @child: child node of LED device +* @alt_name: an alternate name if the label node is not found +* @len: length of the alt_name +* @led_name: derived name from either DT label or alt_name +*/ +void of_led_compose_name (struct device_node *parent, +struct device_node *child, +const char *alt_name, +size_t len, +char *led_name) +{ +int ret; +int length; +const char *name; + +if (len ==0 || alt_name ==NULL ) +return ; + + ret =of_property_read_string (child,"label" , &name); +if (!ret) { +strlcpy (led_name, name,sizeof (led_name)); + }else { + length = len +strlen (parent->name) +1 ; +snprintf (led_name, len,"%s:%s" , parent->name, alt_name); + } + +} +EXPORT_SYMBOL_GPL (of_led_compose_name); +/** * of_led_classdev_register - register a new object of led_classdev class. *
include/linux/leds.h +6 -0
@@ -123,6 +123,12 @@ struct led_classdev {struct mutex led_access; }; +extern void of_led_compose_name (struct device_node *parent, +struct device_node *child, +const char *alt_name, +size_t len, +char *led_name); +extern int of_led_classdev_register (struct device *parent,struct device_node *np,struct led_classdev *led_cdev);
Signature · 1 line
2.15.0.124.g7668cbc60
PATCH v6 2/6 dt: bindings: lm3692x: Add bindings for lm3692x LED driver
This adds the devicetree bindings for the LM3692x
I2C LED string driver.
--- .../devicetree/bindings/leds/leds-lm3692x.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3692x.txt
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +39 -0
@@ -0,0 +1,39 @@ +* Texas Instruments - LM3692x Highly Efficient White LED Driver + +The LM3692x is an ultra-compact, highly efficient, +white-LED driver designed for LCD display backlighting. + +The main difference between the LM36922 and LM36923 is the number of +LED strings it supports. The LM36922 supports two strings while the LM36923 +supports three strings. + +Required properties: + - compatible: + "ti,lm36922" + "ti,lm36923" + - reg : I2C slave address + +Optional properties: + - label : see Documentation/devicetree/bindings/leds/common.txt + - enable-gpios : gpio pin to enable/disable the device. + - vled-supply : LED supply + - linux,default-trigger : (optional) + see Documentation/devicetree/bindings/leds/common.txt + +Example: + +lm3692x@36 { + compatible = "ti,lm3692x"; + reg = <0x36>; + + enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>; + vled-supply = <&vbatt>; + + backlight: backlight@0 { + label = "backlight_cluster"; + linux,default-trigger = "backlight"; + }; +} + +For more product information please see the link below: +http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf
Signature · 1 line
2.15.0.124.g7668cbc60
PATCH v6 3/6 leds: lm3692x: Introduce LM3692x dual string driver
In reply to Dan MurphyIntroducing the LM3692x Dual-String white LED driver.
Data sheet is located
http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf
---
v6 - Use new LED API to compose LED label as opposed to creating it. -
https://patchwork.kernel.org/patch/10085565/
v5 - Added OF dependency in Kconfig, added extra fault flag read to ensure that
if a fault exists and it is not a artifact, fixed LED class label to be derived from either the DT child "label" node or create a label based on parent_node_name:led color:trigger, removed ifdef for CONFIG_OF and removed of_match_ptr - https://patchwork.kernel.org/patch/10081073/
v4 - Converted to devm led class register, changed MODULE_LICENSE to GPL v2,
set the led name based on child node name or label entry, removed fault and returned read_buf for fault checking, added mutex_destroy to remove function,
and removed LED_FULL - https://patchwork.kernel.org/patch/10060109/
v3 - Add missing Makefile and Kconfig from v1 and v2 - https://patchwork.kernel.org/patch/10060075/
v2 - Added data sheet link, fixed linuxdoc format, returned on failure in init routine, return on fault_check failure, updated brightness calculation and
fixed capitalization issue - https://patchwork.kernel.org/patch/10056675/
drivers/leds/Kconfig | 7 + drivers/leds/Makefile | 1 + drivers/leds/leds-lm3692x.c | 388 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 396 insertions(+) create mode 100644 drivers/leds/leds-lm3692x.c
drivers/leds/Kconfig +7 -0
@@ -137,6 +137,13 @@ config LEDS_LM3642 converter plus 1.5A constant current driver for a high-current white LED. +config LEDS_LM3692X + tristate "LED support for LM3692x Chips" + depends on LEDS_CLASS && I2C && OF + select REGMAP_I2C + help + This option enables support for the TI LM3692x family + of white LED string drivers used for backlighting. config LEDS_LOCOMO tristate "LED Support for Locomo device"
drivers/leds/Makefile +1 -0
@@ -74,6 +74,7 @@ obj-$(CONFIG_LEDS_PM8058) += leds-pm8058.o obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o +obj-$(CONFIG_LEDS_LM3692X) += leds-lm3692x.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
drivers/leds/leds-lm3692x.c new file +388 -0
388 lines not on this page · raw message
Signature · 1 line
2.15.0.124.g7668cbc60
PATCH v6 4/6 dt: bindings: lp8860: Update the bindings to the standard
In reply to Dan MurphyUpdate the lp8860 dt binding to the LED standard where the LED should have a child node and also adding a LED trigger entry.
---
v6 - New patch to fix binding documentation
Documentation/devicetree/bindings/leds/leds-lp8860.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/leds/leds-lp8860.txt +11 -4
@@ -12,17 +12,24 @@ Required properties: - label - Used for naming LEDs Optional properties: - - enable-gpio - gpio pin to enable/disable the device. - - supply - "vled" - LED supply + - enable-gpios : gpio pin to enable/disable the device. + - vled-supply : LED supply + - label : see Documentation/devicetree/bindings/leds/common.txt + - linux,default-trigger : (optional) + see Documentation/devicetree/bindings/leds/common.txt Example: -leds: leds@6 { +lp8860@2d { compatible = "ti,lp8860"; reg = <0x2d>; - label = "display_cluster"; enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>; vled-supply = <&vbatt>; + + backlight: backlight@0 { + label = "backlight_cluster"; + linux,default-trigger = "backlight"; + }; } For more product information please see the link below:
Signature · 1 line
2.15.0.124.g7668cbc60
Re: [PATCH v6 4/6] dt: bindings: lp8860: Update the bindings to the standard
Dan,
Quoted 30 lines · Dan Murphy
Update the lp8860 dt binding to the LED standard where the LED should have a child node and also adding a LED trigger entry.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to fix binding documentation
Documentation/devicetree/bindings/leds/leds-lp8860.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/leds/leds-lp8860.txt +5
-2@@ -12,17 +12,24 @@ Required properties: - label - Used for naming LEDs Optional properties: - - enable-gpio - gpio pin to enable/disable the device. - - supply - "vled" - LED supply + - enable-gpios : gpio pin to enable/disable the device. + - vled-supply : LED supply + - label : see Documentation/devicetree/bindings/leds/common.txt + - linux,default-trigger : (optional) + see Documentation/devicetree/bindings/leds/common.txt Example:
Documentation/devicetree/bindings/leds/leds-lp8860.txt Required properties: · line 30
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +4
-2-leds: leds@6 { +lp8860@2d { compatible = "ti,lp8860"; reg = <0x2d>; - label = "display_cluster"; enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>; vled-supply = <&vbatt>; + + backlight: backlight@0 { + label = "backlight_cluster";
You'll need to change this to:
label = "white:backlight_cluster"
Please always cc your patches with DT bindings to [email protected] and related maintainers.
Quoted 6 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +2
-0+ linux,default-trigger = "backlight"; + }; } For more product information please see the link below:
Signature · 6 lines
Best regards, Jacek Anaszewski -- 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
Rob Herring
maintainerRe: [PATCH v6 4/6] dt: bindings: lp8860: Update the bindings to the standard
Quoted 31 lines · Jacek Anaszewski
Dan,
Quoted 28 lines · Dan Murphy
Update the lp8860 dt binding to the LED standard where the LED should have a child node and also adding a LED trigger entry.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to fix binding documentation
Documentation/devicetree/bindings/leds/leds-lp8860.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/leds/leds-lp8860.txt +5
-2@@ -12,17 +12,24 @@ Required properties: - label - Used for naming LEDs Optional properties: - - enable-gpio - gpio pin to enable/disable the device. - - supply - "vled" - LED supply + - enable-gpios : gpio pin to enable/disable the device. + - vled-supply : LED supply + - label : see Documentation/devicetree/bindings/leds/common.txt + - linux,default-trigger : (optional) + see Documentation/devicetree/bindings/leds/common.txt
Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt Required properties: · line 23
Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1
-1Example: -leds: leds@6 { +lp8860@2d {
leds@2d
Quoted 7 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt Required properties: · line 29
Quoted 7 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +2
-1compatible = "ti,lp8860"; reg = <0x2d>; - label = "display_cluster"; enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>; vled-supply = <&vbatt>; + + backlight: backlight@0 {
unit-address requires a 'reg' property. Building your dts files with W=1 will tell you this.
Quoted 19 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt Required properties: · line 30
Quoted 1 line
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1
-0+ label = "backlight_cluster";You'll need to change this to:
label = "white:backlight_cluster"
Please always cc your patches with DT bindings to [email protected] and related maintainers.
Quoted 6 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +2
-0+ linux,default-trigger = "backlight"; + }; } For more product information please see the link below:Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v6 4/6] dt: bindings: lp8860: Update the bindings to the standard
Rob
Quoted 32 lines · Rob Herring
Quoted 31 lines · Jacek Anaszewski
Dan,
Quoted 28 lines · Dan Murphy
Update the lp8860 dt binding to the LED standard where the LED should have a child node and also adding a LED trigger entry.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to fix binding documentation
Documentation/devicetree/bindings/leds/leds-lp8860.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/leds/leds-lp8860.txt +5
-2@@ -12,17 +12,24 @@ Required properties: - label - Used for naming LEDs Optional properties: - - enable-gpio - gpio pin to enable/disable the device. - - supply - "vled" - LED supply + - enable-gpios : gpio pin to enable/disable the device. + - vled-supply : LED supply + - label : see Documentation/devicetree/bindings/leds/common.txt + - linux,default-trigger : (optional) + see Documentation/devicetree/bindings/leds/common.txt
Quoted 6 lines
Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt Required properties: · line 23
Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1
-1Example: -leds: leds@6 { +lp8860@2d {leds@2d
Ack
Quoted 11 lines
Quoted 8 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt Required properties: · line 29
Quoted 8 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +2
-1compatible = "ti,lp8860"; reg = <0x2d>; - label = "display_cluster"; enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>; vled-supply = <&vbatt>; + + backlight: backlight@0 {unit-address requires a 'reg' property. Building your dts files with W=1 will tell you this.
I will add this. There is so much noise when enabling this option on the dts I missed the warning.
Dan
<snip>
Signature · 6 lines
------------------ Dan Murphy -- 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
Re: [PATCH v6 4/6] dt: bindings: lp8860: Update the bindings to the standard
In reply to Dan MurphyHi Dan,
Thanks for the patch.
Quoted 17 lines · Dan Murphy
Update the lp8860 dt binding to the LED standard where the LED should have a child node and also adding a LED trigger entry.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to fix binding documentation
Documentation/devicetree/bindings/leds/leds-lp8860.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/leds/leds-lp8860.txt +0
-0
Documentation/devicetree/bindings/leds/leds-lp8860.txt Required properties: · line 19
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +5
-2@@ -12,17 +12,24 @@ Required properties: - label - Used for naming LEDs Optional properties: - - enable-gpio - gpio pin to enable/disable the device. - - supply - "vled" - LED supply + - enable-gpios : gpio pin to enable/disable the device. + - vled-supply : LED supply + - label : see Documentation/devicetree/bindings/leds/common.txt + - linux,default-trigger : (optional) + see Documentation/devicetree/bindings/leds/common.txt
Related driver doesn't parse this DT property AFAICS.
Documentation/devicetree/bindings/leds/leds-lp8860.txt Required properties: · line 26
Quoted 8 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1
-2Example: -leds: leds@6 { +lp8860@2d { compatible = "ti,lp8860"; reg = <0x2d>; - label = "display_cluster"; enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
s/gpio/gpios/
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +5
-0vled-supply = <&vbatt>; + + backlight: backlight@0 { + label = "backlight_cluster"; + linux,default-trigger = "backlight"; + }; } For more product information please see the link below:
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v6 4/6] dt: bindings: lp8860: Update the bindings to the standard
Quoted 24 lines · Jacek Anaszewski
Hi Dan,
Thanks for the patch.
Quoted 19 lines · Dan Murphy
Update the lp8860 dt binding to the LED standard where the LED should have a child node and also adding a LED trigger entry.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to fix binding documentation
Documentation/devicetree/bindings/leds/leds-lp8860.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/leds/leds-lp8860.txt +0
-0@@ -12,17 +12,24 @@ Required properties: - label - Used for naming LEDs
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt Required properties: · line 19
Quoted 8 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +5
-2Optional properties: - - enable-gpio - gpio pin to enable/disable the device. - - supply - "vled" - LED supply + - enable-gpios : gpio pin to enable/disable the device. + - vled-supply : LED supply + - label : see Documentation/devicetree/bindings/leds/common.txt + - linux,default-trigger : (optional) + see Documentation/devicetree/bindings/leds/common.txtRelated driver doesn't parse this DT property AFAICS.
Ah, I missed that you're adding it in 5/6.
Quoted 23 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt Required properties: · line 26
Quoted 9 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +1
-2Example: -leds: leds@6 { +lp8860@2d { compatible = "ti,lp8860"; reg = <0x2d>; - label = "display_cluster"; enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;s/gpio/gpios/
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-lp8860.txt +5
-0vled-supply = <&vbatt>; + + backlight: backlight@0 { + label = "backlight_cluster"; + linux,default-trigger = "backlight"; + }; } For more product information please see the link below:
PATCH v6 5/6 leds: lp8860: Update the LED label generation
In reply to Dan MurphyFix the LED label generation for the LP8860 to conform with the
Documentation/devicetree/bindings/leds/common.txt
document indicating the LED label should be part of a child node to the device parent. If no label is in the child node then the LED label is created based on the parent node name and the alternate name passed in.
---
v6 - New patch to use the new LED class API
drivers/leds/leds-lp8860.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
drivers/leds/leds-lp8860.c +15 -12
@@ -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 {
@@ -318,7 +317,7 @@ static const struct regmap_config lp8860_regmap_config = { .max_register = LP8860_EEPROM_UNLOCK, .reg_defaults = lp8860_reg_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_reg_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE, };static const struct reg_default lp8860_eeprom_defs[] = {
@@ -356,7 +355,7 @@ static const struct regmap_config lp8860_eeprom_regmap_config = { .max_register = LP8860_EEPROM_REG_24, .reg_defaults = lp8860_eeprom_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_eeprom_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE, }; static int lp8860_probe(struct i2c_client *client,
@@ -365,19 +364,23 @@ 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; + +if (!client->dev.of_node) +return -ENODEV ; led =devm_kzalloc (&client->dev,sizeof (*led),GFP_KERNEL );if (!led)return -ENOMEM ; - led->label =LP8860_DISP_LED_NAME ; +for_each_available_child_of_node (np, child_node) { + led->led_dev.default_trigger =of_get_property (child_node, +"linux,default-trigger" , +NULL ); -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 ; - } +of_led_compose_name (np, child_node,"white:backlight" , +sizeof ("white:backlight" ), + led->label); } led->enable_gpio = devm_gpiod_get_optional(&client->dev,
Signature · 1 line
2.15.0.124.g7668cbc60
Re: [PATCH v6 5/6] leds: lp8860: Update the LED label generation
Quoted 67 lines · Dan Murphy
Fix the LED label generation for the LP8860 to conform with the
Documentation/devicetree/bindings/leds/common.txtdocument indicating the LED label should be part of a child node to the device parent. If no label is in the child node then the LED label is created based on the parent node name and the alternate name passed in.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to use the new LED class API
drivers/leds/leds-lp8860.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)drivers/leds/leds-lp8860.c +4
-5@@ -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 {@@ -318,7 +317,7 @@ static const struct regmap_config lp8860_regmap_config = { .max_register = LP8860_EEPROM_UNLOCK, .reg_defaults = lp8860_reg_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_reg_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE, };static const struct reg_default lp8860_eeprom_defs[] = {@@ -356,7 +355,7 @@ static const struct regmap_config lp8860_eeprom_regmap_config = { .max_register = LP8860_EEPROM_REG_24, .reg_defaults = lp8860_eeprom_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_eeprom_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE, }; static int lp8860_probe(struct i2c_client *client,
drivers/leds/leds-lp8860.c static int lp8860_probe(struct i2c_client *client, · line 370
Quoted 7 lines
drivers/leds/leds-lp8860.c +4
-0@@ -365,19 +364,23 @@ 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; + +if (!client->dev.of_node) +return -ENODEV ;
This is actually a bug in the driver. I can submit this independently or keep this here
drivers/leds/leds-lp8860.c static int lp8860_probe(struct i2c_client *client, · line 379
Quoted 10 lines
drivers/leds/leds-lp8860.c +4
-1led =devm_kzalloc (&client->dev,sizeof (*led),GFP_KERNEL );if (!led)return -ENOMEM ; - led->label =LP8860_DISP_LED_NAME ; +for_each_available_child_of_node (np, child_node) { + led->led_dev.default_trigger =of_get_property (child_node, +"linux,default-trigger" , +NULL );
Not sure if you want me to pull this out into a different patch or just add it to the commit message
Quoted 14 lines
drivers/leds/leds-lp8860.c +3
-6-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 ; - } +of_led_compose_name (np, child_node,"white:backlight" , +sizeof ("white:backlight" ), + led->label); } led->enable_gpio = devm_gpiod_get_optional(&client->dev,
Signature · 2 lines
------------------ Dan Murphy
Re: [PATCH v6 5/6] leds: lp8860: Update the LED label generation
Dan,
Quoted 83 lines · Dan Murphy
Quoted 67 lines · Dan Murphy
Fix the LED label generation for the LP8860 to conform with the
Documentation/devicetree/bindings/leds/common.txtdocument indicating the LED label should be part of a child node to the device parent. If no label is in the child node then the LED label is created based on the parent node name and the alternate name passed in.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to use the new LED class API
drivers/leds/leds-lp8860.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)drivers/leds/leds-lp8860.c +4
-5@@ -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 {@@ -318,7 +317,7 @@ static const struct regmap_config lp8860_regmap_config = { .max_register = LP8860_EEPROM_UNLOCK, .reg_defaults = lp8860_reg_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_reg_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE, };static const struct reg_default lp8860_eeprom_defs[] = {@@ -356,7 +355,7 @@ static const struct regmap_config lp8860_eeprom_regmap_config = { .max_register = LP8860_EEPROM_REG_24, .reg_defaults = lp8860_eeprom_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_eeprom_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE, }; static int lp8860_probe(struct i2c_client *client,drivers/leds/leds-lp8860.c static int lp8860_probe(struct i2c_client *client, · line 370
Quoted 7 lines
drivers/leds/leds-lp8860.c +4
-0@@ -365,19 +364,23 @@ 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; + +if (!client->dev.of_node) +return -ENODEV ;This is actually a bug in the driver. I can submit this independently or keep this here
Quoted 5 lines
drivers/leds/leds-lp8860.c +0
-0led =devm_kzalloc (&client->dev,sizeof (*led),GFP_KERNEL );if (!led)return -ENOMEM ;
Quoted 8 lines
drivers/leds/leds-lp8860.c static int lp8860_probe(struct i2c_client *client, · line 379
Quoted 5 lines
drivers/leds/leds-lp8860.c +4
-1- led->label =LP8860_DISP_LED_NAME ; +for_each_available_child_of_node (np, child_node) { + led->led_dev.default_trigger =of_get_property (child_node, +"linux,default-trigger" , +NULL );Not sure if you want me to pull this out into a different patch or just add it to the commit message
Yes, it would be nice. Also related change in DT bindings should be placed in the same patch.
Quoted 16 lines
Quoted 14 lines
drivers/leds/leds-lp8860.c +3
-6-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 ; - } +of_led_compose_name (np, child_node,"white:backlight" , +sizeof ("white:backlight" ), + led->label); } led->enable_gpio = devm_gpiod_get_optional(&client->dev,
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v6 5/6] leds: lp8860: Update the LED label generation
In reply to Dan MurphyDan,
Quoted 49 lines · Dan Murphy
Fix the LED label generation for the LP8860 to conform with the
Documentation/devicetree/bindings/leds/common.txtdocument indicating the LED label should be part of a child node to the device parent. If no label is in the child node then the LED label is created based on the parent node name and the alternate name passed in.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to use the new LED class API
drivers/leds/leds-lp8860.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)drivers/leds/leds-lp8860.c +2
-3@@ -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 {
drivers/leds/leds-lp8860.c static const struct regmap_config lp8860_regmap_config = { · line 320
Quoted 5 lines
drivers/leds/leds-lp8860.c +1
-1@@ -318,7 +317,7 @@ static const struct regmap_config lp8860_regmap_config = { .max_register = LP8860_EEPROM_UNLOCK, .reg_defaults = lp8860_reg_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_reg_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE,
This seems to be an unrelated change.
Please split it to the separate patch and explain its merit.
Quoted 30 lines
drivers/leds/leds-lp8860.c +9
-2};static const struct reg_default lp8860_eeprom_defs[] = {@@ -356,7 +355,7 @@ static const struct regmap_config lp8860_eeprom_regmap_config = { .max_register = LP8860_EEPROM_REG_24, .reg_defaults = lp8860_eeprom_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_eeprom_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE, }; static int lp8860_probe(struct i2c_client *client,@@ -365,19 +364,23 @@ 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; + +if (!client->dev.of_node) +return -ENODEV ; led =devm_kzalloc (&client->dev,sizeof (*led),GFP_KERNEL );if (!led)return -ENOMEM ; - led->label =LP8860_DISP_LED_NAME ; +for_each_available_child_of_node (np, child_node) { + led->led_dev.default_trigger =of_get_property (child_node, +"linux,default-trigger" , +NULL );
drivers/leds/leds-lp8860.c static int lp8860_probe(struct i2c_client *client, · line 383
Quoted 10 lines
drivers/leds/leds-lp8860.c +3
-6-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 ; - } +of_led_compose_name (np, child_node,"white:backlight" , +sizeof ("white:backlight" ), + led->label);
Let's skip it for now.
Please also CC driver author always when you're modifying it.
Quoted 4 lines
drivers/leds/leds-lp8860.c +0
-0} led->enable_gpio = devm_gpiod_get_optional(&client->dev,
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v6 5/6] leds: lp8860: Update the LED label generation
Jacek
Quoted 50 lines · Jacek Anaszewski
Dan,
Quoted 47 lines · Dan Murphy
Fix the LED label generation for the LP8860 to conform with the
Documentation/devicetree/bindings/leds/common.txtdocument indicating the LED label should be part of a child node to the device parent. If no label is in the child node then the LED label is created based on the parent node name and the alternate name passed in.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to use the new LED class API
drivers/leds/leds-lp8860.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)drivers/leds/leds-lp8860.c +2
-3@@ -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 ]; };
Quoted 10 lines
drivers/leds/leds-lp8860.c static const struct regmap_config lp8860_regmap_config = { · line 320
Quoted 7 lines
drivers/leds/leds-lp8860.c +1
-1struct lp8860_eeprom_reg {@@ -318,7 +317,7 @@ static const struct regmap_config lp8860_regmap_config = { .max_register = LP8860_EEPROM_UNLOCK, .reg_defaults = lp8860_reg_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_reg_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE,This seems to be an unrelated change.
Please split it to the separate patch and explain its merit.
ACK. It will be a separate patch
Quoted 32 lines
Quoted 32 lines
drivers/leds/leds-lp8860.c +9
-2};static const struct reg_default lp8860_eeprom_defs[] = {@@ -356,7 +355,7 @@ static const struct regmap_config lp8860_eeprom_regmap_config = { .max_register = LP8860_EEPROM_REG_24, .reg_defaults = lp8860_eeprom_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_eeprom_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE, }; static int lp8860_probe(struct i2c_client *client,@@ -365,19 +364,23 @@ 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; + +if (!client->dev.of_node) +return -ENODEV ; led =devm_kzalloc (&client->dev,sizeof (*led),GFP_KERNEL );if (!led)return -ENOMEM ; - led->label =LP8860_DISP_LED_NAME ; +for_each_available_child_of_node (np, child_node) { + led->led_dev.default_trigger =of_get_property (child_node, +"linux,default-trigger" , +NULL );
Quoted 11 lines
drivers/leds/leds-lp8860.c static int lp8860_probe(struct i2c_client *client, · line 383
Quoted 9 lines
drivers/leds/leds-lp8860.c +3
-6-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 ; - } +of_led_compose_name (np, child_node,"white:backlight" , +sizeof ("white:backlight" ), + led->label);Let's skip it for now.
I will make the same change here as I do for the lm3692x driver.
Quoted 2 lines
Please also CC driver author always when you're modifying it.
The author was on the email.
It is me. ;)
MODULE_AUTHOR("Dan Murphy <[email protected]>");
Dan
Signature · 2 lines
------------------ Dan Murphy
Re: [PATCH v6 5/6] leds: lp8860: Update the LED label generation
Dan,
Quoted 113 lines · Dan Murphy
Jacek
Quoted 50 lines · Jacek Anaszewski
Dan,
Quoted 47 lines · Dan Murphy
Fix the LED label generation for the LP8860 to conform with the
Documentation/devicetree/bindings/leds/common.txtdocument indicating the LED label should be part of a child node to the device parent. If no label is in the child node then the LED label is created based on the parent node name and the alternate name passed in.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to use the new LED class API
drivers/leds/leds-lp8860.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)drivers/leds/leds-lp8860.c +2
-3@@ -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 ]; };Quoted 10 lines
drivers/leds/leds-lp8860.c static const struct regmap_config lp8860_regmap_config = { · line 320
Quoted 7 lines
drivers/leds/leds-lp8860.c +1
-1struct lp8860_eeprom_reg {@@ -318,7 +317,7 @@ static const struct regmap_config lp8860_regmap_config = { .max_register = LP8860_EEPROM_UNLOCK, .reg_defaults = lp8860_reg_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_reg_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE,This seems to be an unrelated change.
Please split it to the separate patch and explain its merit.ACK. It will be a separate patch
Quoted 32 lines
Quoted 32 lines
drivers/leds/leds-lp8860.c +9
-2};static const struct reg_default lp8860_eeprom_defs[] = {@@ -356,7 +355,7 @@ static const struct regmap_config lp8860_eeprom_regmap_config = { .max_register = LP8860_EEPROM_REG_24, .reg_defaults = lp8860_eeprom_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_eeprom_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE, }; static int lp8860_probe(struct i2c_client *client,@@ -365,19 +364,23 @@ 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; + +if (!client->dev.of_node) +return -ENODEV ; led =devm_kzalloc (&client->dev,sizeof (*led),GFP_KERNEL );if (!led)return -ENOMEM ; - led->label =LP8860_DISP_LED_NAME ; +for_each_available_child_of_node (np, child_node) { + led->led_dev.default_trigger =of_get_property (child_node, +"linux,default-trigger" , +NULL );Quoted 11 lines
drivers/leds/leds-lp8860.c static int lp8860_probe(struct i2c_client *client, · line 383
Quoted 9 lines
drivers/leds/leds-lp8860.c +3
-6-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 ; - } +of_led_compose_name (np, child_node,"white:backlight" , +sizeof ("white:backlight" ), + led->label);Let's skip it for now.
I will make the same change here as I do for the lm3692x driver.
Quoted 1 line
Quoted 7 lines
Quoted 1 line
Please also CC driver author always when you're modifying it.
The author was on the email.
It is me. ;)
MODULE_AUTHOR("Dan Murphy <[email protected]>");
OK, but the author of the driver touched by the patch 6/6 is different :-)
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v6 5/6] leds: lp8860: Update the LED label generation
Jacek
Quoted 120 lines · Jacek Anaszewski
Dan,
Quoted 117 lines · Dan Murphy
Jacek
Quoted 50 lines · Jacek Anaszewski
Dan,
Quoted 47 lines · Dan Murphy
Fix the LED label generation for the LP8860 to conform with the
Documentation/devicetree/bindings/leds/common.txtdocument indicating the LED label should be part of a child node to the device parent. If no label is in the child node then the LED label is created based on the parent node name and the alternate name passed in.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to use the new LED class API
drivers/leds/leds-lp8860.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)drivers/leds/leds-lp8860.c +2
-3@@ -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 ]; };Quoted 10 lines
drivers/leds/leds-lp8860.c static const struct regmap_config lp8860_regmap_config = { · line 320
Quoted 7 lines
drivers/leds/leds-lp8860.c +1
-1struct lp8860_eeprom_reg {@@ -318,7 +317,7 @@ static const struct regmap_config lp8860_regmap_config = { .max_register = LP8860_EEPROM_UNLOCK, .reg_defaults = lp8860_reg_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_reg_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE,This seems to be an unrelated change.
Please split it to the separate patch and explain its merit.ACK. It will be a separate patch
Quoted 32 lines
Quoted 32 lines
drivers/leds/leds-lp8860.c +9
-2};static const struct reg_default lp8860_eeprom_defs[] = {@@ -356,7 +355,7 @@ static const struct regmap_config lp8860_eeprom_regmap_config = { .max_register = LP8860_EEPROM_REG_24, .reg_defaults = lp8860_eeprom_defs, .num_reg_defaults = ARRAY_SIZE(lp8860_eeprom_defs), - .cache_type = REGCACHE_NONE, + .cache_type = REGCACHE_RBTREE, }; static int lp8860_probe(struct i2c_client *client,@@ -365,19 +364,23 @@ 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; + +if (!client->dev.of_node) +return -ENODEV ; led =devm_kzalloc (&client->dev,sizeof (*led),GFP_KERNEL );if (!led)return -ENOMEM ; - led->label =LP8860_DISP_LED_NAME ; +for_each_available_child_of_node (np, child_node) { + led->led_dev.default_trigger =of_get_property (child_node, +"linux,default-trigger" , +NULL );Quoted 11 lines
drivers/leds/leds-lp8860.c static int lp8860_probe(struct i2c_client *client, · line 383
Quoted 9 lines
drivers/leds/leds-lp8860.c +3
-6-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 ; - } +of_led_compose_name (np, child_node,"white:backlight" , +sizeof ("white:backlight" ), + led->label);Let's skip it for now.
I will make the same change here as I do for the lm3692x driver.
Quoted 2 lines
Please also CC driver author always when you're modifying it.
The author was on the email.
Quoted 8 lines
Quoted 3 lines
It is me. ;)
MODULE_AUTHOR("Dan Murphy <[email protected]>");OK, but the author of the driver touched by the patch 6/6 is different :-)
True. This patch was dropped in v7.
Dan
Signature · 2 lines
------------------ Dan Murphy
PATCH v6 6/6 leds: as3645a: Update the LED label generation
In reply to Dan MurphyUpdate the LED label creationg to call theof_led_compose_name api to generate a label.
---
v6 - New patch to use the new LED class API
drivers/leds/leds-as3645a.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
drivers/leds/leds-as3645a.c +9 -15
@@ -27,6 +27,7 @@#include <linux/mutex.h> #include <linux/of.h> #include <linux/slab.h> +#include <uapi/linux/uleds.h> #include <media/v4l2-flash-led-class.h>
@@ -133,8 +134,8 @@ struct as3645a_config { };struct as3645a_names { -char flash[32 ]; -char indicator[32 ]; +char flash[LED_MAX_NAME_SIZE ]; +char indicator[LED_MAX_NAME_SIZE ]; };struct as3645a {
@@ -496,7 +497,6 @@ static int as3645a_parse_node(struct as3645a *flash, {struct as3645a_config *cfg = &flash->cfg;struct device_node *child; -const char *name;int rval;for_each_child_of_node (node, child) {
@@ -523,12 +523,9 @@ static int as3645a_parse_node(struct as3645a *flash,return -ENODEV ; } - rval =of_property_read_string (flash->flash_node,"label" , &name); -if (!rval) -strlcpy (names->flash, name,sizeof (names->flash)); -else -snprintf (names->flash,sizeof (names->flash), -"%s:flash" , node->name); +of_led_compose_name (node, flash->flash_node,"flash" , +sizeof ("flash" ), + names->flash); rval =of_property_read_u32 (flash->flash_node,"flash-timeout-us" , &cfg->flash_timeout_us);
@@ -567,12 +564,9 @@ static int as3645a_parse_node(struct as3645a *flash, goto out_err; } - rval =of_property_read_string (flash->indicator_node,"label" , &name); -if (!rval) -strlcpy (names->indicator, name,sizeof (names->indicator)); -else -snprintf (names->indicator,sizeof (names->indicator), -"%s:indicator" , node->name); +of_led_compose_name (node, flash->indicator_node,"indicator" , +sizeof ("indicator" ), + names->indicator); rval =of_property_read_u32 (flash->indicator_node,"led-max-microamp" , &cfg->indicator_max_ua);
Signature · 1 line
2.15.0.124.g7668cbc60
Re: [PATCH v6 6/6] leds: as3645a: Update the LED label generation
Quoted 1 line · Dan Murphy
Update the LED label creationg to call the
s/creationg/creation
Quoted 74 lines
of_led_compose_nameapi to generate a label.Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to use the new LED class API
drivers/leds/leds-as3645a.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)drivers/leds/leds-as3645a.c +9
-15@@ -27,6 +27,7 @@#include <linux/mutex.h> #include <linux/of.h> #include <linux/slab.h> +#include <uapi/linux/uleds.h> #include <media/v4l2-flash-led-class.h> @@ -133,8 +134,8 @@ struct as3645a_config { };struct as3645a_names { -char flash[32 ]; -char indicator[32 ]; +char flash[LED_MAX_NAME_SIZE ]; +char indicator[LED_MAX_NAME_SIZE ]; };struct as3645a {@@ -496,7 +497,6 @@ static int as3645a_parse_node(struct as3645a *flash, {struct as3645a_config *cfg = &flash->cfg;struct device_node *child; -const char *name;int rval;for_each_child_of_node (node, child) {@@ -523,12 +523,9 @@ static int as3645a_parse_node(struct as3645a *flash,return -ENODEV ; } - rval =of_property_read_string (flash->flash_node,"label" , &name); -if (!rval) -strlcpy (names->flash, name,sizeof (names->flash)); -else -snprintf (names->flash,sizeof (names->flash), -"%s:flash" , node->name); +of_led_compose_name (node, flash->flash_node,"flash" , +sizeof ("flash" ), + names->flash); rval =of_property_read_u32 (flash->flash_node,"flash-timeout-us" , &cfg->flash_timeout_us);@@ -567,12 +564,9 @@ static int as3645a_parse_node(struct as3645a *flash, goto out_err; } - rval =of_property_read_string (flash->indicator_node,"label" , &name); -if (!rval) -strlcpy (names->indicator, name,sizeof (names->indicator)); -else -snprintf (names->indicator,sizeof (names->indicator), -"%s:indicator" , node->name); +of_led_compose_name (node, flash->indicator_node,"indicator" , +sizeof ("indicator" ), + names->indicator); rval =of_property_read_u32 (flash->indicator_node,"led-max-microamp" , &cfg->indicator_max_ua);
Signature · 2 lines
------------------ Dan Murphy
Dan,
Quoted 49 lines · Dan Murphy
Create an API that is called to derive the LED name from either the DT label in the child node or if that does not exist from the parent node name and an alternate label that is passed in.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to add the api to generate a LED label
drivers/leds/led-class.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/leds.h | 6 ++++++ 2 files changed, 40 insertions(+)drivers/leds/led-class.c +20
-0@@ -17,6 +17,7 @@#include <linux/leds.h> #include <linux/list.h> #include <linux/module.h> +#include <linux/of.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/timer.h> @@ -243,6 +244,39 @@ static int led_classdev_next_name(const char *init_name, char *name,return i; } +/** +* of_led_compose_name - derive the LED name based on DT or alternate name. +* +* @parent: parent of LED device +* @child: child node of LED device +* @alt_name: an alternate name if the label node is not found +* @len: length of the alt_name +* @led_name: derived name from either DT label or alt_name +*/ +void of_led_compose_name (struct device_node *parent, +struct device_node *child, +const char *alt_name, +size_t len, +char *led_name) +{ +int ret; +int length; +const char *name; +
drivers/leds/led-class.c static int led_classdev_next_name(const char *init_name, char *name, · line 275
Quoted 10 lines
drivers/leds/led-class.c +10
-0+if (len ==0 || alt_name ==NULL ) +return ; + + ret =of_property_read_string (child,"label" , &name); +if (!ret) { +strlcpy (led_name, name,sizeof (led_name)); + }else { + length = len +strlen (parent->name) +1 ; +snprintf (led_name, len,"%s:%s" , parent->name, alt_name); + }
It looks different from what I meant, i.e. that devicename segment shouldn't be present in the label, but derived from the parent DT node name.
This is however to be decided whether it wouldn't be better to leave the decision to the driver on how to obtain devicename - from parent DT node or from the driver hardcoded string. Some LED class drivers prefer the latter way, so if their parent node name differs a bit from the string they currently use for devicename, then the resulting LED class device name will change after switching to using this new API. In order to avoid that we would have to modify related DT node names in *.dts files, which would make unnecessary noise.
Since it may take a while to agree on the final semantics of this new API, especially after my recent patch [0], I propose to put below piece of code directly in the driver:
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::%s", np->name, name)Please note that "::" means leaving colour section blank, because we don't know the LED colour if label DT property was not provided.
Quoted 14 lines
drivers/leds/led-class.c +3
-0+} +EXPORT_SYMBOL_GPL (of_led_compose_name); +/** * of_led_classdev_register - register a new object of led_classdev class. * include/linux/leds.h +0
-0@@ -123,6 +123,12 @@ struct led_classdev {struct mutex led_access; };
include/linux/leds.h struct led_classdev { · line 134
Quoted 10 lines
include/linux/leds.h +6
-0+extern void of_led_compose_name (struct device_node *parent, +struct device_node *child, +const char *alt_name, +size_t len, +char *led_name); +extern int of_led_classdev_register (struct device *parent,struct device_node *np,struct led_classdev *led_cdev);
[0] https://patchwork.kernel.org/patch/10089047
Signature · 2 lines
Best regards, Jacek Anaszewski
Jacek
Quoted 90 lines · Jacek Anaszewski
Dan,
Quoted 49 lines · Dan Murphy
Create an API that is called to derive the LED name from either the DT label in the child node or if that does not exist from the parent node name and an alternate label that is passed in.
Signed-off-by Dan Murphy <[email protected]>---
v6 - New patch to add the api to generate a LED label
drivers/leds/led-class.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/leds.h | 6 ++++++ 2 files changed, 40 insertions(+)drivers/leds/led-class.c +20
-0@@ -17,6 +17,7 @@#include <linux/leds.h> #include <linux/list.h> #include <linux/module.h> +#include <linux/of.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/timer.h> @@ -243,6 +244,39 @@ static int led_classdev_next_name(const char *init_name, char *name,return i; } +/** +* of_led_compose_name - derive the LED name based on DT or alternate name. +* +* @parent: parent of LED device +* @child: child node of LED device +* @alt_name: an alternate name if the label node is not found +* @len: length of the alt_name +* @led_name: derived name from either DT label or alt_name +*/ +void of_led_compose_name (struct device_node *parent, +struct device_node *child, +const char *alt_name, +size_t len, +char *led_name) +{ +int ret; +int length; +const char *name; +drivers/leds/led-class.c static int led_classdev_next_name(const char *init_name, char *name, · line 275
Quoted 10 lines
drivers/leds/led-class.c +10
-0+if (len ==0 || alt_name ==NULL ) +return ; + + ret =of_property_read_string (child,"label" , &name); +if (!ret) { +strlcpy (led_name, name,sizeof (led_name)); + }else { + length = len +strlen (parent->name) +1 ; +snprintf (led_name, len,"%s:%s" , parent->name, alt_name); + }It looks different from what I meant, i.e. that devicename segment shouldn't be present in the label, but derived from the parent DT node name.
This is however to be decided whether it wouldn't be better to leave the decision to the driver on how to obtain devicename - from parent DT node or from the driver hardcoded string. Some LED class drivers prefer the latter way, so if their parent node name differs a bit from the string they currently use for devicename, then the resulting LED class device name will change after switching to using this new API. In order to avoid that we would have to modify related DT node names in *.dts files, which would make unnecessary noise.
Since it may take a while to agree on the final semantics of this new API, especially after my recent patch [0], I propose to put below piece of code directly in the driver:
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::%s", np->name, name)
Quoted 4 lines
Please note that "::" means leaving colour section blank, because we don't know the LED colour if label DT property was not provided.
Just for clarification.
You want me to drop the LED class changes and go back to putting the LED label generation back in the driver as the code you have above.
And separate out the LP8860 changes.
Dan
<snip>
Signature · 2 lines
------------------ Dan Murphy