Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Rui Teng and committed by
Dmitry Torokhov
82ba0d8b 9e4cc255

+16 -12
+16 -12
drivers/input/keyboard/twl4030_keypad.c
··· 61 61 unsigned short keymap[TWL4030_KEYMAP_SIZE]; 62 62 u16 kp_state[TWL4030_MAX_ROWS]; 63 63 bool autorepeat; 64 - unsigned n_rows; 65 - unsigned n_cols; 66 - unsigned irq; 64 + unsigned int n_rows; 65 + unsigned int n_cols; 66 + unsigned int irq; 67 67 68 68 struct device *dbg_dev; 69 69 struct input_dev *input; ··· 110 110 #define KEYP_CTRL_KBD_ON BIT(6) 111 111 112 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 115 /* KEYP_LK_PTV_REG Fields */ 116 116 #define KEYP_LK_PTV_PTV_SHIFT 5 ··· 162 162 163 163 static 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 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 169 * one higher than the size of the matrix). 169 170 */ 170 171 if (col == 0xFF) ··· 210 209 u16 new_state[TWL4030_MAX_ROWS]; 211 210 int col, row; 212 211 213 - if (release_all) 212 + if (release_all) { 214 213 memset(new_state, 0, sizeof(new_state)); 215 - else { 214 + } else { 216 215 /* check for any changes */ 217 216 int ret = twl4030_read_kp_matrix_state(kp, new_state); 218 217 ··· 263 262 /* Read & Clear TWL4030 pending interrupt */ 264 263 ret = twl4030_kpread(kp, &reg, KEYP_ISR1, 1); 265 264 266 - /* Release all keys if I2C has gone bad or 267 - * the KEYP has gone to idle state */ 265 + /* 266 + * Release all keys if I2C has gone bad or 267 + * the KEYP has gone to idle state. 268 + */ 268 269 if (ret >= 0 && (reg & KEYP_IMR1_KP)) 269 270 twl4030_kp_scan(kp, false); 270 271 else ··· 286 283 if (twl4030_kpwrite_u8(kp, reg, KEYP_CTRL) < 0) 287 284 return -EIO; 288 285 289 - /* NOTE: we could use sih_setup() here to package keypad 286 + /* 287 + * NOTE: we could use sih_setup() here to package keypad 290 288 * event sources as four different IRQs ... but we don't. 291 289 */ 292 290 ··· 316 312 317 313 /* 318 314 * Enable Clear-on-Read; disable remembering events that fire 319 - * after the IRQ but before our handler acks (reads) them, 315 + * after the IRQ but before our handler acks (reads) them. 320 316 */ 321 317 reg = TWL4030_SIH_CTRL_COR_MASK | TWL4030_SIH_CTRL_PENDDIS_MASK; 322 318 if (twl4030_kpwrite_u8(kp, reg, KEYP_SIH_CTRL) < 0)