Skip to contentSkip to conversation

leds: add new LED driver for TI LP5812

PATCH Superseded Nam Tran 6 participants 25 messages Mar 6, 2025 – Apr 1, 2025

Subsystems (4)

v3 of 22 Superseded Latest is v22 →

lore
Share & tools
lore

Nam Tran

author maintainer
#0 lore raw

v3 cover leds: add new LED driver for TI LP5812

From: Nam Tran <[email protected]>
To: Pavel Machek <[email protected]>, Lee Jones <[email protected]>, Krzysztof Kozlowski <[email protected]>, Rob Herring <[email protected]>, Conor Dooley <[email protected]>
Cc: [email protected], [email protected], [email protected]

This patch series adds support for the Texas Instruments LP5812 LED driver. Patch 1 adds the Device Tree (DT) bindings documentation.
Patch 2 adds the LP5812 device tree node for Raspberry Pi 4B. Patch 3 introduces the core driver implementation.

This driver has been tested on Raspberry Pi 4 B using kernel version 6.14.0-rc5.

I kindly request feedback from the community to ensure that this driver adheres to the Linux LED subsystem standards.

Thank you for your consideration.

Best regards,
Nam

---

Changes in v3:
- Addressed review comments from v2.
- Split the patches properly (DTS separated).
- Updated DTS example based on reviewer feedback.

author maintainer
#1 lore raw

PATCH v3 1/3 dt-bindings: leds: Add LP5812 LED driver

This documentation ensures proper integration of the LP5812 in Device Tree-based systems.

---
 .../devicetree/bindings/leds/ti,lp5812.yaml   | 50 +++++++++++++++++++
 MAINTAINERS                                   |  6 +++
 2 files changed, 56 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/ti,lp5812.yaml
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +50 -0
new file mode 100644
index 000000000000..9a203da4f272
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/ti,lp5812.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+$ref: /schemas/leds/common.yaml#
+
+title: Linux driver for LP5812 LED from Texas Instruments
+
+maintainers:
+  - Nam Tran <[email protected]>
+
+description: |
+  The LP5812 is an I2C LED Driver that can support LED matrix 4x3.
+  For more product information please see the link below:
+  https://www.ti.com/product/LP5812#tech-docs
+
+properties:
+  compatible:
+    const: ti,lp5812
+
+  reg:
+    maxItems: 1
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        led-controller@1b {
+            compatible = "ti,lp5812";
+            reg = <0x1b>;
+        };
+    };
+
+...
MAINTAINERS +6 -0
index 8e0736dc2ee0..2bd9f5132cab 100644
@@ -23506,6 +23506,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/leds/backlight/ti,lp8864.yaml
 F:	drivers/leds/leds-lp8864.c
 
+TEXAS INSTRUMENTS' LP5812 LED DRIVER
+M:	Nam Tran <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/leds/ti,lp5812.yaml
+
 TEXAS INSTRUMENTS' SYSTEM CONTROL INTERFACE (TISCI) PROTOCOL DRIVER
 M:	Nishanth Menon <[email protected]>
 M:	Tero Kristo <[email protected]>

base-commit: 48a5eed9ad584315c30ed35204510536235ce402

Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v3 1/3] dt-bindings: leds: Add LP5812 LED driver

Quoted 2 lines · Nam Tran

This documentation ensures proper integration of the LP5812 in Device Tree-based systems.

No changelog, no improvements in commit msg. You got comment at v1 to which you did not respond. Then you send v2 and I asked the same.

Please respond to the comment at v1 so acknowledge that you udnerstood it.

Your commit msg is totally redundant - you just said what Devicetree binding is. I asked to change it: describe the hardware instead.

Quoted 14 lines
---
 .../devicetree/bindings/leds/ti,lp5812.yaml   | 50 +++++++++++++++++++
 MAINTAINERS                                   |  6 +++
 2 files changed, 56 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/ti,lp5812.yaml
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +0 -0
new file mode 100644
index 000000000000..9a203da4f272

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 9

Quoted 9 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +9 -0
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/ti,lp5812.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+$ref: /schemas/leds/common.yaml#
+
+title: Linux driver for LP5812 LED from Texas Instruments

Nothing improved.

Quoted 5 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +5 -0
+
+maintainers:
+  - Nam Tran <[email protected]>
+
+description: |

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 24

Quoted 10 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +10 -0
+  The LP5812 is an I2C LED Driver that can support LED matrix 4x3.
+  For more product information please see the link below:
+  https://www.ti.com/product/LP5812#tech-docs
+
+properties:
+  compatible:
+    const: ti,lp5812
+
+  reg:
+    maxItems: 1

This improved... but:

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 30

Quoted 6 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +6 -0
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0

What are these?

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 35

Quoted 5 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +5 -0
+
+required:
+  - compatible
+  - reg
+

Nothing improved here.

You keep ignoring comments, not responding to them. This is not how you are supposed to work with reviewers.

Quoted 20 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +15 -0
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        led-controller@1b {
+            compatible = "ti,lp5812";
+            reg = <0x1b>;
+        };
+    };
+
+...
MAINTAINERS +0 -0
index 8e0736dc2ee0..2bd9f5132cab 100644

MAINTAINERS S: Maintained · line 23509

Quoted 4 lines
MAINTAINERS +1 -0
@@ -23506,6 +23506,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/leds/backlight/ti,lp8864.yaml
 F:	drivers/leds/leds-lp8864.c
 
+TEXAS INSTRUMENTS' LP5812 LED DRIVER

Nothing improved.

NAK

Best regards,
Krzysztof

author maintainer
#3 lore raw

Re: [PATCH v3 1/3] dt-bindings: leds: Add LP5812 LED driver

In reply to Nam Tran

From: Nam Tran <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
Cc: Rob Herring <[email protected]>, Conor Dooley <[email protected]> Pavel Machek <[email protected]>, Lee Jones <[email protected]>, [email protected], [email protected], [email protected]

Sorry for being unprofessional. I will make sure to properly address your concerns.

Quoted 2 lines · Nam Tran

This documentation ensures proper integration of the LP5812 in Device Tree-based systems.

No changelog, no improvements in commit msg. You got comment at v1 to which you did not respond. Then you send v2 and I asked the same.

Please respond to the comment at v1 so acknowledge that you understood it.

Your previous comment
Your commit msg is totally redundant - you just said what Devicetree binding is. I asked to change it: describe the hardware instead.

Nam: I apologize for not responding to your v1 feedback. I appreciate your patience and will ensure that I acknowledge all review comments moving forward.
I now understand your request regarding the commit message. Instead of providing a generic description of Device Tree bindings, I will update the commit message in the next patch to describe the LP5812 hardware itself.

Quoted 14 lines
---
 .../devicetree/bindings/leds/ti,lp5812.yaml   | 50 +++++++++++++++++++
 MAINTAINERS                                   |  6 +++
 2 files changed, 56 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/ti,lp5812.yaml
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +0 -0
new file mode 100644
index 000000000000..9a203da4f272

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 9

Quoted 9 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +9 -0
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/ti,lp5812.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+$ref: /schemas/leds/common.yaml#
+
+title: Linux driver for LP5812 LED from Texas Instruments

Nothing improved.

Nam: Do you mean the title should focus on the LP5812 hardware itself? If so, I will update it accordingly to better describe the device.

Quoted 5 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +5 -0
+
+maintainers:
+  - Nam Tran <[email protected]>
+
+description: |

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 24

Quoted 10 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +10 -0
+  The LP5812 is an I2C LED Driver that can support LED matrix 4x3.
+  For more product information please see the link below:
+  https://www.ti.com/product/LP5812#tech-docs
+
+properties:
+  compatible:
+    const: ti,lp5812
+
+  reg:
+    maxItems: 1

This improved... but:

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 30

Quoted 6 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +6 -0
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0

What are these?

Nam: I included the #address-cells and #size-cells properties to resolve a warning encountered when running:
make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/leds/ti,lp5812.yaml
The specific warning was:
Documentation/devicetree/bindings/leds/ti,lp5812.example.dts:23.17-30: Warning (reg_format): /example-0/i2c/led-controller@1b:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1) This warning suggests that the default values for #address-cells and #size-cells in the schema context are not aligned with the LP5812's expected usage. To explicitly define the correct values, I set these properties as mentioned. This ensures that the binding schema validation passes without warnings. If you believe a different approach is more appropriate, I’m happy to adjust the binding accordingly.

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 35

Quoted 5 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +5 -0
+
+required:
+  - compatible
+  - reg
+

Nothing improved here.
Your previous comment
No ref to LED common schema? No other properties? This is too incomplete

Nam: I have chosen not to reference common.yaml in the LP5812 binding because the LP5812 does not fully align with the standard LED properties defined in the common schema. Since the driver does not use standard properties like function, color, or max-brightness, I believe referencing the common schema would introduce unnecessary constraints. Currently, I have included compatible and reg as required properties, as they are essential for describing the LP5812 device. Are there additional properties that should be marked as required? Or if you have specific improvements in mind, I would appreciate your guidance.

Quoted 20 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +15 -0
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        led-controller@1b {
+            compatible = "ti,lp5812";
+            reg = <0x1b>;
+        };
+    };
+
+...
MAINTAINERS +0 -0
index 8e0736dc2ee0..2bd9f5132cab 100644

MAINTAINERS S: Maintained · line 23509

Quoted 4 lines
MAINTAINERS +1 -0
@@ -23506,6 +23506,12 @@ S:   Maintained
 F:   Documentation/devicetree/bindings/leds/backlight/ti,lp8864.yaml
 F:   drivers/leds/leds-lp8864.c
 
+TEXAS INSTRUMENTS' LP5812 LED DRIVER

Nothing improved.
Your previous comment
5 is before 8, so this does not look sorted.

Nam: I have reviewed the sorting order in MAINTAINERS, and I believe the current placement of LP5812 is correct. Since "LB" comes before "LP" alphabetically, "TEXAS INSTRUMENTS' LB8864 LED DRIVER" is correctly listed before "TEXAS INSTRUMENTS' LP5812 LED BACKLIGHT DRIVER". It seems there is a typo in the MAINTAINERS file, should it be LB8864 or LP8864?

Best regards,
Nam Tran

#4 lore raw

Re: [PATCH v3 1/3] dt-bindings: leds: Add LP5812 LED driver

Quoted 11 lines · Nam Tran

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 9

Quoted 8 lines

+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/ti,lp5812.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#

Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +4 -0
+
+$ref: /schemas/leds/common.yaml#
+
+title: Linux driver for LP5812 LED from Texas Instruments

Nothing improved.

Quoted 1 line

Nam: Do you mean the title should focus on the LP5812 hardware itself? If so, I will update it accordingly to better describe the device.

No, I mean you should say what this device is, not what the driver is for. Bindings are about hardware, not drivers.

Quoted 29 lines
Quoted 6 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +5 -0
+
+maintainers:
+  - Nam Tran <[email protected]>
+
+description: |

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 24

Quoted 10 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +10 -0
+  The LP5812 is an I2C LED Driver that can support LED matrix 4x3.
+  For more product information please see the link below:
+  https://www.ti.com/product/LP5812#tech-docs
+
+properties:
+  compatible:
+    const: ti,lp5812
+
+  reg:
+    maxItems: 1

This improved... but:

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 30

Quoted 6 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +6 -0
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0

What are these?

Quoted 4 lines

Nam: I included the #address-cells and #size-cells properties to resolve a warning encountered when running:
make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/leds/ti,lp5812.yaml
The specific warning was:
Documentation/devicetree/bindings/leds/ti,lp5812.example.dts:23.17-30: Warning (reg_format): /example-0/i2c/led-controller@1b:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)

This makes no sense.

Quoted 2 lines

This warning suggests that the default values for #address-cells and #size-cells in the schema context are not aligned with the LP5812's expected usage. To explicitly define the correct values, I set these properties as mentioned. This ensures that the binding schema validation passes without warnings. If you believe a different approach is more appropriate, I’m happy to adjust the binding accordingly.

I can barely parse your messages. They are neither properly quoting my replies, nor wrapped according to email style. Use standard format, expressed in countless guides bout netiquette and mailing lists.

You added properties to hide warning, instead of fixing the warning, but these properties make nos sense here.

Quoted 11 lines

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 35

Quoted 6 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +5 -0
+
+required:
+  - compatible
+  - reg
+

Nothing improved here.
Your previous comment
No ref to LED common schema? No other properties? This is too incomplete

Quoted 1 line

Nam: I have chosen not to reference common.yaml in the LP5812 binding because the LP5812 does not fully align with the standard LED properties defined in the common schema. Since the driver does

That's a no go.

Quoted 1 line

not use standard properties like function, color, or max-brightness, I believe referencing the common schema would introduce unnecessary constraints.

Driver? Please describe hardware, not driver.

Quoted 1 line

Currently, I have included compatible and reg as required properties, as they are essential for describing the LP5812 device. Are there additional properties that should be marked as required? Or if you have specific improvements in mind, I would appreciate your guidance.

Look at other bindings and do not re-invent.

Quoted 24 lines
Quoted 24 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +15 -0
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        led-controller@1b {
+            compatible = "ti,lp5812";
+            reg = <0x1b>;
+        };
+    };
+
+...
MAINTAINERS +0 -0
index 8e0736dc2ee0..2bd9f5132cab 100644
@@ -23506,6 +23506,12 @@ S:   Maintained
 F:   Documentation/devicetree/bindings/leds/backlight/ti,lp8864.yaml
 F:   drivers/leds/leds-lp8864.c
 
Quoted 7 lines

MAINTAINERS S: Maintained · line 23509

Quoted 1 line
MAINTAINERS +1 -0
+TEXAS INSTRUMENTS' LP5812 LED DRIVER

