leds: qcom-lpg: Check the return value of regmap_bulk_write()
PATCH 1/1 leds: qcom-lpg: Check the return value of regmap_bulk_write()
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.
--- drivers/leds/rgb/leds-qcom-lpg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/leds/rgb/leds-qcom-lpg.c +4 -2
@@ -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);
Signature · 1 line
2.50.1.windows.1
Lee Jones
maintainerQuoted 28 lines · Haotian Zhang
The
lpg_lut_store()function currently ignores the return value ofregmap_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()inlpg_lut_storeand return the error to the caller on failure.Fixes 24e2d05d1b68 ("leds: Add driver for Qualcomm LPG")Signed-off-by Haotian Zhang <[email protected]>--- drivers/leds/rgb/leds-qcom-lpg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/leds/rgb/leds-qcom-lpg.c +1
-1@@ -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 );
drivers/leds/rgb/leds-qcom-lpg.c static int lpg_lut_store(struct lpg *lpg, struct led_pattern *pattern, · line 383
Quoted 6 lines
drivers/leds/rgb/leds-qcom-lpg.c +1
-1@@ -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.
Quoted 8 lines
drivers/leds/rgb/leds-qcom-lpg.c +2
-0+if (ret) +return ret; }bitmap_set (lpg->lut_bitmap, idx, len);Signature · 1 line
2.50.1.windows.1
Signature · 1 line
Lee Jones [李琼斯]
PATCH v2 1/1 leds: qcom-lpg: Check the return value of regmap_bulk_write()
In reply to Haotian ZhangThe 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.
---
Changes in v2:
- Fix indentation alignment.
--- drivers/leds/rgb/leds-qcom-lpg.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/leds/rgb/leds-qcom-lpg.c +5 -3
@@ -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);
Signature · 1 line
2.50.1.windows.1
Re: (subset) [PATCH v2] leds: qcom-lpg: Check the return value of regmap_bulk_write()
Quoted 9 lines · Haotian Zhang
The
lpg_lut_store()function currently ignores the return value ofregmap_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()inlpg_lut_storeand 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 [李琼斯]