leds: ti-lmu-common: Fix coccinelle issue in TI LMU
PATCH v2 1/1 leds: ti-lmu-common: Fix coccinelle issue in TI LMU
Fix the coccinelle issues found in the TI LMU common code
drivers/leds/leds-ti-lmu-common.c:97:20-29: WARNING: Unsigned expression compared with zero: ramp_down < 0 drivers/leds/leds-ti-lmu-common.c:97:5-12: WARNING: Unsigned expression compared with zero: ramp_up < 0
--- drivers/leds/leds-ti-lmu-common.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/leds/leds-ti-lmu-common.c +6 -9
@@ -11,10 +11,10 @@#include <linux/leds-ti-lmu-common.h> -const static int ramp_table[16 ] = {2048 ,262000 ,524000 ,1049000 ,2090000 , -4194000 ,8389000 ,16780000 ,33550000 ,41940000 , -50330000 ,58720000 ,67110000 ,83880000 , -100660000 ,117440000 }; +const static unsigned int ramp_table[16 ] = {2048 ,262000 ,524000 ,1049000 , +2090000 ,4194000 ,8389000 ,16780000 ,33550000 , +41940000 ,50330000 ,58720000 ,67110000 , +83880000 ,100660000 ,117440000 };static int ti_lmu_common_update_brightness (struct ti_lmu_bank *lmu_bank,int brightness)
@@ -54,7 +54,7 @@ int ti_lmu_common_set_brightness(struct ti_lmu_bank *lmu_bank, int brightness) }EXPORT_SYMBOL (ti_lmu_common_set_brightness); -static int ti_lmu_common_convert_ramp_to_index (unsigned int usec) +static unsigned int ti_lmu_common_convert_ramp_to_index (unsigned int usec) {int size =ARRAY_SIZE (ramp_table);int i;
@@ -78,7 +78,7 @@ static int ti_lmu_common_convert_ramp_to_index(unsigned int usec) } } -return -EINVAL ; +return 0 ; }int ti_lmu_common_set_ramp (struct ti_lmu_bank *lmu_bank)
@@ -94,9 +94,6 @@ int ti_lmu_common_set_ramp(struct ti_lmu_bank *lmu_bank) ramp_down =ti_lmu_common_convert_ramp_to_index (lmu_bank->ramp_down_usec); } -if (ramp_up <0 || ramp_down <0 ) -return -EINVAL ; - ramp = (ramp_up <<4 ) | ramp_down;return regmap_write (regmap, lmu_bank->runtime_ramp_reg, ramp);
Signature · 1 line
2.22.0.214.g8dca754b1e
Hi Dan,
Thank you for the update.
Quoted 50 lines · Dan Murphy
Fix the coccinelle issues found in the TI LMU common code
drivers/leds/leds-ti-lmu-common.c:97:20-29: WARNING: Unsigned expression compared with zero:
ramp_down< 0 drivers/leds/leds-ti-lmu-common.c:97:5-12: WARNING: Unsigned expression compared with zero:ramp_up< 0Fixes f717460ba4d7 ("leds: TI LMU: Add common code for TI LMU devices")Signed-off-by Dan Murphy <[email protected]>--- drivers/leds/leds-ti-lmu-common.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)drivers/leds/leds-ti-lmu-common.c +6
-6@@ -11,10 +11,10 @@#include <linux/leds-ti-lmu-common.h> -const static int ramp_table[16 ] = {2048 ,262000 ,524000 ,1049000 ,2090000 , -4194000 ,8389000 ,16780000 ,33550000 ,41940000 , -50330000 ,58720000 ,67110000 ,83880000 , -100660000 ,117440000 }; +const static unsigned int ramp_table[16 ] = {2048 ,262000 ,524000 ,1049000 , +2090000 ,4194000 ,8389000 ,16780000 ,33550000 , +41940000 ,50330000 ,58720000 ,67110000 , +83880000 ,100660000 ,117440000 };static int ti_lmu_common_update_brightness (struct ti_lmu_bank *lmu_bank,int brightness)@@ -54,7 +54,7 @@ int ti_lmu_common_set_brightness(struct ti_lmu_bank *lmu_bank, int brightness) }EXPORT_SYMBOL (ti_lmu_common_set_brightness); -static int ti_lmu_common_convert_ramp_to_index (unsigned int usec) +static unsigned int ti_lmu_common_convert_ramp_to_index (unsigned int usec) {int size =ARRAY_SIZE (ramp_table);int i;@@ -78,7 +78,7 @@ static int ti_lmu_common_convert_ramp_to_index(unsigned int usec) } } -return -EINVAL ; +return 0 ; }int ti_lmu_common_set_ramp (struct ti_lmu_bank *lmu_bank)
drivers/leds/leds-ti-lmu-common.c int ti_lmu_common_set_ramp(struct ti_lmu_bank *lmu_bank) · line 99
Quoted 9 lines
drivers/leds/leds-ti-lmu-common.c +0
-3@@ -94,9 +94,6 @@ int ti_lmu_common_set_ramp(struct ti_lmu_bank *lmu_bank) ramp_down =ti_lmu_common_convert_ramp_to_index (lmu_bank->ramp_down_usec); } -if (ramp_up <0 || ramp_down <0 ) -return -EINVAL ; - ramp = (ramp_up <<4 ) | ramp_down;return regmap_write (regmap, lmu_bank->runtime_ramp_reg, ramp);
I've applied the patch but amended SHA1 in the Fixes tag - in mainline it is 3fce8e1eb994.
Signature · 2 lines
Best regards, Jacek Anaszewski