Nothing improved.
Your previous comment
5 is before 8, so this does not look sorted.

Nam: I have reviewed the sorting order in MAINTAINERS, and I believe the current placement of LP5812 is correct. Since "LB" comes before "LP" alphabetically, "TEXAS INSTRUMENTS' LB8864 LED DRIVER" is correctly listed before "TEXAS INSTRUMENTS' LP5812 LED BACKLIGHT DRIVER".

Indeed, existing entry has typo, so code is fine. Is it such a big deal to answer to reviewer to his comment?

Best regards,
Krzysztof

author maintainer
#5 lore raw

Re: [PATCH v3 1/3] dt-bindings: leds: Add LP5812 LED driver

Quoted 11 lines · Krzysztof Kozlowski
Quoted 11 lines

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 9

Quoted 8 lines

+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/ti,lp5812.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#

Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +4 -0
+
+$ref: /schemas/leds/common.yaml#
+
+title: Linux driver for LP5812 LED from Texas Instruments

Nothing improved.

Quoted 4 lines
Quoted 1 line

Nam: Do you mean the title should focus on the LP5812 hardware itself? If so, I will update it accordingly to better describe the device.

No, I mean you should say what this device is, not what the driver is for. Bindings are about hardware, not drivers.

Thank you for the clarification.
I will change the title to “TI/National Semiconductor LP5812 LED Drivers”.

Quoted 39 lines
Quoted 29 lines
Quoted 6 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +5 -0
+
+maintainers:
+  - Nam Tran <[email protected]>
+
+description: |

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 24

Quoted 10 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +10 -0
+  The LP5812 is an I2C LED Driver that can support LED matrix 4x3.
+  For more product information please see the link below:
+  https://www.ti.com/product/LP5812#tech-docs
+
+properties:
+  compatible:
+    const: ti,lp5812
+
+  reg:
+    maxItems: 1

This improved... but:

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 30

Quoted 6 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +6 -0
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0

What are these?

Quoted 4 lines

Nam: I included the #address-cells and #size-cells properties to resolve a warning encountered when running:
make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/leds/ti,lp5812.yaml
The specific warning was:
Documentation/devicetree/bindings/leds/ti,lp5812.example.dts:23.17-30: Warning (reg_format): /example-0/i2c/led-controller@1b:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)

This makes no sense.

Quoted 2 lines

This warning suggests that the default values for #address-cells and #size-cells in the schema context are not aligned with the LP5812's expected usage. To explicitly define the correct values, I set these properties as mentioned. This ensures that the binding schema validation passes without warnings. If you believe a different approach is more appropriate, I’m happy to adjust the binding accordingly.

Quoted 6 lines

I can barely parse your messages. They are neither properly quoting my replies, nor wrapped according to email style. Use standard format, expressed in countless guides bout netiquette and mailing lists.

You added properties to hide warning, instead of fixing the warning, but these properties make nos sense here.

#address-cells is 1 because I only one cell to define address of a child node of LP5812 #size-cells is 0 because I don't need to define size of reg properly of child node. Reg properly of child node is describe for address only.

Quoted 15 lines
Quoted 11 lines

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 35

Quoted 6 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +5 -0
+
+required:
+  - compatible
+  - reg
+

Nothing improved here.
Your previous comment
No ref to LED common schema? No other properties? This is too incomplete

Quoted 1 line

Nam: I have chosen not to reference common.yaml in the LP5812 binding because the LP5812 does not fully align with the standard LED properties defined in the common schema. Since the driver does

That's a no go.

Quoted 7 lines
Quoted 1 line

not use standard properties like function, color, or max-brightness, I believe referencing the common schema would introduce unnecessary constraints.

Driver? Please describe hardware, not driver.

Quoted 1 line

Currently, I have included compatible and reg as required properties, as they are essential for describing the LP5812 device. Are there additional properties that should be marked as required? Or if you have specific improvements in mind, I would appreciate your guidance.

Look at other bindings and do not re-invent.

I checked other bindings and I will update LP5812 yaml follow multi color led and describe LP5812 hardware in the yaml. My new yaml will update as below

# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
---
$id: http://devicetree.org/schemas/leds/ti,lp5812.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

$ref: /schemas/leds/common.yaml#

title: TI/National Semiconductor LP5812 LED Drivers

maintainers:
- Nam Tran <[email protected]>

description: |
The LP5812 is an I2C LED Driver that can support LED matrix 4x3. For more product information please see the link below:
https://www.ti.com/product/LP5812#tech-docs

properties:
compatible:

    const: ti,lp5812

reg:
maxItems: 1
description:
I2C slave address
lp5812/12- 0x1b

"#address-cells":
const: 1

"#size-cells":
const: 0

patternProperties:
'^multi-led@[0-3]$':

    type: object
    $ref: leds-class-multicolor.yaml#
    unevaluatedProperties: false

    properties:
      reg:
        minItems: 1
        maxItems: 12

      '#address-cells':
        const: 1

      '#size-cells':
        const: 0

    patternProperties:
      "^led@[0-9a-f]+$":
        type: object
        $ref: common.yaml#
        unevaluatedProperties: false

        properties:
          reg:
            maxItems: 1

        required:
          - reg

required:
- compatible
- reg

additionalProperties: false

examples:
- |

    #include <dt-bindings/leds/common.h>

    i2c {
        #address-cells = <1>;
        #size-cells = <0>;

        led-controller@1b {
            compatible = "ti,lp5812";
            reg = <0x1b>;
            #address-cells = <1>;
            #size-cells = <0>;

            multi-led@0 {
              #address-cells = <1>;
              #size-cells = <0>;
              reg = <0x0>;
              color = <LED_COLOR_ID_RGB>;
              led@0 {
                     reg = <0x0>;
                     color = <LED_COLOR_ID_GREEN>;
              };
              led@1 {
                     reg = <0x1>;
                     color = <LED_COLOR_ID_RED>;
              };
              led@2 {
                     reg = <0x2>;
                     color = <LED_COLOR_ID_BLUE>;
              };
            };

            multi-led@1 {
              #address-cells = <1>;
              #size-cells = <0>;
              reg = <0x1>;
              color = <LED_COLOR_ID_RGB>;
              led@3 {
                     reg = <0x3>;
                     color = <LED_COLOR_ID_GREEN>;
              };
              led@4 {
                     reg = <0x4>;
                     color = <LED_COLOR_ID_RED>;
              };
              led@5 {
                     reg = <0x5>;
                     color = <LED_COLOR_ID_BLUE>;
              };
            };
            multi-led@2 {
              #address-cells = <1>;
              #size-cells = <0>;
              reg = <0x2>;
              color = <LED_COLOR_ID_RGB>;
              led@6 {
                     reg = <0x6>;
                     color = <LED_COLOR_ID_GREEN>;
              };
              led@7 {
                     reg = <0x7>;
                     color = <LED_COLOR_ID_RED>;
              };
              led@8 {
                     reg = <0x8>;
                     color = <LED_COLOR_ID_BLUE>;
              };
            };

            multi-led@3 {
              #address-cells = <1>;
              #size-cells = <0>;
              reg = <0x3>;
              color = <LED_COLOR_ID_RGB>;
              led@9 {
                     reg = <0x9>;
                     color = <LED_COLOR_ID_GREEN>;
              };
              led@a {
                     reg = <0xA>;
                     color = <LED_COLOR_ID_RED>;
              };
              led@b {
                     reg = <0xB>;
                     color = <LED_COLOR_ID_BLUE>;
              };
            };
        };
    };

...

Quoted 30 lines
Quoted 30 lines
Quoted 21 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +15 -0
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        led-controller@1b {
+            compatible = "ti,lp5812";
+            reg = <0x1b>;
+        };
+    };
+
+...
MAINTAINERS +0 -0
index 8e0736dc2ee0..2bd9f5132cab 100644

MAINTAINERS S: Maintained · line 23509

Quoted 4 lines
MAINTAINERS +1 -0
@@ -23506,6 +23506,12 @@ S:   Maintained
 F:   Documentation/devicetree/bindings/leds/backlight/ti,lp8864.yaml
 F:   drivers/leds/leds-lp8864.c
 
+TEXAS INSTRUMENTS' LP5812 LED DRIVER

Nothing improved.
Your previous comment
5 is before 8, so this does not look sorted.

Quoted 5 lines
Quoted 1 line

Nam: I have reviewed the sorting order in MAINTAINERS, and I believe the current placement of LP5812 is correct. Since "LB" comes before "LP" alphabetically, "TEXAS INSTRUMENTS' LB8864 LED DRIVER" is correctly listed before "TEXAS INSTRUMENTS' LP5812 LED BACKLIGHT DRIVER".

Indeed, existing entry has typo, so code is fine. Is it such a big deal to answer to reviewer to his comment?

Thank you for the clarification. I now understand that the existing entry contains a typo. I will make sure to response to reviewer comments more promtly in the future. Is it acceptable if I modify MAINTAINERS file to adjust LB8864 to LP8864?

Best regards,
Nam Tran

#6 lore raw

Re: [PATCH v3 1/3] dt-bindings: leds: Add LP5812 LED driver

Quoted 24 lines · Nam Tran
Quoted 24 lines
Quoted 10 lines

Documentation/devicetree/bindings/leds/ti,lp5812.yaml line 30

Quoted 7 lines
Documentation/devicetree/bindings/leds/ti,lp5812.yaml new file +6 -0
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0

What are these?

Quoted 4 lines

Nam: I included the #address-cells and #size-cells properties to resolve a warning encountered when running:
make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/leds/ti,lp5812.yaml
The specific warning was:
Documentation/devicetree/bindings/leds/ti,lp5812.example.dts:23.17-30: Warning (reg_format): /example-0/i2c/led-controller@1b:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)

This makes no sense.

Quoted 2 lines

This warning suggests that the default values for #address-cells and #size-cells in the schema context are not aligned with the LP5812's expected usage. To explicitly define the correct values, I set these properties as mentioned. This ensures that the binding schema validation passes without warnings. If you believe a different approach is more appropriate, I’m happy to adjust the binding accordingly.

I can barely parse your messages. They are neither properly quoting my replies, nor wrapped according to email style. Use standard format, expressed in countless guides bout netiquette and mailing lists.

Quoted 6 lines
Quoted 2 lines

You added properties to hide warning, instead of fixing the warning, but these properties make nos sense here.

#address-cells is 1 because I only one cell to define address of a child node of LP5812 #size-cells is 0 because I don't need to define size of reg properly of child node. Reg properly of child node is describe for address only.

Please do not explain me how DT works, we all know. You do not have child node. If you disagree - point me to the line in schema having it.

Best regards,
Krzysztof

author maintainer
#7 lore raw

Re: [PATCH v3 1/3] dt-bindings: leds: Add LP5812 LED driver

Quoted 2 lines · Krzysztof Kozlowski

Please do not explain me how DT works, we all know. You do not have child node. If you disagree - point me to the line in schema having it.

Thank you for your feedback.
I now understand that my schema does not define child nodes, so #address-cells and #size-cells should not be included. I will update the schema accordingly as shown below.

# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
---
$id: http://devicetree.org/schemas/leds/ti,lp5812.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: TI/National Semiconductor LP5812 LED Driver

maintainers:
- Nam Tran <[email protected]>

description: |
The LP5812 is an I2C LED Driver that can support LED matrix 4x3. For more product information please see the link below:
https://www.ti.com/product/LP5812#tech-docs

properties:
compatible:

    const: ti,lp5812

reg:
maxItems: 1
description:
I2C slave address
lp5812/12- 0x1b

patternProperties:
"^led@[0-9a-b]$":
type: object
$ref: common.yaml#
unevaluatedProperties: false

properties:
reg:
minimum: 0
maximum: 0xb

chan-name:
$ref: /schemas/types.yaml#/definitions/string
description: LED channel name

required:
- reg

required:
- compatible
- reg

additionalProperties: false

examples:
- |

    #include <dt-bindings/leds/common.h>

    i2c {
        #address-cells = <1>;
        #size-cells = <0>;

        led-controller@1b {
            compatible = "ti,lp5812";
            reg = <0x1b>;

            led@0 {
                    reg = <0x0>;
                    chan-name = "a0";
            };
            led@1 {
                    reg = <0x1>;
                    chan-name = "a1";
            };
            led@2 {
                    reg = <0x2>;
                    chan-name = "a2";
            };
            led@3 {
                    reg = <0x3>;
                    chan-name = "b0";
            };
            led@4 {
                    reg = <0x4>;
                    chan-name = "b1";
            };
            led@5 {
                    reg = <0x5>;
                    chan-name = "b2";
            };
            led@6 {
                    reg = <0x6>;
                    chan-name = "c0";
            };
            led@7 {
                    reg = <0x7>;
                    chan-name = "c1";
            };
            led@8 {
                    reg = <0x8>;
                    chan-name = "c2";
            };
            led@9 {
                    reg = <0x9>;
                    chan-name = "d0";
            };
            led@a {
                    reg = <0xa>;
                    chan-name = "d1";
            };
            led@b {
                    reg = <0xb>;
                    chan-name = "d2";
            };
        };
    };

...

Best regards,
Nam Tran

#8 lore raw

Re: [PATCH v3 1/3] dt-bindings: leds: Add LP5812 LED driver

Quoted 8 lines · Nam Tran
Quoted 2 lines · Krzysztof Kozlowski

Please do not explain me how DT works, we all know. You do not have child node. If you disagree - point me to the line in schema having it.

Thank you for your feedback.
I now understand that my schema does not define child nodes, so #address-cells and #size-cells should not be included. I will update the schema accordingly as shown below.

This has... What are we talking here about? I commented only about that patch.

You claimed:

Quoted 1 line

Nam: I included the #address-cells and #size-cells properties to

