@@ -238,36 +238,6 @@ static void adnp_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
238
238
mutex_unlock (& adnp -> i2c_lock );
239
239
}
240
240
241
- static int adnp_gpio_setup (struct adnp * adnp , unsigned int num_gpios )
242
- {
243
- struct gpio_chip * chip = & adnp -> gpio ;
244
- int err ;
245
-
246
- adnp -> reg_shift = get_count_order (num_gpios ) - 3 ;
247
-
248
- chip -> direction_input = adnp_gpio_direction_input ;
249
- chip -> direction_output = adnp_gpio_direction_output ;
250
- chip -> get = adnp_gpio_get ;
251
- chip -> set = adnp_gpio_set ;
252
- chip -> can_sleep = true;
253
-
254
- if (IS_ENABLED (CONFIG_DEBUG_FS ))
255
- chip -> dbg_show = adnp_gpio_dbg_show ;
256
-
257
- chip -> base = -1 ;
258
- chip -> ngpio = num_gpios ;
259
- chip -> label = adnp -> client -> name ;
260
- chip -> parent = & adnp -> client -> dev ;
261
- chip -> of_node = chip -> parent -> of_node ;
262
- chip -> owner = THIS_MODULE ;
263
-
264
- err = devm_gpiochip_add_data (& adnp -> client -> dev , chip , adnp );
265
- if (err )
266
- return err ;
267
-
268
- return 0 ;
269
- }
270
-
271
241
static irqreturn_t adnp_irq (int irq , void * data )
272
242
{
273
243
struct adnp * adnp = data ;
@@ -464,18 +434,54 @@ static int adnp_irq_setup(struct adnp *adnp)
464
434
return err ;
465
435
}
466
436
467
- err = gpiochip_irqchip_add_nested (chip ,
468
- & adnp_irq_chip ,
469
- 0 ,
470
- handle_simple_irq ,
471
- IRQ_TYPE_NONE );
472
- if (err ) {
473
- dev_err (chip -> parent ,
474
- "could not connect irqchip to gpiochip\n" );
475
- return err ;
437
+ return 0 ;
438
+ }
439
+
440
+ static int adnp_gpio_setup (struct adnp * adnp , unsigned int num_gpios ,
441
+ bool is_irq_controller )
442
+ {
443
+ struct gpio_chip * chip = & adnp -> gpio ;
444
+ int err ;
445
+
446
+ adnp -> reg_shift = get_count_order (num_gpios ) - 3 ;
447
+
448
+ chip -> direction_input = adnp_gpio_direction_input ;
449
+ chip -> direction_output = adnp_gpio_direction_output ;
450
+ chip -> get = adnp_gpio_get ;
451
+ chip -> set = adnp_gpio_set ;
452
+ chip -> can_sleep = true;
453
+
454
+ if (IS_ENABLED (CONFIG_DEBUG_FS ))
455
+ chip -> dbg_show = adnp_gpio_dbg_show ;
456
+
457
+ chip -> base = -1 ;
458
+ chip -> ngpio = num_gpios ;
459
+ chip -> label = adnp -> client -> name ;
460
+ chip -> parent = & adnp -> client -> dev ;
461
+ chip -> of_node = chip -> parent -> of_node ;
462
+ chip -> owner = THIS_MODULE ;
463
+
464
+ if (is_irq_controller ) {
465
+ struct gpio_irq_chip * girq ;
466
+
467
+ err = adnp_irq_setup (adnp );
468
+ if (err )
469
+ return err ;
470
+
471
+ girq = & chip -> irq ;
472
+ girq -> chip = & adnp_irq_chip ;
473
+ /* This will let us handle the parent IRQ in the driver */
474
+ girq -> parent_handler = NULL ;
475
+ girq -> num_parents = 0 ;
476
+ girq -> parents = NULL ;
477
+ girq -> default_type = IRQ_TYPE_NONE ;
478
+ girq -> handler = handle_simple_irq ;
479
+ girq -> threaded = true;
476
480
}
477
481
478
- gpiochip_set_nested_irqchip (chip , & adnp_irq_chip , adnp -> client -> irq );
482
+ err = devm_gpiochip_add_data (& adnp -> client -> dev , chip , adnp );
483
+ if (err )
484
+ return err ;
479
485
480
486
return 0 ;
481
487
}
@@ -503,16 +509,11 @@ static int adnp_i2c_probe(struct i2c_client *client,
503
509
mutex_init (& adnp -> i2c_lock );
504
510
adnp -> client = client ;
505
511
506
- err = adnp_gpio_setup (adnp , num_gpios );
512
+ err = adnp_gpio_setup (adnp , num_gpios ,
513
+ of_property_read_bool (np , "interrupt-controller" ));
507
514
if (err )
508
515
return err ;
509
516
510
- if (of_find_property (np , "interrupt-controller" , NULL )) {
511
- err = adnp_irq_setup (adnp );
512
- if (err )
513
- return err ;
514
- }
515
-
516
517
i2c_set_clientdata (client , adnp );
517
518
518
519
return 0 ;
0 commit comments