Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+32 −31
Original line number Diff line number Diff line
@@ -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;
	if (trigger[0] == '+')
		new_state.triggers |= BIT(trigger_bit);
	else {
		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
			 *       bit (1) will not be disabled */
		 *       bit (1) will not be disabled
		 */
		if (trigger_bit == 1)
			new_state.triggers &= ~BIT(2);
	}
@@ -1697,9 +1701,6 @@ static ssize_t kbd_led_triggers_store(struct device *dev,
	return count;
}

	return -EINVAL;
}

static ssize_t kbd_led_triggers_show(struct device *dev,
				     struct device_attribute *attr, char *buf)
{