Commit d20e1d21fd0c398a8beb170beacf8e2ca839844c

Authored by Peter Ujfalusi
1 parent 2a433b9daf

MFD: twl6040: Demand valid interrupt configuration

In order to operate correctly twl6040 needs correct
interrupt configuration.
The slave drivers (vibra, and ASoC codec) will refuse
to probe, if the interrupt configuration is not correct.
In this way some checks can be removed from the code.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>

Showing 2 changed files with 22 additions and 36 deletions Side-by-side Diff

drivers/mfd/twl6040-core.c
... ... @@ -459,6 +459,12 @@
459 459 return -EINVAL;
460 460 }
461 461  
  462 + /* In order to operate correctly we need valid interrupt config */
  463 + if (!pdata->naudint_irq || !pdata->irq_base) {
  464 + dev_err(&pdev->dev, "Invalid IRQ configuration\n");
  465 + return -EINVAL;
  466 + }
  467 +
462 468 twl6040 = kzalloc(sizeof(struct twl6040), GFP_KERNEL);
463 469 if (!twl6040)
464 470 return -ENOMEM;
465 471  
... ... @@ -491,20 +497,18 @@
491 497 if (twl6040->rev == TWL6040_REV_ES1_0)
492 498 twl6040->audpwron = -EINVAL;
493 499  
494   - if (twl6040->irq) {
495   - /* codec interrupt */
496   - ret = twl6040_irq_init(twl6040);
497   - if (ret)
498   - goto gpio2_err;
  500 + /* codec interrupt */
  501 + ret = twl6040_irq_init(twl6040);
  502 + if (ret)
  503 + goto gpio2_err;
499 504  
500   - ret = twl6040_request_irq(twl6040, TWL6040_IRQ_READY,
501   - twl6040_naudint_handler, 0,
502   - "twl6040_irq_ready", twl6040);
503   - if (ret) {
504   - dev_err(twl6040->dev, "READY IRQ request failed: %d\n",
505   - ret);
506   - goto irq_err;
507   - }
  505 + ret = twl6040_request_irq(twl6040, TWL6040_IRQ_READY,
  506 + twl6040_naudint_handler, 0,
  507 + "twl6040_irq_ready", twl6040);
  508 + if (ret) {
  509 + dev_err(twl6040->dev, "READY IRQ request failed: %d\n",
  510 + ret);
  511 + goto irq_err;
508 512 }
509 513  
510 514 /* dual-access registers controlled by I2C only */
511 515  
... ... @@ -553,11 +557,9 @@
553 557 return 0;
554 558  
555 559 mfd_err:
556   - if (twl6040->irq)
557   - twl6040_free_irq(twl6040, TWL6040_IRQ_READY, twl6040);
  560 + twl6040_free_irq(twl6040, TWL6040_IRQ_READY, twl6040);
558 561 irq_err:
559   - if (twl6040->irq)
560   - twl6040_irq_exit(twl6040);
  562 + twl6040_irq_exit(twl6040);
561 563 gpio2_err:
562 564 if (gpio_is_valid(twl6040->audpwron))
563 565 gpio_free(twl6040->audpwron);
... ... @@ -579,9 +581,7 @@
579 581 gpio_free(twl6040->audpwron);
580 582  
581 583 twl6040_free_irq(twl6040, TWL6040_IRQ_READY, twl6040);
582   -
583   - if (twl6040->irq)
584   - twl6040_irq_exit(twl6040);
  584 + twl6040_irq_exit(twl6040);
585 585  
586 586 mfd_remove_devices(&pdev->dev);
587 587 platform_set_drvdata(pdev, NULL);
drivers/mfd/twl6040-irq.c
... ... @@ -148,19 +148,6 @@
148 148 twl6040->irq_masks_cache = TWL6040_ALLINT_MSK;
149 149 twl6040_reg_write(twl6040, TWL6040_REG_INTMR, TWL6040_ALLINT_MSK);
150 150  
151   - if (!twl6040->irq) {
152   - dev_warn(twl6040->dev,
153   - "no interrupt specified, no interrupts\n");
154   - twl6040->irq_base = 0;
155   - return 0;
156   - }
157   -
158   - if (!twl6040->irq_base) {
159   - dev_err(twl6040->dev,
160   - "no interrupt base specified, no interrupts\n");
161   - return 0;
162   - }
163   -
164 151 /* Register them with genirq */
165 152 for (cur_irq = twl6040->irq_base;
166 153 cur_irq < twl6040->irq_base + ARRAY_SIZE(twl6040_irqs);
... ... @@ -199,8 +186,7 @@
199 186  
200 187 void twl6040_irq_exit(struct twl6040 *twl6040)
201 188 {
202   - if (twl6040->irq)
203   - free_irq(twl6040->irq, twl6040);
  189 + free_irq(twl6040->irq, twl6040);
204 190 }
205 191 EXPORT_SYMBOL(twl6040_irq_exit);