@@ -27,9 +27,10 @@ struct matrix_keypad {
27
27
const struct matrix_keypad_platform_data * pdata ;
28
28
struct input_dev * input_dev ;
29
29
unsigned int row_shift ;
30
- unsigned int row_irqs [MATRIX_MAX_ROWS ];
31
30
32
- DECLARE_BITMAP (disabled_gpios , MATRIX_MAX_ROWS );
31
+ unsigned int row_irqs [MATRIX_MAX_ROWS ];
32
+ unsigned int num_row_irqs ;
33
+ DECLARE_BITMAP (wakeup_enabled_irqs , MATRIX_MAX_ROWS );
33
34
34
35
uint32_t last_key_state [MATRIX_MAX_COLS ];
35
36
struct delayed_work work ;
@@ -86,28 +87,18 @@ static bool row_asserted(const struct matrix_keypad_platform_data *pdata,
86
87
87
88
static void enable_row_irqs (struct matrix_keypad * keypad )
88
89
{
89
- const struct matrix_keypad_platform_data * pdata = keypad -> pdata ;
90
90
int i ;
91
91
92
- if (pdata -> clustered_irq > 0 )
93
- enable_irq (pdata -> clustered_irq );
94
- else {
95
- for (i = 0 ; i < pdata -> num_row_gpios ; i ++ )
96
- enable_irq (keypad -> row_irqs [i ]);
97
- }
92
+ for (i = 0 ; i < keypad -> num_row_irqs ; i ++ )
93
+ enable_irq (keypad -> row_irqs [i ]);
98
94
}
99
95
100
96
static void disable_row_irqs (struct matrix_keypad * keypad )
101
97
{
102
- const struct matrix_keypad_platform_data * pdata = keypad -> pdata ;
103
98
int i ;
104
99
105
- if (pdata -> clustered_irq > 0 )
106
- disable_irq_nosync (pdata -> clustered_irq );
107
- else {
108
- for (i = 0 ; i < pdata -> num_row_gpios ; i ++ )
109
- disable_irq_nosync (keypad -> row_irqs [i ]);
110
- }
100
+ for (i = 0 ; i < keypad -> num_row_irqs ; i ++ )
101
+ disable_irq_nosync (keypad -> row_irqs [i ]);
111
102
}
112
103
113
104
/*
@@ -233,35 +224,20 @@ static void matrix_keypad_stop(struct input_dev *dev)
233
224
234
225
static void matrix_keypad_enable_wakeup (struct matrix_keypad * keypad )
235
226
{
236
- const struct matrix_keypad_platform_data * pdata = keypad -> pdata ;
237
227
int i ;
238
228
239
- if (pdata -> clustered_irq > 0 ) {
240
- if (enable_irq_wake (pdata -> clustered_irq ) == 0 )
241
- keypad -> gpio_all_disabled = true;
242
- } else {
243
-
244
- for (i = 0 ; i < pdata -> num_row_gpios ; i ++ )
245
- if (!test_bit (i , keypad -> disabled_gpios ))
246
- if (enable_irq_wake (keypad -> row_irqs [i ]) == 0 )
247
- __set_bit (i , keypad -> disabled_gpios );
248
- }
229
+ for_each_clear_bit (i , keypad -> wakeup_enabled_irqs , keypad -> num_row_irqs )
230
+ if (enable_irq_wake (keypad -> row_irqs [i ]) == 0 )
231
+ __set_bit (i , keypad -> wakeup_enabled_irqs );
249
232
}
250
233
251
234
static void matrix_keypad_disable_wakeup (struct matrix_keypad * keypad )
252
235
{
253
- const struct matrix_keypad_platform_data * pdata = keypad -> pdata ;
254
236
int i ;
255
237
256
- if (pdata -> clustered_irq > 0 ) {
257
- if (keypad -> gpio_all_disabled ) {
258
- disable_irq_wake (pdata -> clustered_irq );
259
- keypad -> gpio_all_disabled = false;
260
- }
261
- } else {
262
- for (i = 0 ; i < pdata -> num_row_gpios ; i ++ )
263
- if (test_and_clear_bit (i , keypad -> disabled_gpios ))
264
- disable_irq_wake (keypad -> row_irqs [i ]);
238
+ for_each_set_bit (i , keypad -> wakeup_enabled_irqs , keypad -> num_row_irqs ) {
239
+ disable_irq_wake (keypad -> row_irqs [i ]);
240
+ __clear_bit (i , keypad -> wakeup_enabled_irqs );
265
241
}
266
242
}
267
243
@@ -335,6 +311,9 @@ static int matrix_keypad_init_gpio(struct platform_device *pdev,
335
311
"Unable to acquire clustered interrupt\n" );
336
312
goto err_free_rows ;
337
313
}
314
+
315
+ keypad -> row_irqs [0 ] = pdata -> clustered_irq ;
316
+ keypad -> num_row_irqs = 1 ;
338
317
} else {
339
318
for (i = 0 ; i < pdata -> num_row_gpios ; i ++ ) {
340
319
irq = gpio_to_irq (pdata -> row_gpios [i ]);
@@ -360,6 +339,8 @@ static int matrix_keypad_init_gpio(struct platform_device *pdev,
360
339
361
340
keypad -> row_irqs [i ] = irq ;
362
341
}
342
+
343
+ keypad -> num_row_irqs = pdata -> num_row_gpios ;
363
344
}
364
345
365
346
/* initialized as disabled - enabled by input->open */
@@ -386,12 +367,8 @@ static void matrix_keypad_free_gpio(struct matrix_keypad *keypad)
386
367
const struct matrix_keypad_platform_data * pdata = keypad -> pdata ;
387
368
int i ;
388
369
389
- if (pdata -> clustered_irq > 0 ) {
390
- free_irq (pdata -> clustered_irq , keypad );
391
- } else {
392
- for (i = 0 ; i < pdata -> num_row_gpios ; i ++ )
393
- free_irq (keypad -> row_irqs [i ], keypad );
394
- }
370
+ for (i = 0 ; i < keypad -> num_row_irqs ; i ++ )
371
+ free_irq (keypad -> row_irqs [i ], keypad );
395
372
396
373
for (i = 0 ; i < pdata -> num_row_gpios ; i ++ )
397
374
gpio_free (pdata -> row_gpios [i ]);
0 commit comments