Skip to content

Commit d20e1d2

Browse files
author
Peter Ujfalusi
committed
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>
1 parent 2a433b9 commit d20e1d2

2 files changed

Lines changed: 22 additions & 36 deletions

File tree

‎drivers/mfd/twl6040-core.c‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,12 @@ static int __devinit twl6040_probe(struct platform_device *pdev)
459459
return -EINVAL;
460460
}
461461

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+
462468
twl6040 = kzalloc(sizeof(struct twl6040), GFP_KERNEL);
463469
if (!twl6040)
464470
return -ENOMEM;
@@ -491,20 +497,18 @@ static int __devinit twl6040_probe(struct platform_device *pdev)
491497
if (twl6040->rev == TWL6040_REV_ES1_0)
492498
twl6040->audpwron = -EINVAL;
493499

494-
if (twl6040->irq) {
495-
/* codec interrupt */
496-
ret = twl6040_irq_init(twl6040);
497-
if (ret)
498-
goto gpio2_err;
499-
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-
}
500+
/* codec interrupt */
501+
ret = twl6040_irq_init(twl6040);
502+
if (ret)
503+
goto gpio2_err;
504+
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;
508512
}
509513

510514
/* dual-access registers controlled by I2C only */
@@ -553,11 +557,9 @@ static int __devinit twl6040_probe(struct platform_device *pdev)
553557
return 0;
554558

555559
mfd_err:
556-
if (twl6040->irq)
557-
twl6040_free_irq(twl6040, TWL6040_IRQ_READY, twl6040);
560+
twl6040_free_irq(twl6040, TWL6040_IRQ_READY, twl6040);
558561
irq_err:
559-
if (twl6040->irq)
560-
twl6040_irq_exit(twl6040);
562+
twl6040_irq_exit(twl6040);
561563
gpio2_err:
562564
if (gpio_is_valid(twl6040->audpwron))
563565
gpio_free(twl6040->audpwron);
@@ -579,9 +581,7 @@ static int __devexit twl6040_remove(struct platform_device *pdev)
579581
gpio_free(twl6040->audpwron);
580582

581583
twl6040_free_irq(twl6040, TWL6040_IRQ_READY, twl6040);
582-
583-
if (twl6040->irq)
584-
twl6040_irq_exit(twl6040);
584+
twl6040_irq_exit(twl6040);
585585

586586
mfd_remove_devices(&pdev->dev);
587587
platform_set_drvdata(pdev, NULL);

‎drivers/mfd/twl6040-irq.c‎

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,19 +148,6 @@ int twl6040_irq_init(struct twl6040 *twl6040)
148148
twl6040->irq_masks_cache = TWL6040_ALLINT_MSK;
149149
twl6040_reg_write(twl6040, TWL6040_REG_INTMR, TWL6040_ALLINT_MSK);
150150

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-
164151
/* Register them with genirq */
165152
for (cur_irq = twl6040->irq_base;
166153
cur_irq < twl6040->irq_base + ARRAY_SIZE(twl6040_irqs);
@@ -199,7 +186,6 @@ EXPORT_SYMBOL(twl6040_irq_init);
199186

200187
void twl6040_irq_exit(struct twl6040 *twl6040)
201188
{
202-
if (twl6040->irq)
203-
free_irq(twl6040->irq, twl6040);
189+
free_irq(twl6040->irq, twl6040);
204190
}
205191
EXPORT_SYMBOL(twl6040_irq_exit);

0 commit comments

Comments
 (0)