diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-04-21 01:33:09 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-04-21 02:08:48 -0400 |
commit | 71f3d070a309504cdfef87b9e98836395b75ae0e (patch) | |
tree | 75ed4cbae62fece04fd06a15a7460fa8215bb2fa /drivers | |
parent | bcad87bd92f4331d4422c1afd571e66f7f5c95d6 (diff) |
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: Werner <w.landgraf@ru.ru>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/keyboard/tc3589x-keypad.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c index 2dee3e4e7c6f..f4da2a7a6970 100644 --- a/drivers/input/keyboard/tc3589x-keypad.c +++ b/drivers/input/keyboard/tc3589x-keypad.c | |||
@@ -96,21 +96,15 @@ static int tc3589x_keypad_init_key_hardware(struct tc_keypad *keypad) | |||
96 | { | 96 | { |
97 | int ret; | 97 | int ret; |
98 | struct tc3589x *tc3589x = keypad->tc3589x; | 98 | struct tc3589x *tc3589x = keypad->tc3589x; |
99 | u8 settle_time = keypad->board->settle_time; | 99 | const struct tc3589x_keypad_platform_data *board = keypad->board; |
100 | u8 dbounce_period = keypad->board->debounce_period; | 100 | |
101 | u8 rows = keypad->board->krow & 0xf; /* mask out the nibble */ | 101 | /* validate platform configuration */ |
102 | u8 column = keypad->board->kcol & 0xf; /* mask out the nibble */ | 102 | if (board->kcol > TC3589x_MAX_KPCOL || board->krow > TC3589x_MAX_KPROW) |
103 | |||
104 | /* validate platform configurations */ | ||
105 | if (keypad->board->kcol > TC3589x_MAX_KPCOL || | ||
106 | keypad->board->krow > TC3589x_MAX_KPROW || | ||
107 | keypad->board->debounce_period > TC3589x_MAX_DEBOUNCE_SETTLE || | ||
108 | keypad->board->settle_time > TC3589x_MAX_DEBOUNCE_SETTLE) | ||
109 | return -EINVAL; | 103 | return -EINVAL; |
110 | 104 | ||
111 | /* configure KBDSIZE 4 LSbits for cols and 4 MSbits for rows */ | 105 | /* configure KBDSIZE 4 LSbits for cols and 4 MSbits for rows */ |
112 | ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSIZE, | 106 | ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSIZE, |
113 | (rows << KP_ROW_SHIFT) | column); | 107 | (board->krow << KP_ROW_SHIFT) | board->kcol); |
114 | if (ret < 0) | 108 | if (ret < 0) |
115 | return ret; | 109 | return ret; |
116 | 110 | ||
@@ -124,12 +118,14 @@ static int tc3589x_keypad_init_key_hardware(struct tc_keypad *keypad) | |||
124 | return ret; | 118 | return ret; |
125 | 119 | ||
126 | /* Configure settle time */ | 120 | /* Configure settle time */ |
127 | ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSETTLE_REG, settle_time); | 121 | ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSETTLE_REG, |
122 | board->settle_time); | ||
128 | if (ret < 0) | 123 | if (ret < 0) |
129 | return ret; | 124 | return ret; |
130 | 125 | ||
131 | /* Configure debounce time */ | 126 | /* Configure debounce time */ |
132 | ret = tc3589x_reg_write(tc3589x, TC3589x_KBDBOUNCE, dbounce_period); | 127 | ret = tc3589x_reg_write(tc3589x, TC3589x_KBDBOUNCE, |
128 | board->debounce_period); | ||
133 | if (ret < 0) | 129 | if (ret < 0) |
134 | return ret; | 130 | return ret; |
135 | 131 | ||