Change color lookup return value

This commit is contained in:
Christoffer Sandberg 2020-08-04 11:40:17 +02:00
parent 17595676b5
commit afbe4cde64
2 changed files with 3 additions and 3 deletions

View file

@ -103,11 +103,11 @@ static struct color_list_t color_list = {
/** /**
* Looks up a color in the color_list * Looks up a color in the color_list
* *
* Returns found color, or -1 if string did not match * Returns found color value, or 0xffffffff if string did not match
*/ */
static u32 color_lookup(const struct color_list_t *color_list, const char *color_name) static u32 color_lookup(const struct color_list_t *color_list, const char *color_name)
{ {
u32 found_color = -1; u32 found_color = 0xffffffff;
int i; int i;
for (i = 0; i < color_list->size; ++i) { for (i = 0; i < color_list->size; ++i) {
if (strcmp(color_list->colors[i].name, color_name) == 0) { if (strcmp(color_list->colors[i].name, color_name) == 0) {

View file

@ -308,7 +308,7 @@ static int uniwill_keyboard_probe(struct platform_device *dev)
// Initialize keyboard backlight driver state according to parameters // Initialize keyboard backlight driver state according to parameters
if (param_brightness > UNIWILL_BRIGHTNESS_MAX) param_brightness = UNIWILL_BRIGHTNESS_DEFAULT; if (param_brightness > UNIWILL_BRIGHTNESS_MAX) param_brightness = UNIWILL_BRIGHTNESS_DEFAULT;
kbd_led_state_uw.brightness = param_brightness; kbd_led_state_uw.brightness = param_brightness;
if (color_lookup(&color_list, param_color) != -1) kbd_led_state_uw.color = color_lookup(&color_list, param_color); if (color_lookup(&color_list, param_color) <= (u32) 0xffffff) kbd_led_state_uw.color = color_lookup(&color_list, param_color);
else kbd_led_state_uw.color = UNIWILL_COLOR_DEFAULT; else kbd_led_state_uw.color = UNIWILL_COLOR_DEFAULT;
// Update keyboard according to the current state // Update keyboard according to the current state