resolve a warning encountered when running:

which was obviously not true. You could not have such errors, because you did not have children. You disagreed with me so you got response like that.

If you decide to add children, then you will need address and size cells, but that's a different patch.

Best regards,
Krzysztof

author maintainer
#9 lore raw

PATCH v3 2/3 arm64: dts: Add LP5812 LED node for Raspberry Pi 4 Model B

In reply to Nam Tran

Add the LP5812 LED driver node to the Device Tree for Raspberry Pi 4 B. This enables the LED connected to the LP5812 to be controlled via I2C.

---
 arch/arm/boot/dts/broadcom/bcm2711-rpi-4-b.dts | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/dts/broadcom/bcm2711-rpi-4-b.dts +10 -0
index 353bb50ce542..85441746d94b 100644
@@ -270,3 +270,13 @@ &vec {
 &wifi_pwrseq {
 	reset-gpios = <&expgpio 1 GPIO_ACTIVE_LOW>;
 };
+
+&i2c1 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	led-controller@1b {
+		compatible = "ti,lp5812";
+		reg = <0x1b>;
+	};
+};
Signature · 1 line
2.25.1
#10 lore raw

Re: [PATCH v3 2/3] arm64: dts: Add LP5812 LED node for Raspberry Pi 4 Model B

Quoted 13 lines · Nam Tran

Add the LP5812 LED driver node to the Device Tree for Raspberry Pi 4 B. This enables the LED connected to the LP5812 to be controlled via I2C.

---
 arch/arm/boot/dts/broadcom/bcm2711-rpi-4-b.dts | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/dts/broadcom/bcm2711-rpi-4-b.dts +0 -0
index 353bb50ce542..85441746d94b 100644

