Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

backlight: lm3630a_bl: Remove invalid checks for unsigned int < 0

unsigned ints 'sources' and 'bank' cannot be less than LM3630A_SINK_0 (0)
and LM3630A_BANK_0 (0) respecitively, so change the logic to only check
for thier two possible valid values.

Fixes W=1 warnings:

drivers/video/backlight/lm3630a_bl.c: In function ‘lm3630a_parse_led_sources’:
drivers/video/backlight/lm3630a_bl.c:394:18: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
394 | if (sources[i] < LM3630A_SINK_0 || sources[i] > LM3630A_SINK_1)
| ^
drivers/video/backlight/lm3630a_bl.c: In function ‘lm3630a_parse_bank’:
drivers/video/backlight/lm3630a_bl.c:415:11: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
415 | if (bank < LM3630A_BANK_0 || bank > LM3630A_BANK_1)
| ^

Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Daniel Jeong <gshark.jeong@gmail.com>
Cc: LDD MLP <ldd-mlp@list.ti.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

+2 -2
+2 -2
drivers/video/backlight/lm3630a_bl.c
··· 391 391 return ret; 392 392 393 393 for (i = 0; i < num_sources; i++) { 394 - if (sources[i] < LM3630A_SINK_0 || sources[i] > LM3630A_SINK_1) 394 + if (sources[i] != LM3630A_SINK_0 && sources[i] != LM3630A_SINK_1) 395 395 return -EINVAL; 396 396 397 397 ret |= BIT(sources[i]); ··· 412 412 if (ret) 413 413 return ret; 414 414 415 - if (bank < LM3630A_BANK_0 || bank > LM3630A_BANK_1) 415 + if (bank != LM3630A_BANK_0 && bank != LM3630A_BANK_1) 416 416 return -EINVAL; 417 417 418 418 led_sources = lm3630a_parse_led_sources(node, BIT(bank));