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

Commit 71f3d070 authored by Dmitry Torokhov's avatar Dmitry Torokhov
Browse files

Input: tc3589x-keypad - remove unnecessary checks



settle_time and debounce_period are u8 and thus can not be greater than
TC3589x_MAX_DEBOUNCE_SETTLE which is 255.

There also no need to mask out nibbles form board->krow and board->kcol
as we validate that they are in correct range.

Reported-by: default avatarWerner <w.landgraf@ru.ru>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent bcad87bd
Loading
Loading
Loading
Loading
+9 −13
Original line number Original line Diff line number Diff line
@@ -96,21 +96,15 @@ static int tc3589x_keypad_init_key_hardware(struct tc_keypad *keypad)
{
{
	int ret;
	int ret;
	struct tc3589x *tc3589x = keypad->tc3589x;
	struct tc3589x *tc3589x = keypad->tc3589x;
	u8 settle_time = keypad->board->settle_time;
	const struct tc3589x_keypad_platform_data *board = keypad->board;
	u8 dbounce_period = keypad->board->debounce_period;

	u8 rows = keypad->board->krow & 0xf;	/* mask out the nibble */
	/* validate platform configuration */
	u8 column = keypad->board->kcol & 0xf;	/* mask out the nibble */
	if (board->kcol > TC3589x_MAX_KPCOL || board->krow > TC3589x_MAX_KPROW)

	/* validate platform configurations */
	if (keypad->board->kcol > TC3589x_MAX_KPCOL ||
	    keypad->board->krow > TC3589x_MAX_KPROW ||
	    keypad->board->debounce_period > TC3589x_MAX_DEBOUNCE_SETTLE ||
	    keypad->board->settle_time > TC3589x_MAX_DEBOUNCE_SETTLE)
		return -EINVAL;
		return -EINVAL;


	/* configure KBDSIZE 4 LSbits for cols and 4 MSbits for rows */
	/* configure KBDSIZE 4 LSbits for cols and 4 MSbits for rows */
	ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSIZE,
	ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSIZE,
			(rows << KP_ROW_SHIFT) | column);
			(board->krow << KP_ROW_SHIFT) | board->kcol);
	if (ret < 0)
	if (ret < 0)
		return ret;
		return ret;


@@ -124,12 +118,14 @@ static int tc3589x_keypad_init_key_hardware(struct tc_keypad *keypad)
		return ret;
		return ret;


	/* Configure settle time */
	/* Configure settle time */
	ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSETTLE_REG, settle_time);
	ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSETTLE_REG,
				board->settle_time);
	if (ret < 0)
	if (ret < 0)
		return ret;
		return ret;


	/* Configure debounce time */
	/* Configure debounce time */
	ret = tc3589x_reg_write(tc3589x, TC3589x_KBDBOUNCE, dbounce_period);
	ret = tc3589x_reg_write(tc3589x, TC3589x_KBDBOUNCE,
				board->debounce_period);
	if (ret < 0)
	if (ret < 0)
		return ret;
		return ret;