arch/arm/boot/dts/broadcom/bcm2711-rpi-4-b.dts &vec { · line 274

Quoted 5 lines
arch/arm/boot/dts/broadcom/bcm2711-rpi-4-b.dts +2 -0
@@ -270,3 +270,13 @@ &vec {
 &wifi_pwrseq {
 	reset-gpios = <&expgpio 1 GPIO_ACTIVE_LOW>;
 };
+
+&i2c1 {

Follow ordering of nodes explained in DTS coding style.

Best regards,
Krzysztof

#11 lore raw

Re: [PATCH v3 2/3] arm64: dts: Add LP5812 LED node for Raspberry Pi 4 Model B

In reply to Nam Tran
Quoted 7 lines · Nam Tran

Add the LP5812 LED driver node to the Device Tree for Raspberry Pi 4 B. This enables the LED connected to the LP5812 to be controlled via I2C.

---
 arch/arm/boot/dts/broadcom/bcm2711-rpi-4-b.dts | 10 ++++++++++
 1 file changed, 10 insertions(+)

One more: DTS is *never* in the middle of patchset. It is always at the end.

Best regards,
Krzysztof

author maintainer
#12 lore raw

PATCH v3 3/3 leds: add new LED driver for TI LP5812

In reply to Nam Tran

The chip can drive LED matrix 4x3.
This driver enables LED control via I2C.

The driver is implemented in two parts:
- Core driver logic in leds-lp5812.c
- Common support functions in leds-lp5812-common.c

---
 MAINTAINERS                       |    6 +
 drivers/leds/Kconfig              |   29 +
 drivers/leds/Makefile             |    2 +
 drivers/leds/leds-lp5812-common.c | 1023 ++++++++++++++
 drivers/leds/leds-lp5812-common.h |  323 +++++
 drivers/leds/leds-lp5812-regs.h   |   96 ++
 drivers/leds/leds-lp5812.c        | 2190 +++++++++++++++++++++++++++++
 7 files changed, 3669 insertions(+)
 create mode 100644 drivers/leds/leds-lp5812-common.c
 create mode 100644 drivers/leds/leds-lp5812-common.h
 create mode 100644 drivers/leds/leds-lp5812-regs.h
 create mode 100644 drivers/leds/leds-lp5812.c
MAINTAINERS +6 -0
index 2bd9f5132cab..773c7ad6a7b6 100644
@@ -23511,6 +23511,12 @@ M:	Nam Tran <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/leds/ti,lp5812.yaml
+F:	drivers/leds/Kconfig
+F:	drivers/leds/Makefile
+F:	drivers/leds/leds-lp5812-common.c
+F:	drivers/leds/leds-lp5812-common.h
+F:	drivers/leds/leds-lp5812-regs.h
+F:	drivers/leds/leds-lp5812.c
 
 TEXAS INSTRUMENTS' SYSTEM CONTROL INTERFACE (TISCI) PROTOCOL DRIVER
 M:	Nishanth Menon <[email protected]>
drivers/leds/Kconfig +29 -0
index 2b27d043921c..7af5ebf190a9 100644
@@ -483,6 +483,35 @@ config LEDS_LP5569
 	  Driver provides direct control via LED class and interface for
 	  programming the engines.
 
+config LEDS_LP5812
+	tristate "Enable LP5812 support LED matrix 4x3"
+	depends on LEDS_CLASS && I2C
+	depends on LEDS_CLASS_MULTICOLOR
+	help
+	  If you say Y here you get support for TI LP5812 LED driver.
+
+	  The LP5812 is an I2C-based RGB LED driver that supports a 4x3 LED matrix.
+	  It provides independent brightness control and color mixing for each LED.
+	  This driver integrates with the Linux LED framework and LED multicolor class.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called leds-lp5812.
+
+	  If unsure, say N.
+
+config LEDS_LP5812_COMMON
+	tristate "Common driver for TI LP5812"
+	depends on LEDS_CLASS
+	depends on LEDS_CLASS_MULTICOLOR
+	depends on I2C
+	help
+	  If you say Y here you get support common operation for TI LP5812 LED driver.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called leds-lp5812-common.
+
+	  If unsure, say N.
+
 config LEDS_LP8501
 	tristate "LED Support for TI LP8501 LED driver chip"
 	depends on LEDS_CLASS && I2C
drivers/leds/Makefile +2 -0
index 6ad52e219ec6..d3daae2d808c 100644
@@ -54,6 +54,8 @@ obj-$(CONFIG_LEDS_LP5523)		+= leds-lp5523.o
 obj-$(CONFIG_LEDS_LP5562)		+= leds-lp5562.o
 obj-$(CONFIG_LEDS_LP5569)		+= leds-lp5569.o
 obj-$(CONFIG_LEDS_LP55XX_COMMON)	+= leds-lp55xx-common.o
+obj-$(CONFIG_LEDS_LP5812) 		+= leds-lp5812.o
+obj-$(CONFIG_LEDS_LP5812_COMMON)	+= leds-lp5812-common.o
 obj-$(CONFIG_LEDS_LP8501)		+= leds-lp8501.o
 obj-$(CONFIG_LEDS_LP8788)		+= leds-lp8788.o
 obj-$(CONFIG_LEDS_LP8860)		+= leds-lp8860.o
drivers/leds/leds-lp5812-common.c new file +1023 -0

1,023 lines not on this page · raw message

drivers/leds/leds-lp5812-common.h new file +323 -0

323 lines not on this page · raw message

drivers/leds/leds-lp5812-regs.h new file +96 -0

96 lines not on this page · raw message

drivers/leds/leds-lp5812.c new file +2190 -0

1,503 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.25.1

Part of the diff is not shown here. View the raw message.

#13 lore raw

Le 06/03/2025 à 18:21, Nam Tran a écrit :

Quoted 9 lines

The chip can drive LED matrix 4x3.
This driver enables LED control via I2C.

The driver is implemented in two parts:
- Core driver logic in leds-lp5812.c
- Common support functions in leds-lp5812-common.c

---

A few comments/nitpicks.

Some of them can be applied in several places, I've not spotted all of them, but you get the idea.

Hoping, this will help to clean the code and help other reviewers.

drivers/leds/leds-lp5812.c line 1096

Quoted 12 lines
drivers/leds/leds-lp5812.c new file +12 -0
+
+static ssize_t led_mode_store(struct kobject *kobj,
+		struct kobj_attribute *attr, const char *buf, size_t count)
+{
+	int val, ret;
+	struct lp5812_led *led = to_lp5812_led(kobj);
+	struct lp5812_chip *chip = led->priv;
+
+	if (sysfs_streq(buf, "manual")) {
+		/* Remove AEU sysfs interface for current led in manual mode */
+		aeu_remove_multi_sysfs_groups(led);
+		val = 0;

Maybe use AUTONOMOUS or MANUAL directly.

Quoted 26 lines
drivers/leds/leds-lp5812.c new file +26 -0
+	} else if (sysfs_streq(buf, "autonomous")) {
+		val = 1;
+	} else {
+		return -EINVAL;
+	}
+
+	mutex_lock(&chip->lock);
+	ret = lp5812_set_led_mode(chip, led->led_number,
+			val ? AUTONOMOUS : MANUAL);
+	if (ret) {
+		ret = -EIO;
+		goto out;
+	}
+
+	ret = aeu_create_multi_sysfs_groups(led);
+	if (ret) {
+		dev_err(chip->dev, "aeu_create_multi_sysfs_groups() failed\n");
+		goto out;
+	}
+
+	mutex_unlock(&chip->lock);
+	return count;
+out:
+	mutex_unlock(&chip->lock);
+	return ret;
+}

...

Quoted 4 lines
drivers/leds/leds-lp5812.c new file +4 -0
+static ssize_t led_manual_pwm_store(struct kobject *kobj,
+		struct kobj_attribute *attr, const char *buf, size_t count)
+{
+	int manual_pwm;

drivers/leds/leds-lp5812.c line 1180

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+	int ret;
+	struct lp5812_led *led = to_lp5812_led(kobj);
+	struct lp5812_chip *chip = led->priv;
+
+	ret = kstrtoint(buf, 0, &manual_pwm);
+	if (ret)
+		return ret;
+
+	if (manual_pwm < 0 || manual_pwm > 255)
+		return -EINVAL; /* Invalid argument */

Useless comment (here and in several other places)

Quoted 12 lines
drivers/leds/leds-lp5812.c new file +12 -0
+
+	/* set to hardware */
+	mutex_lock(&chip->lock);
+	if (lp5812_manual_dc_pwm_control(chip, led->led_number,
+		manual_pwm, PWM)) {
+		mutex_unlock(&chip->lock);
+		return -EIO;
+	}
+	mutex_unlock(&chip->lock);
+
+	return count;
+}

...

Quoted 4 lines
drivers/leds/leds-lp5812.c new file +4 -0
+static ssize_t led_auto_dc_store(struct kobject *kobj,
+		struct kobj_attribute *attr, const char *buf, size_t count)
+{
+	int auto_dc;

drivers/leds/leds-lp5812.c line 1223

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+	int ret;
+	struct lp5812_led *led = to_lp5812_led(kobj);
+	struct lp5812_chip *chip = led->priv;
+
+	ret = kstrtoint(buf, 0, &auto_dc);
+	if (ret)
+		return ret;
+
+	if (auto_dc < 0 || auto_dc > 255)
+		return -EINVAL; /* Invalid argument */

Useless comment

Quoted 12 lines
drivers/leds/leds-lp5812.c new file +12 -0
+
+	/* set to hardware */
+	mutex_lock(&chip->lock);
+	if (lp5812_autonomous_dc_pwm_control(chip, led->led_number,
+			auto_dc, ANALOG)) {
+		mutex_unlock(&chip->lock);
+		return -EIO;
+	}
+	mutex_unlock(&chip->lock);
+
+	return count;
+}

...

drivers/leds/leds-lp5812.c line 1263

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+static int parse_autonomous_animation_config(struct lp5812_led *led,
+		const char *user_buf)
+{
+	int ret;
+	int i;
+	char *str;
+	char *sub_str;
+	int aeu_select, start_pause_time, stop_pause_time, led_playback_time;
+
+	str = kmalloc(strlen(user_buf) + 1, GFP_KERNEL);

kstrdup()?

Quoted 60 lines
drivers/leds/leds-lp5812.c new file +60 -0
+	if (!str)
+		return -ENOMEM;
+	strscpy(str, user_buf, strlen(user_buf) + 1);
+
+	/* parse aeu_select */
+	sub_str = strsep(&str, ":");
+	ret = kstrtoint(sub_str, 0, &aeu_select);
+	if (ret)
+		return ret;
+	if (aeu_select < 1 || aeu_select > 3)
+		return -EINVAL;
+
+	aeu_remove_multi_sysfs_groups(led);
+
+	for (i = 0; i < aeu_select; i++)
+		aeu_create_sysfs_group(&led->aeu[i]);
+	led->led_playback.s_led_playback.aeu_selection = aeu_select - 1;
+
+	/* parse start_pause_time */
+	sub_str = strsep(&str, ":");
+	if (sub_str) {
+		ret = kstrtoint(sub_str, 0, &start_pause_time);
+		if (ret)
+			return ret;
+		if (start_pause_time < 0 || start_pause_time > 15)
+			return -EINVAL;
+		led->start_stop_pause_time.s_time.second = start_pause_time;
+	} else {
+		led->start_stop_pause_time.s_time.second = 15;
+	}
+
+	/* parse stop_pause_time */
+	sub_str = strsep(&str, ":");
+	if (sub_str) {
+		ret = kstrtoint(sub_str, 0, &stop_pause_time);
+		if (ret)
+			return ret;
+		if (stop_pause_time < 0 || stop_pause_time > 15)
+			return -EINVAL;
+		led->start_stop_pause_time.s_time.first = stop_pause_time;
+	} else {
+		led->start_stop_pause_time.s_time.first = 15;
+	}
+
+	/* parse led_playback_time */
+	sub_str = strsep(&str, ":");
+	if (sub_str) {
+		ret = kstrtoint(sub_str, 0, &led_playback_time);
+		if (ret)
+			return ret;
+		if (led_playback_time < 0 || led_playback_time > 15)
+			return -EINVAL;
+		led->led_playback.s_led_playback.led_playback_time =
+			led_playback_time;
+	} else {
+		led->led_playback.s_led_playback.led_playback_time = 15;
+	}
+
+	return 0;
+}

...

Quoted 22 lines
drivers/leds/leds-lp5812.c new file +22 -0
+static ssize_t led_auto_animation_show(struct kobject *kobj,
+		struct kobj_attribute *attr, char *buf)
+{
+	int ret;
+	char tmp_str[256] = {};
+	char usage[128] = {};
+	char *aeu_select = "AEU Select: ";
+	char *start_pause_time = "Start pause time: ";
+	char *stop_pause_time = "; Stop pause time: ";
+	char *led_playback_time = "; LED Playback time: ";
+	int aeu_selection, playback_time, start_pause, stop_pause;
+	struct lp5812_led *led = to_lp5812_led(kobj);
+	struct lp5812_chip *chip = led->priv;
+
+	sprintf(usage, "%s%s",
+	"Command usage: echo (aeu number):(start pause time):",
+	"(stop pause time):(playback time) > autonomous_animation");
+
+	mutex_lock(&chip->lock);
+	ret = led_get_autonomous_animation_config(led);
+	if (ret) {
+		ret = -EIO;

drivers/leds/leds-lp5812.c line 1393

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+		goto out;
+	}
+
+	/* parse config and feedback to userspace */
+	aeu_selection = led->led_playback.s_led_playback.aeu_selection;
+	playback_time = led->led_playback.s_led_playback.led_playback_time;
+	start_pause = led->start_stop_pause_time.s_time.second;
+	stop_pause = led->start_stop_pause_time.s_time.first;
+	if (aeu_selection == ONLY_AEU1) {
+		sprintf(tmp_str, "%s%s%s%s%s%s%s%s\n", aeu_select,

Maybe add a least 1 tab for all this parameters, to improve readability?

Quoted 25 lines
drivers/leds/leds-lp5812.c new file +25 -0
+		"Only use AEU1; ", start_pause_time,
+		time_name_array[start_pause], stop_pause_time,
+		time_name_array[stop_pause], led_playback_time,
+		led_playback_time_arr[playback_time]);
+	} else if (aeu_selection == AEU1_AEU2) {
+		sprintf(tmp_str, "%s%s%s%s%s%s%s%s\n", aeu_select,
+		"Use AEU1 and AEU2; ", start_pause_time,
+		time_name_array[start_pause], stop_pause_time,
+		time_name_array[stop_pause], led_playback_time,
+		led_playback_time_arr[playback_time]);
+	} else {
+		sprintf(tmp_str, "%s%s%s%s%s%s%s%s\n", aeu_select,
+		"Use AEU1,AEU2 and AEU3; ", start_pause_time,
+		time_name_array[start_pause], stop_pause_time,
+		time_name_array[stop_pause], led_playback_time,
+		led_playback_time_arr[playback_time]);
+	}
+	strcat(tmp_str, usage);
+	mutex_unlock(&chip->lock);
+	return sprintf(buf, "%s\n", tmp_str);
+
+out:
+	mutex_unlock(&chip->lock);
+	return ret;
+}

...

drivers/leds/leds-lp5812.c line 1534

Quoted 9 lines
drivers/leds/leds-lp5812.c new file +9 -0
+static ssize_t led_pwm_dimming_scale_store(struct kobject *kobj,
+		struct kobj_attribute *attr, const char *buf, size_t count)
+{
+	int val, ret;
+	struct lp5812_led *led = to_lp5812_led(kobj);
+	struct lp5812_chip *chip = led->priv;
+
+	if (sysfs_streq(buf, "linear"))
+		val = 0;

Maybe use directly LINEAR or EXPONENTIAL to simplify the code?

Quoted 14 lines
drivers/leds/leds-lp5812.c new file +14 -0
+	else if (sysfs_streq(buf, "exponential"))
+		val = 1;
+	else
+		return -EINVAL;
+
+	mutex_lock(&chip->lock);
+	ret = lp5812_set_pwm_dimming_scale(chip, led->led_number,
+			val ? EXPONENTIAL : LINEAR);
+	mutex_unlock(&chip->lock);
+	if (ret)
+		return -EIO;
+
+	return count;
+}

...

drivers/leds/leds-lp5812.c line 1598

Quoted 13 lines
drivers/leds/leds-lp5812.c new file +13 -0
+static struct attribute *led_kobj_attributes[] = {
+	&kobj_attr_enable.attr,
+	&kobj_attr_mode.attr,
+	&kobj_attr_manual_dc.attr,
+	&kobj_attr_manual_pwm.attr,
+	&kobj_attr_autonomous_dc.attr,
+	&kobj_attr_autonomous_animation.attr,
+	&kobj_attr_lod_lsd.attr,
+	&kobj_attr_auto_pwm_val.attr,
+	&kobj_attr_aep_status.attr,
+	&kobj_attr_pwm_phase_align.attr,
+	&kobj_attr_pwm_dimming_scale.attr,
+	NULL,

Nitpick: unneeded comma after a terminator

Quoted 1 line

+};

...

drivers/leds/leds-lp5812.c line 1739

Quoted 13 lines
drivers/leds/leds-lp5812.c new file +13 -0
+static ssize_t aeu_pwm4_store(struct kobject *kobj,
+		struct kobj_attribute *attr, const char *buf, size_t count)
+{
+	int val = 0;
+	int ret = 0;
+	struct anim_engine_unit *aeu = to_anim_engine_unit(kobj);
+	struct lp5812_chip *chip = aeu->led->priv;
+
+	ret = kstrtoint(buf, 0, &val);
+	if (ret)
+		return -EINVAL;
+	if (val < 0 || val > 255)
+		return -EINVAL; /* Invalid argument */

This comment is not really useful.

Quoted 18 lines
drivers/leds/leds-lp5812.c new file +18 -0
+
+	mutex_lock(&chip->lock);
+	ret = led_aeu_pwm_set_val(aeu, val, PWM4);
+	if (ret != 0) {
+		mutex_unlock(&chip->lock);
+		return -EIO;
+	}
+	mutex_unlock(&chip->lock);
+
+	return count;
+}
+
+static ssize_t aeu_pwm4_show(struct kobject *kobj,
+		struct kobj_attribute *attr, char *buf)
+{
+	int ret = 0;
+	u8 val = 0;
+	struct anim_engine_unit *aeu = to_anim_engine_unit(kobj);

drivers/leds/leds-lp5812.c line 1768

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+	struct lp5812_chip *chip = aeu->led->priv;
+
+	mutex_lock(&chip->lock);
+	ret = led_aeu_pwm_get_val(aeu, &val, PWM4);
+	mutex_unlock(&chip->lock);
+	if (ret)
+		return -EIO;
+
+	return sprintf(buf, "%d\n", val);
+

Maybe the core of aeu_pwm|14]_store() and aeu_pwm[14]_show() could be implemented only once, with an additional parameter for PWx?

}

...

Quoted 7 lines
drivers/leds/leds-lp5812.c new file +7 -0
+static ssize_t aeu_playback_time_show(struct kobject *kobj,
+		struct kobj_attribute *attr, char *buf)
+{
+	int ret = 0;
+	u8 val = 0;
+	struct anim_engine_unit *aeu = to_anim_engine_unit(kobj);
+	struct lp5812_chip *chip = aeu->led->priv;

drivers/leds/leds-lp5812.c line 2025

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+
+	mutex_lock(&chip->lock);
+	ret = led_aeu_playback_time_get_val(aeu, &val);
+	if (ret != 0) {
+		mutex_unlock(&chip->lock);
+		return -EIO;
+	}
+	mutex_unlock(&chip->lock);
+
+	return sprintf(buf, "%d\n", val);

sysfs_emit? (here and in mayne places)

Quoted 20 lines
drivers/leds/leds-lp5812.c new file +20 -0
+}
+
+static LP5812_KOBJ_ATTR_RW(pwm1, aeu_pwm1_show, aeu_pwm1_store);
+static LP5812_KOBJ_ATTR_RW(pwm2, aeu_pwm2_show, aeu_pwm2_store);
+static LP5812_KOBJ_ATTR_RW(pwm3, aeu_pwm3_show, aeu_pwm3_store);
+static LP5812_KOBJ_ATTR_RW(pwm4, aeu_pwm4_show, aeu_pwm4_store);
+static LP5812_KOBJ_ATTR_RW(pwm5, aeu_pwm5_show, aeu_pwm5_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t1, aeu_slope_time_t1_show,
+		aeu_slope_time_t1_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t2, aeu_slope_time_t2_show,
+		aeu_slope_time_t2_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t3, aeu_slope_time_t3_show,
+		aeu_slope_time_t3_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t4, aeu_slope_time_t4_show,
+		aeu_slope_time_t4_store);
+static LP5812_KOBJ_ATTR_RW(playback_time, aeu_playback_time_show,
+		aeu_playback_time_store);
+
+static struct attribute *aeu_kobj_attributes[] = {
+	&kobj_attr_pwm1.attr,

drivers/leds/leds-lp5812.c line 2055

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+	&kobj_attr_pwm2.attr,
+	&kobj_attr_pwm3.attr,
+	&kobj_attr_pwm4.attr,
+	&kobj_attr_pwm5.attr,
+	&kobj_attr_slope_time_t1.attr,
+	&kobj_attr_slope_time_t2.attr,
+	&kobj_attr_slope_time_t3.attr,
+	&kobj_attr_slope_time_t4.attr,
+	&kobj_attr_playback_time.attr,
+	NULL,

Nitpick: unneeded comma after a terminator

Quoted 57 lines
drivers/leds/leds-lp5812.c new file +57 -0
+};
+
+static void aeu_init_properties(struct lp5812_led *led)
+{
+	int i;
+
+	for (i = 0; i < MAX_AEU; i++) {
+		led->aeu[i].aeu_name = aeu_name_array[i];
+		led->aeu[i].aeu_number = i + 1;
+		led->aeu[i].led = led;
+		led->aeu[i].enabled = 0;
+		led->aeu[i].attr_group.attrs = aeu_kobj_attributes;
+		kobject_init(&led->aeu[i].kobj, &aeu_ktype);
+	}
+}
+
+static int lp5812_probe(struct i2c_client *client)
+{
+	struct lp5812_chip *chip;
+	int i;
+	int ret;
+	u8 val;
+
+	chip = devm_kzalloc(&client->dev, sizeof(struct lp5812_chip),
+			GFP_KERNEL);
+	if (!chip)
+		return -ENOMEM;
+	mutex_init(&chip->lock);
+	chip->i2c_cl = client;
+	chip->dev = &client->dev;
+	chip->regs = &regs;
+	chip->command = NONE;
+	chip->total_leds = MAX_LEDS;
+	chip->attr_group.name = "lp5812_chip_setup";
+	chip->attr_group.attrs = lp5812_chip_attributes;
+	chip->chip_leds_map = chip_leds_map;
+	chip->u_drive_mode.drive_mode_val = 0x10;
+	chip->u_scan_order.scan_order_val = 0x00;
+
+	/* initialize property for each led */
+	for (i = 0; i < MAX_LEDS; i++) {
+		chip->leds[i].led_name = led_name_array[i];
+		chip->leds[i].led_number = i;
+		chip->leds[i].anim_base_addr = anim_base_addr_array[i];
+		chip->leds[i].enable = 0; /* LED disable as default */
+		chip->leds[i].mode = MANUAL; /* manual mode as default */
+		chip->leds[i].priv = chip;
+		chip->leds[i].total_aeu = MAX_AEU;
+		chip->leds[i].led_playback.led_playback_val = 0;
+		chip->leds[i].start_stop_pause_time.time_val = 0;
+		/* sysfs for this led not be created */
+		chip->leds[i].is_sysfs_created = 0;
+		chip->leds[i].attr_group.attrs = led_kobj_attributes;
+		kobject_init(&chip->leds[i].kobj, &led_ktype);
+
+		/* init animation engine unit properties */
+		aeu_init_properties(&chip->leds[i]);

drivers/leds/leds-lp5812.c line 2122

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+
+		/* set autonomous animation config as default for all LEDs */
+		led_set_autonomous_animation_config(&chip->leds[i]);
+	}
+
+	i2c_set_clientdata(client, chip);
+
+	ret = sysfs_create_group(&chip->dev->kobj, &chip->attr_group);
+	if (ret) {
+		dev_err(chip->dev, "sysfs_create_group failed\n");

Maybe return dev_err_probe?

drivers/leds/leds-lp5812.c line 2129

Quoted 7 lines
drivers/leds/leds-lp5812.c new file +7 -0
+		return ret;
+	}
+
+	ret = lp5812_init_dev_config(chip, "tcmscan:4:0:1:2:3", 0);
+	if (ret) {
+		dev_err(chip->dev, "%s: lp5812_init_dev_config failed\n",
+			__func__);

Maybe return dev_err_probe?

drivers/leds/leds-lp5812.c line 2132

Quoted 3 lines
drivers/leds/leds-lp5812.c new file +3 -0
+		return ret;
+	}
+	/* initialize lp5812 chip */

Nitpick: this comment is not really useful, IMHO, the line just after should be enough

drivers/leds/leds-lp5812.c line 2133

Quoted 1 line
drivers/leds/leds-lp5812.c new file +1 -0
+	ret = lp5812_initialize(chip);

Missing error handling?

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+
+	/* code to verify i2c read/write ok or not */
+	lp5812_read(chip, (u16)DEV_CONFIG2, &val);
+
+	lp5812_write(chip, (u16)LED_A1_AUTO_BASE_ADRR, 0x14);
+	lp5812_read(chip, (u16)LED_A1_AUTO_BASE_ADRR, &val);
+	/* End code to verify i2c read/write*/
+
+	return 0;
+}

drivers/leds/leds-lp5812.c line 2153

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+
+static void lp5812_remove(struct i2c_client *client)
+{
+	struct lp5812_chip *chip = i2c_get_clientdata(client);
+
+	mutex_destroy(&chip->lock);
+	leds_remove_existed_sysfs(chip);
+	sysfs_remove_group(&chip->dev->kobj, &chip->attr_group);
+
+	/* Disable all Leds */

Nitpick: this comment is not really useful, IMHI, the line just after should be enough

drivers/leds/leds-lp5812.c line 2161

Quoted 8 lines
drivers/leds/leds-lp5812.c new file +8 -0
+	lp5812_disable_all_leds(chip);
+
+	/* Disable lp5812 device */
+	lp5812_enable_disable(chip, 0);
+}
+
+static const struct i2c_device_id lp5812_id[] = {
+	{ "lp5812", 0 },

Nitpick: unneeded explicit 0

drivers/leds/leds-lp5812.c line 2170

Quoted 9 lines
drivers/leds/leds-lp5812.c new file +9 -0
+	{ }
+};
+
+MODULE_DEVICE_TABLE(i2c, lp5812_id);
+
+#ifdef CONFIG_OF
+static const struct of_device_id of_lp5812_match[] = {
+	{ .compatible = "ti,lp5812", },
+	{/* NULL */},

Nitpick: unneeded comma after a terminator

Quoted 20 lines
drivers/leds/leds-lp5812.c new file +20 -0
+};
+
+MODULE_DEVICE_TABLE(of, of_lp5812_match);
+#endif
+
+static struct i2c_driver lp5812_driver = {
+	.driver = {
+		.name   = "lp5812",
+		.of_match_table = of_match_ptr(of_lp5812_match),
+	},
+	.probe          = lp5812_probe,
+	.remove         = lp5812_remove,
+	.id_table       = lp5812_id,
+};
+
+module_i2c_driver(lp5812_driver);
+
+MODULE_DESCRIPTION("Texas Instruments LP5812 LED Driver");
+MODULE_AUTHOR("Jared Zhou");
+MODULE_LICENSE("GPL");
#14 lore raw
In reply to Nam Tran
Quoted 2 lines · Nam Tran

The chip can drive LED matrix 4x3.
This driver enables LED control via I2C.

You still did not respond to comments from v1. I don't see it being addressed.

Quoted 4 lines

The driver is implemented in two parts:
- Core driver logic in leds-lp5812.c
- Common support functions in leds-lp5812-common.c

Why do you make two modules? This looks really unneccessary. Just compile them into one module.

Quoted 97 lines
---
 MAINTAINERS                       |    6 +
 drivers/leds/Kconfig              |   29 +
 drivers/leds/Makefile             |    2 +
 drivers/leds/leds-lp5812-common.c | 1023 ++++++++++++++
 drivers/leds/leds-lp5812-common.h |  323 +++++
 drivers/leds/leds-lp5812-regs.h   |   96 ++
 drivers/leds/leds-lp5812.c        | 2190 +++++++++++++++++++++++++++++
 7 files changed, 3669 insertions(+)
 create mode 100644 drivers/leds/leds-lp5812-common.c
 create mode 100644 drivers/leds/leds-lp5812-common.h
 create mode 100644 drivers/leds/leds-lp5812-regs.h
 create mode 100644 drivers/leds/leds-lp5812.c
MAINTAINERS +6 -0
index 2bd9f5132cab..773c7ad6a7b6 100644
@@ -23511,6 +23511,12 @@ M:	Nam Tran <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/leds/ti,lp5812.yaml
+F:	drivers/leds/Kconfig
+F:	drivers/leds/Makefile
+F:	drivers/leds/leds-lp5812-common.c
+F:	drivers/leds/leds-lp5812-common.h
+F:	drivers/leds/leds-lp5812-regs.h
+F:	drivers/leds/leds-lp5812.c
 
 TEXAS INSTRUMENTS' SYSTEM CONTROL INTERFACE (TISCI) PROTOCOL DRIVER
 M:	Nishanth Menon <[email protected]>
drivers/leds/Kconfig +29 -0
index 2b27d043921c..7af5ebf190a9 100644
@@ -483,6 +483,35 @@ config LEDS_LP5569
 	  Driver provides direct control via LED class and interface for
 	  programming the engines.
 
+config LEDS_LP5812
+	tristate "Enable LP5812 support LED matrix 4x3"
+	depends on LEDS_CLASS && I2C
+	depends on LEDS_CLASS_MULTICOLOR
+	help
+	  If you say Y here you get support for TI LP5812 LED driver.
+
+	  The LP5812 is an I2C-based RGB LED driver that supports a 4x3 LED matrix.
+	  It provides independent brightness control and color mixing for each LED.
+	  This driver integrates with the Linux LED framework and LED multicolor class.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called leds-lp5812.
+
+	  If unsure, say N.
+
+config LEDS_LP5812_COMMON
+	tristate "Common driver for TI LP5812"
+	depends on LEDS_CLASS
+	depends on LEDS_CLASS_MULTICOLOR
+	depends on I2C
+	help
+	  If you say Y here you get support common operation for TI LP5812 LED driver.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called leds-lp5812-common.
+
+	  If unsure, say N.
+
 config LEDS_LP8501
 	tristate "LED Support for TI LP8501 LED driver chip"
 	depends on LEDS_CLASS && I2C
drivers/leds/Makefile +2 -0
index 6ad52e219ec6..d3daae2d808c 100644
@@ -54,6 +54,8 @@ obj-$(CONFIG_LEDS_LP5523)		+= leds-lp5523.o
 obj-$(CONFIG_LEDS_LP5562)		+= leds-lp5562.o
 obj-$(CONFIG_LEDS_LP5569)		+= leds-lp5569.o
 obj-$(CONFIG_LEDS_LP55XX_COMMON)	+= leds-lp55xx-common.o
+obj-$(CONFIG_LEDS_LP5812) 		+= leds-lp5812.o
+obj-$(CONFIG_LEDS_LP5812_COMMON)	+= leds-lp5812-common.o
 obj-$(CONFIG_LEDS_LP8501)		+= leds-lp8501.o
 obj-$(CONFIG_LEDS_LP8788)		+= leds-lp8788.o
 obj-$(CONFIG_LEDS_LP8860)		+= leds-lp8860.o
drivers/leds/leds-lp5812-common.c new file +5 -0
new file mode 100644
index 000000000000..01157233507f
@@ -0,0 +1,1023 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * LP5812 Common Driver
+ *
+ * Copyright (C) 2025 Texas Instruments

drivers/leds/leds-lp5812-common.c line 15

Quoted 10 lines
drivers/leds/leds-lp5812-common.c new file +10 -0
+ *
+ * Author: Jared Zhou <[email protected]>
+ */
+
+#include "leds-lp5812-common.h"
+
+/*
+ * Function: lp5812_write
+ * Params:
+ * Return: 0 if success

No, use proper kerneldoc

Quoted 16 lines
drivers/leds/leds-lp5812-common.c new file +16 -0
+ */
+int lp5812_write(struct lp5812_chip *chip, u16 reg, u8 val)
+{
+	int ret;
+	u8 extracted_bits; /* save 9th and 8th bit of reg address */
+	struct i2c_msg msg;
+	u8 buf[2] = {(u8)(reg & 0xFF), val};
+
+	extracted_bits = (reg >> 8) & 0x03;
+	msg.addr = (chip->i2c_cl->addr << 2) | extracted_bits;
+	msg.flags = 0;
+	msg.len = sizeof(buf);
+	msg.buf = buf;
+
+	ret = i2c_transfer(chip->i2c_cl->adapter, &msg, 1);
+	if (ret != 1) {

drivers/leds/leds-lp5812-common.c line 41

Quoted 10 lines
drivers/leds/leds-lp5812-common.c new file +10 -0
+		dev_err(chip->dev, "i2c write error, register 0x%02X, ret=%d\n", reg, ret);
+		ret = ret < 0 ? ret : -EIO;
+	} else {
+		ret = 0;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(lp5812_write);
+

Missing kerneldoc. Every exported symbol must have kerneldoc.

Quoted 26 lines
drivers/leds/leds-lp5812-common.c new file +26 -0
+int lp5812_read(struct lp5812_chip *chip, u16 reg, u8 *val)
+{
+	int ret;
+	u8 ret_val;  /* lp5812_chip return value */
+	u8 extracted_bits; /* save 9th and 8th bit of reg address */
+	u8 converted_reg;  /* extracted 8bit from reg */
+	struct i2c_msg msgs[2];
+
+	extracted_bits = (reg >> 8) & 0x03;
+	converted_reg = (u8)(reg & 0xFF);
+
+	msgs[0].addr = (chip->i2c_cl->addr << 2) | extracted_bits;
+	msgs[0].flags = 0;
+	msgs[0].len = 1;
+	msgs[0].buf = &converted_reg;
+
+	msgs[1].addr = (chip->i2c_cl->addr << 2) | extracted_bits;
+	msgs[1].flags = I2C_M_RD;
+	msgs[1].len = 1;
+	msgs[1].buf = &ret_val;
+
+	ret = i2c_transfer(chip->i2c_cl->adapter, msgs, 2);
+	if (ret != 2) {
+		dev_err(chip->dev, "Read register 0x%02X error, ret=%d\n", reg, ret);
+		*val = 0;
+		ret = ret < 0 ? ret : -EIO;

drivers/leds/leds-lp5812-common.c line 77

Quoted 10 lines
drivers/leds/leds-lp5812-common.c new file +10 -0
+	} else {
+		*val = ret_val;
+		ret = 0;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(lp5812_read);
+
+int lp5812_update_bit(struct lp5812_chip *chip, u16 reg, u8 mask, u8 val)

Why this is not static?

Quoted 12 lines
drivers/leds/leds-lp5812-common.c new file +12 -0
+{
+	int ret;
+	u8 tmp;
+
+	ret = lp5812_read(chip, reg, &tmp);
+	if (ret)
+		return ret;
+
+	tmp &= ~mask;
+	tmp |= val & mask;
+
+	return lp5812_write(chip, reg, tmp);

drivers/leds/leds-lp5812-common.c line 99

Quoted 10 lines
drivers/leds/leds-lp5812-common.c new file +10 -0
+}
+
+/*
+ * Function: lp5812_read_tsd_config_status
+ * Description: read tsd config status register
+ * Param: chip --> struct lp5812_chip itself
+ *        reg_val
+ * Return: 0 if success
+ */
+int lp5812_read_tsd_config_status(struct lp5812_chip *chip, u8 *reg_val)

Why this is not static?

drivers/leds/leds-lp5812-common.c line 112

Quoted 13 lines
drivers/leds/leds-lp5812-common.c new file +13 -0
+{
+	int ret = 0;
+
+	if (!reg_val)
+		return -1;
+
+	ret = lp5812_read(chip, chip->regs->tsd_config_status_reg, reg_val);
+
+	return ret;
+}
+
+/*
+ * Function: lp5812_update_regs_config

Missing kerneldoc

Quoted 9 lines
drivers/leds/leds-lp5812-common.c new file +9 -0
+ * Description: update reg config register
+ * Param: chip --> struct lp5812_chip itself
+ * Return: 0 if success
+ */
+int lp5812_update_regs_config(struct lp5812_chip *chip)
+{
+	int ret;
+	u8 reg_val; /* save register value */
+

...

drivers/leds/leds-lp5812-common.c

Quoted 4 lines
drivers/leds/leds-lp5812-common.c new file +4 -0
+static struct drive_mode_led_map chip_leds_map[] = {
+	{
+		"direct_mode",
+		(const char *[]){LED0, LED1, LED2, LED3, NULL},

Drop the cast.

Quoted 6 lines
drivers/leds/leds-lp5812-common.c new file +6 -0
+	},
+	{
+		"tcmscan:1:0", /* tcm 1 scan; scan order 0 out0 */
+		(const char *[]){LED_A0, LED_A1, LED_A2, NULL},
+	},
+	{

drivers/leds/leds-lp5812-common.c

Quoted 10 lines
drivers/leds/leds-lp5812-common.c new file +10 -0
+		"tcmscan:1:1", /* tcm 1 scan; scan order 0 out1 */
+		(const char *[]){LED_B0, LED_B1, LED_B2, NULL},
+	},
+	{
+		"tcmscan:1:2", /* tcm 1 scan; scan order 0 out2 */
+		(const char *[]){LED_C0, LED_C1, LED_C2, NULL},
+	},
+	{
+		"tcmscan:1:3", /* tcm 1 scan; scan order 0 out3 */
+		(const char *[]){LED_D0, LED_D1, LED_D2, NULL},

What is all this here?

How LED controller with so little properties have so complicated driver?

Quoted 11 lines
drivers/leds/leds-lp5812-common.c new file +10 -0
+	},
+	{ /* tcm 2 scan, scan order 0 out0; scan order 1 out1 */
+		"tcmscan:2:0:1",
+		(const char *[]){LED_A0, LED_A1, LED_A2, LED_B0, LED_B1, LED_B2,
+		NULL},
+	},
+	{ /* tcm 2 scan, scan order 0 out0; scan order 1 out2 */
+		"tcmscan:2:0:2",
+		(const char *[]){LED_A0, LED_A1, LED_A2, LED_C0, LED_C1, LED_C2,
+		NULL},
 

drivers/leds/leds-lp5812-common.c

Quoted 10 lines
drivers/leds/leds-lp5812-common.c new file +9 -0
 
+static void led_kobj_release(struct kobject *kobj)
+{
+	kfree(kobj);
+}
+
+static void aeu_kobj_release(struct kobject *kobj)
+{
+	kfree(kobj);
+}

What is all this? Why do you create your own kobjects?

Quoted 5 lines
drivers/leds/leds-lp5812-common.c new file +5 -0
+
+static const struct kobj_type led_ktype = {
+	.release = led_kobj_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+};

drivers/leds/leds-lp5812-common.c

Quoted 10 lines
drivers/leds/leds-lp5812-common.c new file +8 -0
+
+static const struct kobj_type aeu_ktype = {
+	.release = aeu_kobj_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+};
 
 
+static ssize_t device_reset_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t len)

NAK.

Sorry, you just cannot create whatever interfaces you want. You must use standard LED interfaces for normal LED operations. None of these sysfs are needed for device control.

Respond to this comment that you understood it (you ignored all previous comments).

Quoted 32 lines
drivers/leds/leds-lp5812-common.c new file +32 -0
+{
+	int reset;
+	int ret;
+	struct lp5812_chip *chip = i2c_get_clientdata(to_i2c_client(dev));
+
+	ret = kstrtoint(buf, 0, &reset);
+	if (ret)
+		return ret;
+
+	if (reset != 1)
+		return -EINVAL; /* Invalid argument */
+
+	/* reset hardware */
+	mutex_lock(&chip->lock);
+	lp5812_reset(chip);
+	msleep(1000);
+	/* set back manual mode as default for all LEDs */
+	lp5812_write(chip, (u16)DEV_CONFIG3, 0x00);
+	lp5812_write(chip, (u16)DEV_CONFIG4, 0x00);
+	lp5812_update_regs_config(chip);
+	mutex_unlock(&chip->lock);
+
+	/* Update sysfs based on default mode when hardware reseted*/
+	ret = lp5812_init_dev_config(chip, "direct_mode", 1);
+	if (ret) {
+		dev_err(dev, "%s: lp5812_init_dev_config failed\n",
+			__func__);
+		return ret;
+	}
+
+	return len;
+}

...

Quoted 5 lines
drivers/leds/leds-lp5812-common.c new file +5 -0
+static LP5812_KOBJ_ATTR_RW(pwm1, aeu_pwm1_show, aeu_pwm1_store);
+static LP5812_KOBJ_ATTR_RW(pwm2, aeu_pwm2_show, aeu_pwm2_store);
+static LP5812_KOBJ_ATTR_RW(pwm3, aeu_pwm3_show, aeu_pwm3_store);
+static LP5812_KOBJ_ATTR_RW(pwm4, aeu_pwm4_show, aeu_pwm4_store);
+static LP5812_KOBJ_ATTR_RW(pwm5, aeu_pwm5_show, aeu_pwm5_store);

drivers/leds/leds-lp5812-common.c

Quoted 10 lines
drivers/leds/leds-lp5812-common.c new file +10 -0
+static LP5812_KOBJ_ATTR_RW(slope_time_t1, aeu_slope_time_t1_show,
+		aeu_slope_time_t1_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t2, aeu_slope_time_t2_show,
+		aeu_slope_time_t2_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t3, aeu_slope_time_t3_show,
+		aeu_slope_time_t3_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t4, aeu_slope_time_t4_show,
+		aeu_slope_time_t4_store);
+static LP5812_KOBJ_ATTR_RW(playback_time, aeu_playback_time_show,
+		aeu_playback_time_store);

What is all this?

...

Quoted 39 lines
drivers/leds/leds-lp5812-common.c new file +39 -0
+static int lp5812_probe(struct i2c_client *client)
+{
+	struct lp5812_chip *chip;
+	int i;
+	int ret;
+	u8 val;
+
+	chip = devm_kzalloc(&client->dev, sizeof(struct lp5812_chip),
+			GFP_KERNEL);
+	if (!chip)
+		return -ENOMEM;
+	mutex_init(&chip->lock);
+	chip->i2c_cl = client;
+	chip->dev = &client->dev;
+	chip->regs = &regs;
+	chip->command = NONE;
+	chip->total_leds = MAX_LEDS;
+	chip->attr_group.name = "lp5812_chip_setup";
+	chip->attr_group.attrs = lp5812_chip_attributes;
+	chip->chip_leds_map = chip_leds_map;
+	chip->u_drive_mode.drive_mode_val = 0x10;
+	chip->u_scan_order.scan_order_val = 0x00;
+
+	/* initialize property for each led */
+	for (i = 0; i < MAX_LEDS; i++) {
+		chip->leds[i].led_name = led_name_array[i];
+		chip->leds[i].led_number = i;
+		chip->leds[i].anim_base_addr = anim_base_addr_array[i];
+		chip->leds[i].enable = 0; /* LED disable as default */
+		chip->leds[i].mode = MANUAL; /* manual mode as default */
+		chip->leds[i].priv = chip;
+		chip->leds[i].total_aeu = MAX_AEU;
+		chip->leds[i].led_playback.led_playback_val = 0;
+		chip->leds[i].start_stop_pause_time.time_val = 0;
+		/* sysfs for this led not be created */
+		chip->leds[i].is_sysfs_created = 0;
+		chip->leds[i].attr_group.attrs = led_kobj_attributes;
+		kobject_init(&chip->leds[i].kobj, &led_ktype);
+

drivers/leds/leds-lp5812-common.c

Quoted 10 lines
drivers/leds/leds-lp5812-common.c new file +10 -0
+		/* init animation engine unit properties */
+		aeu_init_properties(&chip->leds[i]);
+
+		/* set autonomous animation config as default for all LEDs */
+		led_set_autonomous_animation_config(&chip->leds[i]);
+	}
+
+	i2c_set_clientdata(client, chip);
+
+	ret = sysfs_create_group(&chip->dev->kobj, &chip->attr_group);

You need sysfs ABI documentation.

drivers/leds/leds-lp5812-common.c

Quoted 4 lines
drivers/leds/leds-lp5812-common.c new file +4 -0
+	if (ret) {
+		dev_err(chip->dev, "sysfs_create_group failed\n");
+		return ret;
+	}

Best regards,
Krzysztof

author maintainer
#15 lore raw

Below, I will properly address your remaining concerns in a better format.

Quoted 7 lines · Krzysztof Kozlowski
Quoted 4 lines

The driver is implemented in two parts:
- Core driver logic in leds-lp5812.c
- Common support functions in leds-lp5812-common.c

Why do you make two modules? This looks really unneccessary. Just compile them into one module.

I will merge source code into a file only.

Quoted 29 lines

drivers/leds/leds-lp5812-common.c line 15

Quoted 6 lines
drivers/leds/leds-lp5812-common.c new file +6 -0
+#include "leds-lp5812-common.h"
+
+/*
+ * Function: lp5812_write
+ * Params:
+ * Return: 0 if success

No, use proper kerneldoc

Quoted 20 lines

+ */

drivers/leds/leds-lp5812-common.c new file +19 -0
+int lp5812_write(struct lp5812_chip *chip, u16 reg, u8 val)
+{
+	int ret;
+	u8 extracted_bits; /* save 9th and 8th bit of reg address */
+	struct i2c_msg msg;
+	u8 buf[2] = {(u8)(reg & 0xFF), val};
+
+	extracted_bits = (reg >> 8) & 0x03;
+	msg.addr = (chip->i2c_cl->addr << 2) | extracted_bits;
+	msg.flags = 0;
+	msg.len = sizeof(buf);
+	msg.buf = buf;
+
+	ret = i2c_transfer(chip->i2c_cl->adapter, &msg, 1);
+	if (ret != 1) {
+		dev_err(chip->dev, "i2c write error, register 0x%02X, ret=%d\n", reg, ret);
+		ret = ret < 0 ? ret : -EIO;
+	} else {
+		ret = 0;
Quoted 8 lines

drivers/leds/leds-lp5812-common.c line 41

Quoted 6 lines
drivers/leds/leds-lp5812-common.c new file +6 -0
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(lp5812_write);
+

Missing kerneldoc. Every exported symbol must have kerneldoc.

If I merge leds-lp5812-common.c into leds-lp5812.c, the functions will no longer need to be exported, as they will only be used internally within a single compilation unit. As a result, kernel doc for these symbols will no longer be mandatory.
Would you agree that this approach eliminates the need for separate kernel doc entries for these functions?

Quoted 30 lines
Quoted 30 lines
drivers/leds/leds-lp5812-common.c new file +30 -0
+int lp5812_read(struct lp5812_chip *chip, u16 reg, u8 *val)
+{
+	int ret;
+	u8 ret_val;  /* lp5812_chip return value */
+	u8 extracted_bits; /* save 9th and 8th bit of reg address */
+	u8 converted_reg;  /* extracted 8bit from reg */
+	struct i2c_msg msgs[2];
+
+	extracted_bits = (reg >> 8) & 0x03;
+	converted_reg = (u8)(reg & 0xFF);
+
+	msgs[0].addr = (chip->i2c_cl->addr << 2) | extracted_bits;
+	msgs[0].flags = 0;
+	msgs[0].len = 1;
+	msgs[0].buf = &converted_reg;
+
+	msgs[1].addr = (chip->i2c_cl->addr << 2) | extracted_bits;
+	msgs[1].flags = I2C_M_RD;
+	msgs[1].len = 1;
+	msgs[1].buf = &ret_val;
+
+	ret = i2c_transfer(chip->i2c_cl->adapter, msgs, 2);
+	if (ret != 2) {
+		dev_err(chip->dev, "Read register 0x%02X error, ret=%d\n", reg, ret);
+		*val = 0;
+		ret = ret < 0 ? ret : -EIO;
+	} else {
+		*val = ret_val;
+		ret = 0;
+	}
Quoted 8 lines

drivers/leds/leds-lp5812-common.c line 77

Quoted 6 lines
drivers/leds/leds-lp5812-common.c new file +6 -0
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(lp5812_read);
+
+int lp5812_update_bit(struct lp5812_chip *chip, u16 reg, u8 mask, u8 val)

Why this is not static?

I will change it to a static function.

Quoted 16 lines
Quoted 16 lines
drivers/leds/leds-lp5812-common.c new file +16 -0
+{
+	int ret;
+	u8 tmp;
+
+	ret = lp5812_read(chip, reg, &tmp);
+	if (ret)
+		return ret;
+
+	tmp &= ~mask;
+	tmp |= val & mask;
+
+	return lp5812_write(chip, reg, tmp);
+}
+
+/*
+ * Function: lp5812_read_tsd_config_status
Quoted 8 lines
Quoted 6 lines

+ * Description: read tsd config status register
+ * Param: chip --> struct lp5812_chip itself
+ * reg_val
+ * Return: 0 if success
+ */
+int lp5812_read_tsd_config_status(struct lp5812_chip *chip, u8 *reg_val)

Why this is not static?

I will change it to a static function.

Quoted 7 lines
Quoted 7 lines
drivers/leds/leds-lp5812-common.c new file +7 -0
+{
+	int ret = 0;
+
+	if (!reg_val)
+		return -1;
+
+	ret = lp5812_read(chip, chip->regs->tsd_config_status_reg, reg_val);
Quoted 8 lines

drivers/leds/leds-lp5812-common.c line 112

Quoted 6 lines
drivers/leds/leds-lp5812-common.c new file +6 -0
+
+	return ret;
+}
+
+/*
+ * Function: lp5812_update_regs_config

Missing kerneldoc

As mentioned above, I won't use EXPORT_SYMBOL_GPL for this function.

Quoted 11 lines
Quoted 9 lines

+ * Description: update reg config register
+ * Param: chip --> struct lp5812_chip itself
+ * Return: 0 if success
+ */

drivers/leds/leds-lp5812-common.c new file +5 -0
+int lp5812_update_regs_config(struct lp5812_chip *chip)
+{
+	int ret;
+	u8 reg_val; /* save register value */
+

...

As mentioned above, I won't use EXPORT_SYMBOL_GPL for this function.

Quoted 7 lines

drivers/leds/leds-lp5812.c line 27

Quoted 5 lines
drivers/leds/leds-lp5812.c new file +4 -0
+static struct drive_mode_led_map chip_leds_map[] = {
+	{
+		"direct_mode",
+		(const char *[]){LED0, LED1, LED2, LED3, NULL},

Drop the cast.

I will drop them.

Quoted 20 lines
Quoted 6 lines
drivers/leds/leds-lp5812.c new file +6 -0
+	},
+	{
+		"tcmscan:1:0", /* tcm 1 scan; scan order 0 out0 */
+		(const char *[]){LED_A0, LED_A1, LED_A2, NULL},
+	},
+	{

drivers/leds/leds-lp5812.c line 43

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+		"tcmscan:1:1", /* tcm 1 scan; scan order 0 out1 */
+		(const char *[]){LED_B0, LED_B1, LED_B2, NULL},
+	},
+	{
+		"tcmscan:1:2", /* tcm 1 scan; scan order 0 out2 */
+		(const char *[]){LED_C0, LED_C1, LED_C2, NULL},
+	},
+	{
+		"tcmscan:1:3", /* tcm 1 scan; scan order 0 out3 */
+		(const char *[]){LED_D0, LED_D1, LED_D2, NULL},

What is all this here?

Quoted 1 line

How LED controller with so little properties have so complicated driver?

This hardware has 3 main modes. Each mode has many options. My idea is to create a driver that supports all capabilities of the hardware. Therefore, when the user updates the mode of hardware, it will create specific device files.
Refer: https://dev.ti.com/gallery/view/LED/LP581x/ver/0.16.0/

Quoted 12 lines
Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+	},
+	{ /* tcm 2 scan, scan order 0 out0; scan order 1 out1 */
+		"tcmscan:2:0:1",
+		(const char *[]){LED_A0, LED_A1, LED_A2, LED_B0, LED_B1, LED_B2,
+		NULL},
+	},
+	{ /* tcm 2 scan, scan order 0 out0; scan order 1 out2 */
+		"tcmscan:2:0:2",
+		(const char *[]){LED_A0, LED_A1, LED_A2, LED_C0, LED_C1, LED_C2,
+		NULL},
Quoted 11 lines

drivers/leds/leds-lp5812.c line 300

Quoted 9 lines
drivers/leds/leds-lp5812.c new file +9 -0
+static void led_kobj_release(struct kobject *kobj)
+{
+	kfree(kobj);
+}
+
+static void aeu_kobj_release(struct kobject *kobj)
+{
+	kfree(kobj);
+}

What is all this? Why do you create your own kobjects?

Same as previous answer, I need to create kobjects to support many interfaces.

Quoted 18 lines
Quoted 5 lines
drivers/leds/leds-lp5812.c new file +5 -0
+
+static const struct kobj_type led_ktype = {
+	.release = led_kobj_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+};

drivers/leds/leds-lp5812.c

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +8 -0
+
+static const struct kobj_type aeu_ktype = {
+	.release = aeu_kobj_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+};
 
 
+static ssize_t device_reset_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf, size_t len)

NAK.

Quoted 6 lines

Sorry, you just cannot create whatever interfaces you want. You must use standard LED interfaces for normal LED operations. None of these sysfs are needed for device control.

Respond to this comment that you understood it (you ignored all previous comments).

Based on LP5812 datasheet, it is not normal LED operations. It supports many modes, each mode we can control specific leds (user can enable/disable leds). Each led has normal mode, autonomous mode,… That is why I want to create interfaces.
Based on your concern, I think that my driver may not be compatible with normal LED operations. Given that the LP5812 driver has advanced functionality beyond basic LED control, would it be acceptable to place the driver in a different location instead of drivers/led/? If so, could you suggest a more suitable location? I am open to discussions on how best to integrate these features while maintaining compliance with kernel standards. Please let me know your thoughts on how we can refine the approach.

Quoted 10 lines
Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+static LP5812_KOBJ_ATTR_RW(pwm1, aeu_pwm1_show, aeu_pwm1_store);
+static LP5812_KOBJ_ATTR_RW(pwm2, aeu_pwm2_show, aeu_pwm2_store);
+static LP5812_KOBJ_ATTR_RW(pwm3, aeu_pwm3_show, aeu_pwm3_store);
+static LP5812_KOBJ_ATTR_RW(pwm4, aeu_pwm4_show, aeu_pwm4_store);
+static LP5812_KOBJ_ATTR_RW(pwm5, aeu_pwm5_show, aeu_pwm5_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t1, aeu_slope_time_t1_show,
+		aeu_slope_time_t1_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t2, aeu_slope_time_t2_show,
+		aeu_slope_time_t2_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t3, aeu_slope_time_t3_show,
Quoted 8 lines

drivers/leds/leds-lp5812.c line 2042

Quoted 5 lines
drivers/leds/leds-lp5812.c new file +5 -0
+		aeu_slope_time_t3_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t4, aeu_slope_time_t4_show,
+		aeu_slope_time_t4_store);
+static LP5812_KOBJ_ATTR_RW(playback_time, aeu_playback_time_show,
+		aeu_playback_time_store);

What is all this?

In autonomous mode, we can blink leds with specific PWM, delay, slope …
Refer: chapter 7.3.4 from https://www.ti.com/lit/ds/symlink/lp5812.pdf?ts=1741765622088&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FLP5812

Quoted 44 lines
Quoted 44 lines
drivers/leds/leds-lp5812.c new file +44 -0
+static int lp5812_probe(struct i2c_client *client)
+{
+	struct lp5812_chip *chip;
+	int i;
+	int ret;
+	u8 val;
+
+	chip = devm_kzalloc(&client->dev, sizeof(struct lp5812_chip),
+			GFP_KERNEL);
+	if (!chip)
+		return -ENOMEM;
+	mutex_init(&chip->lock);
+	chip->i2c_cl = client;
+	chip->dev = &client->dev;
+	chip->regs = &regs;
+	chip->command = NONE;
+	chip->total_leds = MAX_LEDS;
+	chip->attr_group.name = "lp5812_chip_setup";
+	chip->attr_group.attrs = lp5812_chip_attributes;
+	chip->chip_leds_map = chip_leds_map;
+	chip->u_drive_mode.drive_mode_val = 0x10;
+	chip->u_scan_order.scan_order_val = 0x00;
+
+	/* initialize property for each led */
+	for (i = 0; i < MAX_LEDS; i++) {
+		chip->leds[i].led_name = led_name_array[i];
+		chip->leds[i].led_number = i;
+		chip->leds[i].anim_base_addr = anim_base_addr_array[i];
+		chip->leds[i].enable = 0; /* LED disable as default */
+		chip->leds[i].mode = MANUAL; /* manual mode as default */
+		chip->leds[i].priv = chip;
+		chip->leds[i].total_aeu = MAX_AEU;
+		chip->leds[i].led_playback.led_playback_val = 0;
+		chip->leds[i].start_stop_pause_time.time_val = 0;
+		/* sysfs for this led not be created */
+		chip->leds[i].is_sysfs_created = 0;
+		chip->leds[i].attr_group.attrs = led_kobj_attributes;
+		kobject_init(&chip->leds[i].kobj, &led_ktype);
+
+		/* init animation engine unit properties */
+		aeu_init_properties(&chip->leds[i]);
+
+		/* set autonomous animation config as default for all LEDs */
+		led_set_autonomous_animation_config(&chip->leds[i]);
Quoted 8 lines

drivers/leds/leds-lp5812.c line 2120

Quoted 5 lines
drivers/leds/leds-lp5812.c new file +5 -0
+	}
+
+	i2c_set_clientdata(client, chip);
+
+	ret = sysfs_create_group(&chip->dev->kobj, &chip->attr_group);

You need sysfs ABI documentation.

I will add a new entry under Documentation/ABI/testing/ to document the exposed sysfs attributes for the LP5812 driver in the next patch.

Best regards,
Nam Tran

#16 lore raw
In reply to Nam Tran
kernel test robot noticed the following build errors:

Hi Nam,

kernel test robot noticed the following build errors:

[auto build test ERROR on lee-leds/for-leds-next]
[also build test ERROR on robh/for-next linus/master v6.14-rc5 next-20250307] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Nam-Tran/dt-bindings-leds-Add-LP5812-LED-driver/20250307-012604
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git for-leds-next
patch link:    https://lore.kernel.org/r/20250306172126.24667-4-trannamatk%40gmail.com
patch subject: [PATCH v3 3/3] leds: add new LED driver for TI LP5812
config: x86_64-randconfig-005-20250310 (https://download.01.org/0day-ci/archive/20250310/[email protected]/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250310/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "led_set_autonomous_animation_config" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_initialize" [drivers/leds/leds-lp5812.ko] undefined!
ERROR: modpost: "lp5812_read" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_write" [drivers/leds/leds-lp5812.ko] undefined!
ERROR: modpost: "lp5812_disable_all_leds" [drivers/leds/leds-lp5812.ko] undefined!
ERROR: modpost: "lp5812_enable_disable" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_device_command" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_reset" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_update_regs_config" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_fault_clear" [drivers/leds/leds-lp5812.ko] undefined!

WARNING: modpost: suppressed 23 unresolved symbol warnings because there were too many)

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#17 lore raw
In reply to Nam Tran
kernel test robot noticed the following build errors:

Hi Nam,

kernel test robot noticed the following build errors:

[auto build test ERROR on lee-leds/for-leds-next]
[also build test ERROR on robh/for-next linus/master v6.14-rc6 next-20250307] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Nam-Tran/dt-bindings-leds-Add-LP5812-LED-driver/20250307-012604
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git for-leds-next
patch link:    https://lore.kernel.org/r/20250306172126.24667-4-trannamatk%40gmail.com
patch subject: [PATCH v3 3/3] leds: add new LED driver for TI LP5812
config: x86_64-randconfig-077-20250310 (https://download.01.org/0day-ci/archive/20250311/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250311/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>, old ones prefixed by <<):

WARNING: modpost: missing MODULE_DESCRIPTION() in mm/kasan/kasan_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/slub_kunit.o

>> ERROR: modpost: "lp5812_disable_all_leds" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_enable_disable" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_set_pwm_dimming_scale" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_get_pwm_dimming_scale" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_read" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_set_phase_align" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_get_phase_align" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_read_aep_status" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_read_auto_pwm_value" [drivers/leds/leds-lp5812.ko] undefined!
>> ERROR: modpost: "lp5812_read_lsd_status" [drivers/leds/leds-lp5812.ko] undefined!

WARNING: modpost: suppressed 23 unresolved symbol warnings because there were too many)

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer NAK
#18 lore raw
In reply to Nam Tran

From: Nam Tran <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
Cc: Rob Herring <[email protected]>, Conor Dooley <[email protected]> Pavel Machek <[email protected]>, Lee Jones <[email protected]>, [email protected], [email protected], [email protected]

I sincerely apologize for not addressing all of your previous comments earlier. That was not my intention, and I truly appreciate the time and effort you have put into reviewing my patch. Below, I would like to properly address your concerns.

Quoted 2 lines · Nam Tran

The chip can drive LED matrix 4x3.
This driver enables LED control via I2C.

You still did not respond to comments from v1. I don't see it being addressed.

Nam: I am sorry. This is my mistake. I think that I just need to update source code based on your comments and submit a new patch. This is the first time I try to update a new thing to the Linux Kernel. I will give answer inline your message for tracing easily.

In previous comment you have a question
"Why none of the 10 existing drivers fit for your device?"

Nam: I have carefully reviewed the existing LED drivers in the kernel, but none of them fully support the advanced capabilities of the LP5812. Unlike basic LED controllers, the LP5812 has difference features and register For more detail, please refer to this documentation https://www.ti.com/lit/ds/symlink/lp5812.pdf?ts=1741765622088&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FLP5812

Quoted 4 lines

The driver is implemented in two parts:
- Core driver logic in leds-lp5812.c
- Common support functions in leds-lp5812-common.c

Why do you make two modules? This looks really unneccessary. Just compile them into one module. No, use proper kerneldoc Missing kerneldoc. Every exported symbol must have kerneldoc. Why this is not static?

Nam: I will merge source code into a file only. Therefore, I don’t need to export symbols here.

Quoted 12 lines
drivers/leds/leds-lp5812-common.c new file +12 -0
+{
+     int ret;
+     u8 tmp;
+
+     ret = lp5812_read(chip, reg, &tmp);
+     if (ret)
+             return ret;
+
+     tmp &= ~mask;
+     tmp |= val & mask;
+
+     return lp5812_write(chip, reg, tmp);

drivers/leds/leds-lp5812-common.c line 99

Quoted 10 lines
drivers/leds/leds-lp5812-common.c new file +10 -0
+}
+
+/*
+ * Function: lp5812_read_tsd_config_status
+ * Description: read tsd config status register
+ * Param: chip --> struct lp5812_chip itself
+ *        reg_val
+ * Return: 0 if success
+ */
+int lp5812_read_tsd_config_status(struct lp5812_chip *chip, u8 *reg_val)

Why this is not static?

Nam: I will change it to a static function.

drivers/leds/leds-lp5812-common.c line 112

Quoted 13 lines
drivers/leds/leds-lp5812-common.c new file +13 -0
+{
+     int ret = 0;
+
+     if (!reg_val)
+             return -1;
+
+     ret = lp5812_read(chip, chip->regs->tsd_config_status_reg, reg_val);
+
+     return ret;
+}
+
+/*
+ * Function: lp5812_update_regs_config

Missing kerneldoc

Nam: If I merge leds-lp5812-common.c into leds-lp5812.c, the functions will no longer need to be exported, as they will only be used internally within a single compilation unit. As a result, kernel doc for these symbols will no longer be mandatory. Would you agree that this approach eliminates the need for separate kernel doc entries for these functions?

Quoted 9 lines

+ * Description: update reg config register
+ * Param: chip --> struct lp5812_chip itself
+ * Return: 0 if success
+ */

drivers/leds/leds-lp5812-common.c new file +5 -0
+int lp5812_update_regs_config(struct lp5812_chip *chip)
+{
+     int ret;
+     u8 reg_val; /* save register value */
+

...

drivers/leds/leds-lp5812.c line 27

Quoted 4 lines
drivers/leds/leds-lp5812.c new file +4 -0
+static struct drive_mode_led_map chip_leds_map[] = {
+     {
+             "direct_mode",
+             (const char *[]){LED0, LED1, LED2, LED3, NULL},

Drop the cast.
Nam: I will drop them.

Quoted 6 lines
drivers/leds/leds-lp5812.c new file +6 -0
+     },
+     {
+             "tcmscan:1:0", /* tcm 1 scan; scan order 0 out0 */
+             (const char *[]){LED_A0, LED_A1, LED_A2, NULL},
+     },
+     {

drivers/leds/leds-lp5812.c line 43

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+             "tcmscan:1:1", /* tcm 1 scan; scan order 0 out1 */
+             (const char *[]){LED_B0, LED_B1, LED_B2, NULL},
+     },
+     {
+             "tcmscan:1:2", /* tcm 1 scan; scan order 0 out2 */
+             (const char *[]){LED_C0, LED_C1, LED_C2, NULL},
+     },
+     {
+             "tcmscan:1:3", /* tcm 1 scan; scan order 0 out3 */
+             (const char *[]){LED_D0, LED_D1, LED_D2, NULL},

What is all this here?

How LED controller with so little properties have so complicated driver?

Nam: This hardware has 7 modes. Each mode has many options. My idea is to create a driver that supports all capabilities of the hardware. Therefore, when the user updates the mode of hardware, it will create specific device files.
Refer: https://dev.ti.com/gallery/view/LED/LP581x/ver/0.16.0/

Quoted 11 lines
(quoted diff) +10 -0
+     },
+     { /* tcm 2 scan, scan order 0 out0; scan order 1 out1 */
+             "tcmscan:2:0:1",
+             (const char *[]){LED_A0, LED_A1, LED_A2, LED_B0, LED_B1, LED_B2,
+             NULL},
+     },
+     { /* tcm 2 scan, scan order 0 out0; scan order 1 out2 */
+             "tcmscan:2:0:2",
+             (const char *[]){LED_A0, LED_A1, LED_A2, LED_C0, LED_C1, LED_C2,
+             NULL},
 

Review

Quoted 10 lines
(quoted diff) +9 -0
 
+static void led_kobj_release(struct kobject *kobj)
+{
+     kfree(kobj);
+}
+
+static void aeu_kobj_release(struct kobject *kobj)
+{
+     kfree(kobj);
+}

What is all this? Why do you create your own kobjects?

Nam: Same as previous answer, I need to create kobjects to support many interfaces.

Quoted 5 lines
drivers/leds/leds-lp5812.c new file +5 -0
+
+static const struct kobj_type led_ktype = {
+     .release = led_kobj_release,
+     .sysfs_ops = &kobj_sysfs_ops,
+};

drivers/leds/leds-lp5812.c

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +8 -0
+
+static const struct kobj_type aeu_ktype = {
+     .release = aeu_kobj_release,
+     .sysfs_ops = &kobj_sysfs_ops,
+};
 
 
+static ssize_t device_reset_store(struct device *dev,
+             struct device_attribute *attr,
+             const char *buf, size_t len)

NAK.

Sorry, you just cannot create whatever interfaces you want. You must use standard LED interfaces for normal LED operations. None of these sysfs are needed for device control.

Respond to this comment that you understood it (you ignored all previous comments). …

Nam: based on LP5812 datasheet, it is not normal LED operations. It supports many modes, each mode we can control specific leds (user can enable/disable leds). Each led has normal mode, autonomous mode … That is why I want to create interfaces.

Based on your concern, I think that my driver may not be compatible with normal LED operations. Given that the LP5812 driver has advanced functionality beyond basic LED control, would it be acceptable to place the driver in a different location instead of drivers/led/? If so, could you suggest a more suitable location?

I am open to discussions on how best to integrate these features while maintaining compliance with kernel standards. Please let me know your thoughts on how we can refine the approach.

Quoted 5 lines
drivers/leds/leds-lp5812.c new file +5 -0
+static LP5812_KOBJ_ATTR_RW(pwm1, aeu_pwm1_show, aeu_pwm1_store);
+static LP5812_KOBJ_ATTR_RW(pwm2, aeu_pwm2_show, aeu_pwm2_store);
+static LP5812_KOBJ_ATTR_RW(pwm3, aeu_pwm3_show, aeu_pwm3_store);
+static LP5812_KOBJ_ATTR_RW(pwm4, aeu_pwm4_show, aeu_pwm4_store);
+static LP5812_KOBJ_ATTR_RW(pwm5, aeu_pwm5_show, aeu_pwm5_store);

drivers/leds/leds-lp5812.c line 2042

Quoted 10 lines
drivers/leds/leds-lp5812.c new file +10 -0
+static LP5812_KOBJ_ATTR_RW(slope_time_t1, aeu_slope_time_t1_show,
+             aeu_slope_time_t1_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t2, aeu_slope_time_t2_show,
+             aeu_slope_time_t2_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t3, aeu_slope_time_t3_show,
+             aeu_slope_time_t3_store);
+static LP5812_KOBJ_ATTR_RW(slope_time_t4, aeu_slope_time_t4_show,
+             aeu_slope_time_t4_store);
+static LP5812_KOBJ_ATTR_RW(playback_time, aeu_playback_time_show,
+             aeu_playback_time_store);

What is all this?

Nam: In autonomous mode, we can blink leds with specific PWM, delay, slope …
Refer: chapter 7.3.4 from https://www.ti.com/lit/ds/symlink/lp5812.pdf?ts=1741765622088&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FLP5812

drivers/leds/leds-lp5812.c line 2120

Quoted 12 lines
drivers/leds/leds-lp5812.c new file +12 -0
+static int lp5812_probe(struct i2c_client *client)
+{
+     struct lp5812_chip *chip;
+     int i; > +             aeu_init_properties(&chip->leds[i]);
+
+             /* set autonomous animation config as default for all LEDs */
+             led_set_autonomous_animation_config(&chip->leds[i]);
+     }
+
+     i2c_set_clientdata(client, chip);
+
+     ret = sysfs_create_group(&chip->dev->kobj, &chip->attr_group);

You need sysfs ABI documentation.

Nam: I understand that since the driver creates a sysfs attribute group using sysfs_create_group(), corresponding sysfs ABI documentation is required. I will add a new entry under Documentation/ABI/testing/ to document the exposed sysfs attributes for the LP5812 driver in the next patch.

Best regards,
Nam

#19 lore raw
Quoted 12 lines · Nam Tran

From: Nam Tran <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
Cc: Rob Herring <[email protected]>, Conor Dooley <[email protected]> Pavel Machek <[email protected]>, Lee Jones <[email protected]>, [email protected], [email protected], [email protected]

I sincerely apologize for not addressing all of your previous comments earlier. That was not my intention, and I truly appreciate the time and effort you have put into reviewing my patch. Below, I would like to properly address your concerns.

Quoted 2 lines · Nam Tran

The chip can drive LED matrix 4x3.
This driver enables LED control via I2C.

You still did not respond to comments from v1. I don't see it being addressed.

Quoted 7 lines

Nam: I am sorry. This is my mistake. I think that I just need to update source code based on your comments and submit a new patch. This is the first time I try to update a new thing to the Linux Kernel. I will give answer inline your message for tracing easily.

In previous comment you have a question
"Why none of the 10 existing drivers fit for your device?"

Nam: I have carefully reviewed the existing LED drivers in the kernel, but none of them fully support the advanced capabilities of the LP5812. Unlike basic LED controllers, the LP5812 has difference features and register For more detail, please refer to this documentation https://www.ti.com/lit/ds/symlink/lp5812.pdf?ts=1741765622088&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FLP5812

So you read my question and decided to not give an answer. Great.

The burden of proving this is on you. Do not expect me to read this and 10 other datasheets for existing LP devices. Maybe they fit, maybe they don't but based on style of this submission and style of the code I feel you just want to push your patches instead of integrate.

That's not how it works.

Quoted 9 lines
Quoted 5 lines

The driver is implemented in two parts:
- Core driver logic in leds-lp5812.c
- Common support functions in leds-lp5812-common.c

Why do you make two modules? This looks really unneccessary. Just compile them into one module. No, use proper kerneldoc Missing kerneldoc. Every exported symbol must have kerneldoc. Why this is not static?

Nam: I will merge source code into a file only. Therefore, I don’t need to export symbols here.

I cannot parse this. Use standard email quotes and replies. Like every email client since 30 years.

Best regards,
Krzysztof

author maintainer
#20 lore raw
Quoted 8 lines · Krzysztof Kozlowski
Quoted 6 lines

In previous comment you have a question
"Why none of the 10 existing drivers fit for your device?"

Nam: I have carefully reviewed the existing LED drivers in the kernel, but none of them fully support the advanced capabilities of the LP5812. Unlike basic LED controllers, the LP5812 has difference features and register For more detail, please refer to this documentation https://www.ti.com/lit/ds/symlink/lp5812.pdf?ts=1741765622088&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FLP5812

So you read my question and decided to not give an answer. Great.

I am sorry, this was my mistake. I thought I only needed to update the source code based on your comments and submit a new patch. I will make sure to respond to your comments more promptly in the future.

Quoted 6 lines

The burden of proving this is on you. Do not expect me to read this and 10 other datasheets for existing LP devices. Maybe they fit, maybe they don't but based on style of this submission and style of the code I feel you just want to push your patches instead of integrate.

That's not how it works.

I appreciate your feedback. I will provide a more detailed explanation rather than just linking the datasheet.

LP5812 is a new LED driver family. LP5812 has different registers for new features such as run mode, config AEU module... These are not supported in the existing drivers, which are tailored for different device architectures or use cases.

The LP5812 uses a register map and control scheme that differs significantly from other LPxxxx LED drivers. This required a custom implementation to manage device mode, select LEDs in each mode, configure autonomous AEU...

Integrating the LP5812 into an existing driver would introduce significant complexity,
as it would require modifications that could compromise the performance or maintainability of the existing codebase. Developing a dedicated driver ensures clean, maintainable, and optimized code.

By creating a separate driver for the LP5812, we ensure that it can fully exploit its capabilities while maintaining compatibility with the Linux driver framework. This approach also facilitates scalability for future revisions of this or similar devices.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

The driver is implemented in two parts:
- Core driver logic in leds-lp5812.c
- Common support functions in leds-lp5812-common.c

Quoted 6 lines
Quoted 3 lines

Why do you make two modules? This looks really unneccessary. Just compile them into one module. No, use proper kerneldoc Missing kerneldoc. Every exported symbol must have kerneldoc. Why this is not static?

Nam: I will merge source code into a file only. Therefore, I don’t need to export symbols here.

I cannot parse this. Use standard email quotes and replies. Like every email client since 30 years.

I apologize for the formatting issue in my previous response. I will ensure that my future responses follow standard email quoting for better readability. For my remaining unreadable responses, I will correct them and reply to the corresponding emails.

Best regards,
Nam Tran

maintainer
#21 lore raw
In reply to Nam Tran
Quoted 6 lines · Nam Tran

From: Nam Tran <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
Cc: Rob Herring <[email protected]>, Conor Dooley <[email protected]> Pavel Machek <[email protected]>, Lee Jones <[email protected]>, [email protected], [email protected], [email protected]

I sincerely apologize for not addressing all of your previous comments earlier. That was not my intention, and I truly appreciate the time and effort you have put into reviewing my patch. Below, I would like to properly address your concerns.

Quoted 7 lines
Quoted 2 lines · Nam Tran

The chip can drive LED matrix 4x3.
This driver enables LED control via I2C.

You still did not respond to comments from v1. I don't see it being addressed.

Nam: I am sorry. This is my mistake. I think that I just need to update source code based on your comments and submit a new patch. This is the first time I try to update a new thing to the Linux Kernel. I will give answer inline your message for tracing easily.

For the record, I find this format pretty unreadable.

Please reply directly to the email you are responding to. This response looks as though you're replying to the patch itself.

Configure your mailer to refrain from placing header information (To:
Cc: From: etc) in the body of the mail.

If your mailer conducts quoting correctly, there should be no need for "Nam:" comments. For me it looks as though you authored both the review comment and the response, since your mailer currently does not handle quoting correctly.

It would help everyone out if you could configure your mailer correctly.

Maybe this document has additional hints for you particular mailer:

Documentation/process/email-clients.rst

Signature · 1 line
Lee Jones [李琼斯]
author maintainer
#22 lore raw

Thank you for your suggestion. I appreciate your guidance on proper email formatting. I will ensure my future responses follow this standard.
Your feedback is very helpful for me to improve my contributions.

Best regards,
Nam Tran

#23 lore raw
In reply to Nam Tran

…

Quoted 2 lines

+++ b/drivers/leds/leds-lp5812.c

(quoted diff) +0 -0
@@ -0,0 +1,2190 @@

…

Quoted 4 lines
drivers/leds/leds-lp5812.c new file +4 -0
+static ssize_t device_enable_show(struct device *dev,
+		struct device_attribute *attr,
+		char *buf)
+{

…

drivers/leds/leds-lp5812.c line 442

Quoted 9 lines
drivers/leds/leds-lp5812.c new file +9 -0
+	mutex_lock(&chip->lock);
+	if (lp5812_read(chip, chip->regs->enable_reg, &enable)) {
+		mutex_unlock(&chip->lock);
+		return -EIO;
+	}
+	mutex_unlock(&chip->lock);
+
+	return sprintf(buf, "%d\n", enable);
+}

…

Under which circumstances would you become interested to apply a statement like “guard(mutex)(&chip->lock);”?
https://elixir.bootlin.com/linux/v6.14-rc6/source/include/linux/mutex.h#L201

Regards,
Markus

author maintainer
#24 lore raw
Quoted 20 lines

…

Quoted 2 lines

+++ b/drivers/leds/leds-lp5812.c

(quoted diff) +0 -0
@@ -0,0 +1,2190 @@

…

Quoted 4 lines
drivers/leds/leds-lp5812.c new file +4 -0
+static ssize_t device_enable_show(struct device *dev,
+		struct device_attribute *attr,
+		char *buf)
+{

…

Quoted 9 lines
drivers/leds/leds-lp5812.c new file +9 -0
+	mutex_lock(&chip->lock);
+	if (lp5812_read(chip, chip->regs->enable_reg, &enable)) {
+		mutex_unlock(&chip->lock);
+		return -EIO;
+	}
+	mutex_unlock(&chip->lock);
+
+	return sprintf(buf, "%d\n", enable);
+}

…

Quoted 3 lines

Under which circumstances would you become interested to apply a statement like “guard(mutex)(&chip->lock);”?
https://elixir.bootlin.com/linux/v6.14-rc6/source/include/linux/mutex.h#L201

Thank you for your suggestion regarding the use of guard(mutex)(&chip->lock).
While we understand the impacts of this approach, we are currently not planning to change the source code in this version. We will consider incorporating this improvement in the next TI LED version.

Best regards,
Nam Tran