public inbox for linux-leds@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: qcom-lpg: Check the return value of regmap_bulk_write()
@ 2025-12-04  6:17 Haotian Zhang
  2026-01-08 11:06 ` Lee Jones
  2026-01-08 17:51 ` [PATCH v2] " Haotian Zhang
  0 siblings, 2 replies; 4+ messages in thread
From: Haotian Zhang @ 2025-12-04  6:17 UTC (permalink / raw)
  To: lee, pavel
  Cc: abel.vesa, marijn.suijten, sre, andersson, anjelique.melendez,
	linux-leds, linux-kernel, Haotian Zhang

The lpg_lut_store() function currently ignores the return value of
regmap_bulk_write() and always returns 0. This can cause hardware write
failures to go undetected, leading the caller to believe LUT programming
succeeded when it may have failed.

Check the return value of regmap_bulk_write() in lpg_lut_store and return
the error to the caller on failure.

Fixes: 24e2d05d1b68 ("leds: Add driver for Qualcomm LPG")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 drivers/leds/rgb/leds-qcom-lpg.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
index 4f2a178e3d26..76734b1520f6 100644
--- a/drivers/leds/rgb/leds-qcom-lpg.c
+++ b/drivers/leds/rgb/leds-qcom-lpg.c
@@ -369,7 +369,7 @@ static int lpg_lut_store(struct lpg *lpg, struct led_pattern *pattern,
 {
 	unsigned int idx;
 	u16 val;
-	int i;
+	int i, ret;
 
 	idx = bitmap_find_next_zero_area(lpg->lut_bitmap, lpg->lut_size,
 					 0, len, 0);
@@ -379,8 +379,10 @@ static int lpg_lut_store(struct lpg *lpg, struct led_pattern *pattern,
 	for (i = 0; i < len; i++) {
 		val = pattern[i].brightness;
 
-		regmap_bulk_write(lpg->map, lpg->lut_base + LPG_LUT_REG(idx + i),
+		ret = regmap_bulk_write(lpg->map, lpg->lut_base + LPG_LUT_REG(idx + i),
 				  &val, sizeof(val));
+		if (ret)
+			return ret;
 	}
 
 	bitmap_set(lpg->lut_bitmap, idx, len);
-- 
2.50.1.windows.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] leds: qcom-lpg: Check the return value of regmap_bulk_write()
  2025-12-04  6:17 [PATCH] leds: qcom-lpg: Check the return value of regmap_bulk_write() Haotian Zhang
@ 2026-01-08 11:06 ` Lee Jones
  2026-01-08 17:51 ` [PATCH v2] " Haotian Zhang
  1 sibling, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-01-08 11:06 UTC (permalink / raw)
  To: Haotian Zhang
  Cc: pavel, abel.vesa, marijn.suijten, sre, andersson,
	anjelique.melendez, linux-leds, linux-kernel

On Thu, 04 Dec 2025, Haotian Zhang wrote:

> The lpg_lut_store() function currently ignores the return value of
> regmap_bulk_write() and always returns 0. This can cause hardware write
> failures to go undetected, leading the caller to believe LUT programming
> succeeded when it may have failed.
> 
> Check the return value of regmap_bulk_write() in lpg_lut_store and return
> the error to the caller on failure.
> 
> Fixes: 24e2d05d1b68 ("leds: Add driver for Qualcomm LPG")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
>  drivers/leds/rgb/leds-qcom-lpg.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> index 4f2a178e3d26..76734b1520f6 100644
> --- a/drivers/leds/rgb/leds-qcom-lpg.c
> +++ b/drivers/leds/rgb/leds-qcom-lpg.c
> @@ -369,7 +369,7 @@ static int lpg_lut_store(struct lpg *lpg, struct led_pattern *pattern,
>  {
>  	unsigned int idx;
>  	u16 val;
> -	int i;
> +	int i, ret;
>  
>  	idx = bitmap_find_next_zero_area(lpg->lut_bitmap, lpg->lut_size,
>  					 0, len, 0);
> @@ -379,8 +379,10 @@ static int lpg_lut_store(struct lpg *lpg, struct led_pattern *pattern,
>  	for (i = 0; i < len; i++) {
>  		val = pattern[i].brightness;
>  
> -		regmap_bulk_write(lpg->map, lpg->lut_base + LPG_LUT_REG(idx + i),
> +		ret = regmap_bulk_write(lpg->map, lpg->lut_base + LPG_LUT_REG(idx + i),
>  				  &val, sizeof(val));

Fine, but you need to re-align this to the '(' above.

> +		if (ret)
> +			return ret;
>  	}
>  
>  	bitmap_set(lpg->lut_bitmap, idx, len);
> -- 
> 2.50.1.windows.1
> 

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] leds: qcom-lpg: Check the return value of regmap_bulk_write()
  2025-12-04  6:17 [PATCH] leds: qcom-lpg: Check the return value of regmap_bulk_write() Haotian Zhang
  2026-01-08 11:06 ` Lee Jones
@ 2026-01-08 17:51 ` Haotian Zhang
  2026-01-13 12:29   ` (subset) " Lee Jones
  1 sibling, 1 reply; 4+ messages in thread
From: Haotian Zhang @ 2026-01-08 17:51 UTC (permalink / raw)
  To: lee, pavel
  Cc: abel.vesa, marijn.suijten, sre, andersson, anjelique.melendez,
	linux-leds, linux-kernel, Haotian Zhang

The lpg_lut_store() function currently ignores the return value of
regmap_bulk_write() and always returns 0. This can cause hardware write
failures to go undetected, leading the caller to believe LUT programming
succeeded when it may have failed.

Check the return value of regmap_bulk_write() in lpg_lut_store and return
the error to the caller on failure.

Fixes: 24e2d05d1b68 ("leds: Add driver for Qualcomm LPG")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>

---
Changes in v2:
  - Fix indentation alignment.
---
 drivers/leds/rgb/leds-qcom-lpg.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
index 4f2a178e3d26..c33a49105dfc 100644
--- a/drivers/leds/rgb/leds-qcom-lpg.c
+++ b/drivers/leds/rgb/leds-qcom-lpg.c
@@ -369,7 +369,7 @@ static int lpg_lut_store(struct lpg *lpg, struct led_pattern *pattern,
 {
 	unsigned int idx;
 	u16 val;
-	int i;
+	int i, ret;
 
 	idx = bitmap_find_next_zero_area(lpg->lut_bitmap, lpg->lut_size,
 					 0, len, 0);
@@ -379,8 +379,10 @@ static int lpg_lut_store(struct lpg *lpg, struct led_pattern *pattern,
 	for (i = 0; i < len; i++) {
 		val = pattern[i].brightness;
 
-		regmap_bulk_write(lpg->map, lpg->lut_base + LPG_LUT_REG(idx + i),
-				  &val, sizeof(val));
+		ret = regmap_bulk_write(lpg->map, lpg->lut_base + LPG_LUT_REG(idx + i),
+					&val, sizeof(val));
+		if (ret)
+			return ret;
 	}
 
 	bitmap_set(lpg->lut_bitmap, idx, len);
-- 
2.50.1.windows.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: (subset) [PATCH v2] leds: qcom-lpg: Check the return value of regmap_bulk_write()
  2026-01-08 17:51 ` [PATCH v2] " Haotian Zhang
@ 2026-01-13 12:29   ` Lee Jones
  0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-01-13 12:29 UTC (permalink / raw)
  To: lee, pavel, Haotian Zhang
  Cc: abel.vesa, marijn.suijten, sre, andersson, anjelique.melendez,
	linux-leds, linux-kernel

On Fri, 09 Jan 2026 01:51:33 +0800, Haotian Zhang wrote:
> The lpg_lut_store() function currently ignores the return value of
> regmap_bulk_write() and always returns 0. This can cause hardware write
> failures to go undetected, leading the caller to believe LUT programming
> succeeded when it may have failed.
> 
> Check the return value of regmap_bulk_write() in lpg_lut_store and return
> the error to the caller on failure.
> 
> [...]

Applied, thanks!

[1/1] leds: qcom-lpg: Check the return value of regmap_bulk_write()
      commit: 33e822f6f4eba2cfbd09ffd080af221cf8c542b2

--
Lee Jones [李琼斯]


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-13 12:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-04  6:17 [PATCH] leds: qcom-lpg: Check the return value of regmap_bulk_write() Haotian Zhang
2026-01-08 11:06 ` Lee Jones
2026-01-08 17:51 ` [PATCH v2] " Haotian Zhang
2026-01-13 12:29   ` (subset) " Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox