dt-bindings: leds-lp55xx: limit pwr-sel property to ti,lp8501
Subsystems (2)
PATCH v3 1/3 dt-bindings: leds-lp55xx: limit pwr-sel property to ti,lp8501
pwr-sel property is specific to ti,lp8501, make it conditional of the related compatible.
---
v3:
- Add ACK tag
.../devicetree/bindings/leds/leds-lp55xx.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/leds/leds-lp55xx.yaml +10 -0
@@ -151,6 +151,16 @@ patternProperties: $ref: /schemas/types.yaml#/definitions/string description: name of channel +if: + not: + properties: + compatible: + contains: + const: ti,lp8501 +then: + properties: + pwr-sel: false + required: - compatible - reg
Signature · 1 line
2.43.0
PATCH v3 2/3 dt-bindings: leds-lp55xx: Add new ti,lp5569 compatible
Add new ti,lp5569 compatible, this is similar to national,lp5523 with slight change to reg order and reg type and advanced way for LED fault.
---
v2:
- Add ACK tag
Documentation/devicetree/bindings/leds/leds-lp55xx.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/leds/leds-lp55xx.yaml +1 -0
@@ -28,6 +28,7 @@ properties: - national,lp5523 - ti,lp55231 - ti,lp5562 + - ti,lp5569 - ti,lp8501 reg:
Signature · 1 line
2.43.0
PATCH v3 3/3 leds: leds-lp5569: Add support for Texas Instruments LP5569
In reply to Christian MarangiAdd support for Texas Instruments LP5569 LED driver.
Texas Instruments LP5569 is 9 channels chip with programmable engines.
It almost a copy of LP5523 with fundamental changes to regs order and regs content.
Has difference in how the clock is handled and doesn't support detecting clock time automatically, different handling for selftest and different scheme for the status regs.
One some devices using this LED Controller (a NBG7815 Router) it was found loading big precompiled pattern with up to 3 bytes of code. To have support for this "extended" scenarion, hardcode each engine to support 4 pages of precompiled pattern (128 bytes of code) and 1 page for each MUX. This gives plenty of space for any kind precompiled pattern keeping simple logic for page handling of each engine and mux.
---
v3:
- Enlarge and support program size up to 128bytes
v2:
- Fix compilation error with target that doesn't
include bitfield.h
drivers/leds/Kconfig | 16 +- drivers/leds/Makefile | 1 + drivers/leds/leds-lp5569.c | 1159 ++++++++++++++++++++++++++++++++++++ 3 files changed, 1173 insertions(+), 3 deletions(-) create mode 100644 drivers/leds/leds-lp5569.c
drivers/leds/Kconfig +13 -3
@@ -414,7 +414,7 @@ config LEDS_LP50XX module will be called leds-lp50xx. config LEDS_LP55XX_COMMON - tristate "Common Driver for TI/National LP5521/5523/55231/5562/8501" + tristate "Common Driver for TI/National LP5521/5523/55231/5562/5569/8501" depends on LEDS_CLASS depends on LEDS_CLASS_MULTICOLOR depends on OF
@@ -422,8 +422,8 @@ config LEDS_LP55XX_COMMON select FW_LOADER select FW_LOADER_USER_HELPER help - This option supports common operations for LP5521/5523/55231/5562/8501 - devices. + This option supports common operations for LP5521/5523/55231/5562/5569/ + 8501 devices. config LEDS_LP5521 tristate "LED Support for N.S. LP5521 LED driver chip"
@@ -456,6 +456,16 @@ config LEDS_LP5562 Driver provides direct control via LED class and interface for programming the engines. +config LEDS_LP5569 + tristate "LED Support for TI LP5569 LED driver chip" + depends on LEDS_CLASS && I2C + depends on LEDS_LP55XX_COMMON + help + If you say yes here you get support for TI LP5569 LED driver. + It is 9 channels chip with programmable engines. + Driver provides direct control via LED class and interface for + programming the engines. + config LEDS_LP8501 tristate "LED Support for TI LP8501 LED driver chip" depends on LEDS_CLASS && I2C
drivers/leds/Makefile +1 -0
@@ -51,6 +51,7 @@ obj-$(CONFIG_LEDS_LP50XX) += leds-lp50xx.o obj-$(CONFIG_LEDS_LP5521) += leds-lp5521.o 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_LP8501) += leds-lp8501.o obj-$(CONFIG_LEDS_LP8788) += leds-lp8788.o
drivers/leds/leds-lp5569.c new file +1159 -0
1,159 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v3 3/3] leds: leds-lp5569: Add support for Texas Instruments LP5569
Hi Christian,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-leds-lp55xx-Add-new-ti-lp5569-compatible/20240527-174959 base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git for-leds-next patch link: https://lore.kernel.org/r/20240527094737.13354-3-ansuelsmth%40gmail.com patch subject: [PATCH v3 3/3] leds: leds-lp5569: Add support for Texas Instruments LP5569 config: sparc-randconfig-r071-20240528 (https://download.01.org/0day-ci/archive/20240528/[email protected]/config) compiler: sparc-linux-gcc (GCC) 13.2.0
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]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
New smatch warnings:drivers/leds/leds-lp5569.c:378 lp5569_update_program_memory() error: buffer overflow 'pattern' 128 <= 223
vim +/pattern +378 drivers/leds/leds-lp5569.c
ed7ae4f43e228c Christian Marangi 2024-05-27 340 static int lp5569_update_program_memory(struct lp55xx_chip *chip,
ed7ae4f43e228c Christian Marangi 2024-05-27 341 const u8 *data, size_t size)
ed7ae4f43e228c Christian Marangi 2024-05-27 342 {
ed7ae4f43e228c Christian Marangi 2024-05-27 343 enum lp55xx_engine_index idx = chip->engine_idx;
ed7ae4f43e228c Christian Marangi 2024-05-27 344 u8 pattern[LP5569_PROGRAM_LENGTH] = {0};
ed7ae4f43e228c Christian Marangi 2024-05-27 345 unsigned int cmd;
ed7ae4f43e228c Christian Marangi 2024-05-27 346 char c[3];
ed7ae4f43e228c Christian Marangi 2024-05-27 347 int nrchars;
ed7ae4f43e228c Christian Marangi 2024-05-27 348 int ret;
ed7ae4f43e228c Christian Marangi 2024-05-27 349 int offset = 0;
ed7ae4f43e228c Christian Marangi 2024-05-27 350 int page, i = 0;
ed7ae4f43e228c Christian Marangi 2024-05-27 351
ed7ae4f43e228c Christian Marangi 2024-05-27 352 while ((offset < size - 1) && (i < LP5569_PROGRAM_LENGTH)) {
ed7ae4f43e228c Christian Marangi 2024-05-27 353 /* separate sscanfs because length is working only for %s */
ed7ae4f43e228c Christian Marangi 2024-05-27 354 ret = sscanf(data + offset, "%2s%n ", c, &nrchars);
ed7ae4f43e228c Christian Marangi 2024-05-27 355 if (ret != 1)
ed7ae4f43e228c Christian Marangi 2024-05-27 356 goto err;
ed7ae4f43e228c Christian Marangi 2024-05-27 357
ed7ae4f43e228c Christian Marangi 2024-05-27 358 ret = sscanf(c, "%2x", &cmd);
ed7ae4f43e228c Christian Marangi 2024-05-27 359 if (ret != 1)
ed7ae4f43e228c Christian Marangi 2024-05-27 360 goto err;
ed7ae4f43e228c Christian Marangi 2024-05-27 361
ed7ae4f43e228c Christian Marangi 2024-05-27 362 pattern[i] = (u8)cmd;
ed7ae4f43e228c Christian Marangi 2024-05-27 363 offset += nrchars;
ed7ae4f43e228c Christian Marangi 2024-05-27 364 i++;
ed7ae4f43e228c Christian Marangi 2024-05-27 365 }
ed7ae4f43e228c Christian Marangi 2024-05-27 366
ed7ae4f43e228c Christian Marangi 2024-05-27 367 /* Each instruction is 16bit long. Check that length is even */
ed7ae4f43e228c Christian Marangi 2024-05-27 368 if (i % 2)
ed7ae4f43e228c Christian Marangi 2024-05-27 369 goto err;
ed7ae4f43e228c Christian Marangi 2024-05-27 370
ed7ae4f43e228c Christian Marangi 2024-05-27 371 for (page = 0; page < LP5569_PROGRAM_LENGTH / LP5569_BYTES_PER_PAGE; page++) {
ed7ae4f43e228c Christian Marangi 2024-05-27 372 /* Write to the next page each 32 bytes */
ed7ae4f43e228c Christian Marangi 2024-05-27 373 lp55xx_write(chip, LP5569_REG_PROG_PAGE_SEL,
ed7ae4f43e228c Christian Marangi 2024-05-27 374 LP5569_PAGE_ENG(idx) + page);
ed7ae4f43e228c Christian Marangi 2024-05-27 375
ed7ae4f43e228c Christian Marangi 2024-05-27 376 for (i = 0; i < LP5569_PROGRAM_LENGTH; i++) {
ed7ae4f43e228c Christian Marangi 2024-05-27 377 ret = lp55xx_write(chip, LP5569_REG_PROG_MEM + i,
ed7ae4f43e228c Christian Marangi 2024-05-27 @378 pattern[i + (page * LP5569_BYTES_PER_PAGE)]);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^i can co up to LP5569_PROGRAM_LENGTH and "page * LP5569_BYTES_PER_PAGE" can also go up to LP5569_PROGRAM_LENGTH. So we're 2x beyond the end of the array.
ed7ae4f43e228c Christian Marangi 2024-05-27 379 if (ret) ed7ae4f43e228c Christian Marangi 2024-05-27 380 return -EINVAL; ed7ae4f43e228c Christian Marangi 2024-05-27 381 } ed7ae4f43e228c Christian Marangi 2024-05-27 382 } ed7ae4f43e228c Christian Marangi 2024-05-27 383 ed7ae4f43e228c Christian Marangi 2024-05-27 384 ed7ae4f43e228c Christian Marangi 2024-05-27 385 return size; ed7ae4f43e228c Christian Marangi 2024-05-27 386 ed7ae4f43e228c Christian Marangi 2024-05-27 387 err: ed7ae4f43e228c Christian Marangi 2024-05-27 388 dev_err(&chip->cl->dev, "wrong pattern format\n"); ed7ae4f43e228c Christian Marangi 2024-05-27 389 return -EINVAL; ed7ae4f43e228c Christian Marangi 2024-05-27 390 }
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v3 3/3] leds: leds-lp5569: Add support for Texas Instruments LP5569
Quoted 64 lines · Dan Carpenter
Hi Christian,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-leds-lp55xx-Add-new-ti-lp5569-compatible/20240527-174959 base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git for-leds-next patch link: https://lore.kernel.org/r/20240527094737.13354-3-ansuelsmth%40gmail.com patch subject: [PATCH v3 3/3] leds: leds-lp5569: Add support for Texas Instruments LP5569 config: sparc-randconfig-r071-20240528 (https://download.01.org/0day-ci/archive/20240528/[email protected]/config) compiler: sparc-linux-gcc (GCC) 13.2.0If 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]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/New smatch warnings:
drivers/leds/leds-lp5569.c:378lp5569_update_program_memory()error: buffer overflow 'pattern' 128 <= 223vim +/pattern +378
drivers/leds/leds-lp5569.ced7ae4f43e228c Christian Marangi 2024-05-27 340 static int lp5569_update_program_memory(struct lp55xx_chip *chip, ed7ae4f43e228c Christian Marangi 2024-05-27 341 const u8 *data, size_t size) ed7ae4f43e228c Christian Marangi 2024-05-27 342 { ed7ae4f43e228c Christian Marangi 2024-05-27 343 enum lp55xx_engine_index idx = chip->engine_idx; ed7ae4f43e228c Christian Marangi 2024-05-27 344 u8 pattern[LP5569_PROGRAM_LENGTH] = {0}; ed7ae4f43e228c Christian Marangi 2024-05-27 345 unsigned int cmd; ed7ae4f43e228c Christian Marangi 2024-05-27 346 char c[3]; ed7ae4f43e228c Christian Marangi 2024-05-27 347 int nrchars; ed7ae4f43e228c Christian Marangi 2024-05-27 348 int ret; ed7ae4f43e228c Christian Marangi 2024-05-27 349 int offset = 0; ed7ae4f43e228c Christian Marangi 2024-05-27 350 int page, i = 0; ed7ae4f43e228c Christian Marangi 2024-05-27 351 ed7ae4f43e228c Christian Marangi 2024-05-27 352 while ((offset < size - 1) && (i < LP5569_PROGRAM_LENGTH)) { ed7ae4f43e228c Christian Marangi 2024-05-27 353 /* separate sscanfs because length is working only for %s */ ed7ae4f43e228c Christian Marangi 2024-05-27 354 ret = sscanf(data + offset, "%2s%n ", c, &nrchars); ed7ae4f43e228c Christian Marangi 2024-05-27 355 if (ret != 1) ed7ae4f43e228c Christian Marangi 2024-05-27 356 goto err; ed7ae4f43e228c Christian Marangi 2024-05-27 357 ed7ae4f43e228c Christian Marangi 2024-05-27 358 ret = sscanf(c, "%2x", &cmd); ed7ae4f43e228c Christian Marangi 2024-05-27 359 if (ret != 1) ed7ae4f43e228c Christian Marangi 2024-05-27 360 goto err; ed7ae4f43e228c Christian Marangi 2024-05-27 361 ed7ae4f43e228c Christian Marangi 2024-05-27 362 pattern[i] = (u8)cmd; ed7ae4f43e228c Christian Marangi 2024-05-27 363 offset += nrchars; ed7ae4f43e228c Christian Marangi 2024-05-27 364 i++; ed7ae4f43e228c Christian Marangi 2024-05-27 365 } ed7ae4f43e228c Christian Marangi 2024-05-27 366 ed7ae4f43e228c Christian Marangi 2024-05-27 367 /* Each instruction is 16bit long. Check that length is even */ ed7ae4f43e228c Christian Marangi 2024-05-27 368 if (i % 2) ed7ae4f43e228c Christian Marangi 2024-05-27 369 goto err; ed7ae4f43e228c Christian Marangi 2024-05-27 370 ed7ae4f43e228c Christian Marangi 2024-05-27 371 for (page = 0; page < LP5569_PROGRAM_LENGTH / LP5569_BYTES_PER_PAGE; page++) { ed7ae4f43e228c Christian Marangi 2024-05-27 372 /* Write to the next page each 32 bytes */ ed7ae4f43e228c Christian Marangi 2024-05-27 373 lp55xx_write(chip, LP5569_REG_PROG_PAGE_SEL, ed7ae4f43e228c Christian Marangi 2024-05-27 374 LP5569_PAGE_ENG(idx) + page); ed7ae4f43e228c Christian Marangi 2024-05-27 375 ed7ae4f43e228c Christian Marangi 2024-05-27 376 for (i = 0; i < LP5569_PROGRAM_LENGTH; i++) { ed7ae4f43e228c Christian Marangi 2024-05-27 377 ret = lp55xx_write(chip, LP5569_REG_PROG_MEM + i, ed7ae4f43e228c Christian Marangi 2024-05-27 @378 pattern[i + (page * LP5569_BYTES_PER_PAGE)]); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 4 lines
i can co up to
LP5569_PROGRAM_LENGTHand "page *LP5569_BYTES_PER_PAGE" can also go up toLP5569_PROGRAM_LENGTH. So we're 2x beyond the end of the array.
Yes the second loop max value should have been LP5569_BYTES_PER_PAGE, totally a copy paste error on my side.
Thanks a lot for warning about this bug, will send new version with this fixed.
Quoted 17 lines
ed7ae4f43e228c Christian Marangi 2024-05-27 379 if (ret) ed7ae4f43e228c Christian Marangi 2024-05-27 380 return -EINVAL; ed7ae4f43e228c Christian Marangi 2024-05-27 381 } ed7ae4f43e228c Christian Marangi 2024-05-27 382 } ed7ae4f43e228c Christian Marangi 2024-05-27 383 ed7ae4f43e228c Christian Marangi 2024-05-27 384 ed7ae4f43e228c Christian Marangi 2024-05-27 385 return size; ed7ae4f43e228c Christian Marangi 2024-05-27 386 ed7ae4f43e228c Christian Marangi 2024-05-27 387 err: ed7ae4f43e228c Christian Marangi 2024-05-27 388 dev_err(&chip->cl->dev, "wrong pattern format\n"); ed7ae4f43e228c Christian Marangi 2024-05-27 389 return -EINVAL; ed7ae4f43e228c Christian Marangi 2024-05-27 390 }Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Signature · 1 line
Ansuel