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

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>

+21 -35
+20 -20
drivers/mfd/twl6040-core.c
··· 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; ··· 497 491 if (twl6040->rev == TWL6040_REV_ES1_0) 498 492 twl6040->audpwron = -EINVAL; 499 493 500 - if (twl6040->irq) { 501 - /* codec interrupt */ 502 - ret = twl6040_irq_init(twl6040); 503 - if (ret) 504 - goto gpio2_err; 494 + /* codec interrupt */ 495 + ret = twl6040_irq_init(twl6040); 496 + if (ret) 497 + goto gpio2_err; 505 498 506 - ret = twl6040_request_irq(twl6040, TWL6040_IRQ_READY, 507 - twl6040_naudint_handler, 0, 508 - "twl6040_irq_ready", twl6040); 509 - if (ret) { 510 - dev_err(twl6040->dev, "READY IRQ request failed: %d\n", 511 - ret); 512 - goto irq_err; 513 - } 499 + ret = twl6040_request_irq(twl6040, TWL6040_IRQ_READY, 500 + twl6040_naudint_handler, 0, 501 + "twl6040_irq_ready", twl6040); 502 + if (ret) { 503 + dev_err(twl6040->dev, "READY IRQ request failed: %d\n", 504 + ret); 505 + goto irq_err; 514 506 } 515 507 516 508 /* dual-access registers controlled by I2C only */ ··· 557 553 return 0; 558 554 559 555 mfd_err: 560 - if (twl6040->irq) 561 - twl6040_free_irq(twl6040, TWL6040_IRQ_READY, twl6040); 556 + twl6040_free_irq(twl6040, TWL6040_IRQ_READY, twl6040); 562 557 irq_err: 563 - if (twl6040->irq) 564 - twl6040_irq_exit(twl6040); 558 + twl6040_irq_exit(twl6040); 565 559 gpio2_err: 566 560 if (gpio_is_valid(twl6040->audpwron)) 567 561 gpio_free(twl6040->audpwron); ··· 581 579 gpio_free(twl6040->audpwron); 582 580 583 581 twl6040_free_irq(twl6040, TWL6040_IRQ_READY, twl6040); 584 - 585 - if (twl6040->irq) 586 - twl6040_irq_exit(twl6040); 582 + twl6040_irq_exit(twl6040); 587 583 588 584 mfd_remove_devices(&pdev->dev); 589 585 platform_set_drvdata(pdev, NULL);
+1 -15
drivers/mfd/twl6040-irq.c
··· 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); ··· 186 199 187 200 void twl6040_irq_exit(struct twl6040 *twl6040) 188 201 { 189 - if (twl6040->irq) 190 - free_irq(twl6040->irq, twl6040); 202 + free_irq(twl6040->irq, twl6040); 191 203 } 192 204 EXPORT_SYMBOL(twl6040_irq_exit);