aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Teng <rui.teng@linux.vnet.ibm.com>2016-04-26 12:45:13 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2016-04-29 16:59:00 -0400
commit82ba0d8ba48df5442ff31ee6f62b594f062bc162 (patch)
tree43097efd729bc829a33fa8c7170be52d3513b6e9
parent9e4cc255e6e18418ddbeea447efa506bb43d57a2 (diff)
Input: twl4030 - fix unsafe macro definition
The bitwise shift operator has lower priority than plus operator. So the values on macros should be enclosed in parentheses. For example, "(1 << 4 + 1)" means "(1 << (4 + 1))", but it is not expected by the macros. And also fix other two coding style problems reported by scripts/checkpatch.pl. Signed-off-by: Rui Teng <rui.teng@linux.vnet.ibm.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/keyboard/twl4030_keypad.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index bbcccd67247d..323a0fb575a4 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -61,9 +61,9 @@ struct twl4030_keypad {
61 unsigned short keymap[TWL4030_KEYMAP_SIZE]; 61 unsigned short keymap[TWL4030_KEYMAP_SIZE];
62 u16 kp_state[TWL4030_MAX_ROWS]; 62 u16 kp_state[TWL4030_MAX_ROWS];
63 bool autorepeat; 63 bool autorepeat;
64 unsigned n_rows; 64 unsigned int n_rows;
65 unsigned n_cols; 65 unsigned int n_cols;
66 unsigned irq; 66 unsigned int irq;
67 67
68 struct device *dbg_dev; 68 struct device *dbg_dev;
69 struct input_dev *input; 69 struct input_dev *input;
@@ -110,7 +110,7 @@ struct twl4030_keypad {
110#define KEYP_CTRL_KBD_ON BIT(6) 110#define KEYP_CTRL_KBD_ON BIT(6)
111 111
112/* KEYP_DEB, KEYP_LONG_KEY, KEYP_TIMEOUT_x*/ 112/* KEYP_DEB, KEYP_LONG_KEY, KEYP_TIMEOUT_x*/
113#define KEYP_PERIOD_US(t, prescale) ((t) / (31 << (prescale + 1)) - 1) 113#define KEYP_PERIOD_US(t, prescale) ((t) / (31 << ((prescale) + 1)) - 1)
114 114
115/* KEYP_LK_PTV_REG Fields */ 115/* KEYP_LK_PTV_REG Fields */
116#define KEYP_LK_PTV_PTV_SHIFT 5 116#define KEYP_LK_PTV_PTV_SHIFT 5
@@ -162,9 +162,10 @@ static int twl4030_kpwrite_u8(struct twl4030_keypad *kp, u8 data, u32 reg)
162 162
163static inline u16 twl4030_col_xlate(struct twl4030_keypad *kp, u8 col) 163static inline u16 twl4030_col_xlate(struct twl4030_keypad *kp, u8 col)
164{ 164{
165 /* If all bits in a row are active for all coloumns then 165 /*
166 * If all bits in a row are active for all columns then
166 * we have that row line connected to gnd. Mark this 167 * we have that row line connected to gnd. Mark this
167 * key on as if it was on matrix position n_cols (ie 168 * key on as if it was on matrix position n_cols (i.e.
168 * one higher than the size of the matrix). 169 * one higher than the size of the matrix).
169 */ 170 */
170 if (col == 0xFF) 171 if (col == 0xFF)
@@ -209,9 +210,9 @@ static void twl4030_kp_scan(struct twl4030_keypad *kp, bool release_all)
209 u16 new_state[TWL4030_MAX_ROWS]; 210 u16 new_state[TWL4030_MAX_ROWS];
210 int col, row; 211 int col, row;
211 212
212 if (release_all) 213 if (release_all) {
213 memset(new_state, 0, sizeof(new_state)); 214 memset(new_state, 0, sizeof(new_state));
214 else { 215 } else {
215 /* check for any changes */ 216 /* check for any changes */
216 int ret = twl4030_read_kp_matrix_state(kp, new_state); 217 int ret = twl4030_read_kp_matrix_state(kp, new_state);
217 218
@@ -262,8 +263,10 @@ static irqreturn_t do_kp_irq(int irq, void *_kp)
262 /* Read & Clear TWL4030 pending interrupt */ 263 /* Read & Clear TWL4030 pending interrupt */
263 ret = twl4030_kpread(kp, &reg, KEYP_ISR1, 1); 264 ret = twl4030_kpread(kp, &reg, KEYP_ISR1, 1);
264 265
265 /* Release all keys if I2C has gone bad or 266 /*
266 * the KEYP has gone to idle state */ 267 * Release all keys if I2C has gone bad or
268 * the KEYP has gone to idle state.
269 */
267 if (ret >= 0 && (reg & KEYP_IMR1_KP)) 270 if (ret >= 0 && (reg & KEYP_IMR1_KP))
268 twl4030_kp_scan(kp, false); 271 twl4030_kp_scan(kp, false);
269 else 272 else
@@ -283,7 +286,8 @@ static int twl4030_kp_program(struct twl4030_keypad *kp)
283 if (twl4030_kpwrite_u8(kp, reg, KEYP_CTRL) < 0) 286 if (twl4030_kpwrite_u8(kp, reg, KEYP_CTRL) < 0)
284 return -EIO; 287 return -EIO;
285 288
286 /* NOTE: we could use sih_setup() here to package keypad 289 /*
290 * NOTE: we could use sih_setup() here to package keypad
287 * event sources as four different IRQs ... but we don't. 291 * event sources as four different IRQs ... but we don't.
288 */ 292 */
289 293
@@ -312,7 +316,7 @@ static int twl4030_kp_program(struct twl4030_keypad *kp)
312 316
313 /* 317 /*
314 * Enable Clear-on-Read; disable remembering events that fire 318 * Enable Clear-on-Read; disable remembering events that fire
315 * after the IRQ but before our handler acks (reads) them, 319 * after the IRQ but before our handler acks (reads) them.
316 */ 320 */
317 reg = TWL4030_SIH_CTRL_COR_MASK | TWL4030_SIH_CTRL_PENDDIS_MASK; 321 reg = TWL4030_SIH_CTRL_COR_MASK | TWL4030_SIH_CTRL_PENDDIS_MASK;
318 if (twl4030_kpwrite_u8(kp, reg, KEYP_SIH_CTRL) < 0) 322 if (twl4030_kpwrite_u8(kp, reg, KEYP_SIH_CTRL) < 0)