Commit 1c7e2824 authored by Hans de Goede's avatar Hans de Goede Committed by Darren Hart (VMware)

platform/x86: dell-laptop: Refactor kbd_led_triggers_store()

Return -EINVAL immediately on invalid input, rather then doing
the straight path in an if block and returning -EINVAL at the end
of the function.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarPali Rohár <pali.rohar@gmail.com>
Signed-off-by: default avatarDarren Hart (VMware) <dvhart@infradead.org>
parent 504b0259
...@@ -1666,15 +1666,19 @@ static ssize_t kbd_led_triggers_store(struct device *dev, ...@@ -1666,15 +1666,19 @@ static ssize_t kbd_led_triggers_store(struct device *dev,
} }
} }
if (trigger_bit != -1) { if (trigger_bit == -1)
return -EINVAL;
new_state = state; new_state = state;
if (trigger[0] == '+') if (trigger[0] == '+')
new_state.triggers |= BIT(trigger_bit); new_state.triggers |= BIT(trigger_bit);
else { else {
new_state.triggers &= ~BIT(trigger_bit); new_state.triggers &= ~BIT(trigger_bit);
/* NOTE: trackstick bit (2) must be disabled when /*
* NOTE: trackstick bit (2) must be disabled when
* disabling touchpad bit (1), otherwise touchpad * disabling touchpad bit (1), otherwise touchpad
* bit (1) will not be disabled */ * bit (1) will not be disabled
*/
if (trigger_bit == 1) if (trigger_bit == 1)
new_state.triggers &= ~BIT(2); new_state.triggers &= ~BIT(2);
} }
...@@ -1695,9 +1699,6 @@ static ssize_t kbd_led_triggers_store(struct device *dev, ...@@ -1695,9 +1699,6 @@ static ssize_t kbd_led_triggers_store(struct device *dev,
if (new_state.mode_bit != KBD_MODE_BIT_OFF) if (new_state.mode_bit != KBD_MODE_BIT_OFF)
kbd_previous_mode_bit = new_state.mode_bit; kbd_previous_mode_bit = new_state.mode_bit;
return count; return count;
}
return -EINVAL;
} }
static ssize_t kbd_led_triggers_show(struct device *dev, static ssize_t kbd_led_triggers_show(struct device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment