[PATCH v2 3/4] leds: lp5860: save count of multi_leds

Steffen Trumtrar posted 4 patches 9 months ago
There is a newer version of this series
[PATCH v2 3/4] leds: lp5860: save count of multi_leds
Posted by Steffen Trumtrar 9 months ago
Save the count of multi_leds child nodes for later use.
As the leds are added to a flex array, the size needs to be saved at
runtime.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 drivers/leds/leds-lp5860-spi.c | 2 ++
 drivers/leds/leds-lp5860.h     | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/leds/leds-lp5860-spi.c b/drivers/leds/leds-lp5860-spi.c
index 751cc4184037c3c0e14d3493d0a43f0885786523..eee41ee8a8c226db6a68413998642624fabffe7c 100644
--- a/drivers/leds/leds-lp5860-spi.c
+++ b/drivers/leds/leds-lp5860-spi.c
@@ -50,6 +50,8 @@ static int lp5860_probe(struct spi_device *spi)
 	if (!lp5860)
 		return -ENOMEM;
 
+	lp5860->leds_size = multi_leds;
+
 	spi_set_drvdata(spi, lp5860);
 
 	spi->mode = SPI_MODE_0;
diff --git a/drivers/leds/leds-lp5860.h b/drivers/leds/leds-lp5860.h
index b4255fb48372814c7fda86ada96f504c2036f534..3b8342a832bc75afdf2318fd4ee1ee9ce105cbe3 100644
--- a/drivers/leds/leds-lp5860.h
+++ b/drivers/leds/leds-lp5860.h
@@ -305,6 +305,7 @@ struct lp5860_led {
 struct lp5860 {
 	struct device *dev;
 	struct regmap *regmap;
+	unsigned int leds_size;
 
 	DECLARE_FLEX_ARRAY(struct lp5860_led, leds);
 };

-- 
2.47.1
Re: [PATCH v2 3/4] leds: lp5860: save count of multi_leds
Posted by Lee Jones 8 months ago
On Wed, 14 May 2025, Steffen Trumtrar wrote:

> Save the count of multi_leds child nodes for later use.
> As the leds are added to a flex array, the size needs to be saved at
> runtime.

Size of the LEDs?  Length in millimeters?

> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
>  drivers/leds/leds-lp5860-spi.c | 2 ++
>  drivers/leds/leds-lp5860.h     | 1 +
>  2 files changed, 3 insertions(+)
> 
> diff --git a/drivers/leds/leds-lp5860-spi.c b/drivers/leds/leds-lp5860-spi.c
> index 751cc4184037c3c0e14d3493d0a43f0885786523..eee41ee8a8c226db6a68413998642624fabffe7c 100644
> --- a/drivers/leds/leds-lp5860-spi.c
> +++ b/drivers/leds/leds-lp5860-spi.c
> @@ -50,6 +50,8 @@ static int lp5860_probe(struct spi_device *spi)
>  	if (!lp5860)
>  		return -ENOMEM;
>  
> +	lp5860->leds_size = multi_leds;
> +
>  	spi_set_drvdata(spi, lp5860);
>  
>  	spi->mode = SPI_MODE_0;
> diff --git a/drivers/leds/leds-lp5860.h b/drivers/leds/leds-lp5860.h
> index b4255fb48372814c7fda86ada96f504c2036f534..3b8342a832bc75afdf2318fd4ee1ee9ce105cbe3 100644
> --- a/drivers/leds/leds-lp5860.h
> +++ b/drivers/leds/leds-lp5860.h
> @@ -305,6 +305,7 @@ struct lp5860_led {
>  struct lp5860 {
>  	struct device *dev;
>  	struct regmap *regmap;
> +	unsigned int leds_size;
>  
>  	DECLARE_FLEX_ARRAY(struct lp5860_led, leds);
>  };
> 
> -- 
> 2.47.1
> 
> 

-- 
Lee Jones [李琼斯]