linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] mfd: da9052-core: Use regmap_irq_get_virq() and fix the probe
@ 2012-10-04  3:15 Fabio Estevam
  2012-10-04  3:15 ` [PATCH 2/6] mfd: da9052: Introduce da9052-irq.c Fabio Estevam
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: Fabio Estevam @ 2012-10-04  3:15 UTC (permalink / raw)
  To: sameo
  Cc: broonie, ashish.jangam, dchen, arnd, kernel, linux-kernel,
	Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

On a mx53qsb dt-kernel the da9052-core driver fails to probe as follows:

da9052 1-0048: DA9052 ADC IRQ failed ret=-22

The reason for the error was due to passing only the offset as the interrupt
number in request_threaded_irq() without da9052->irq_base.

The recommended approach though is to use regmap_get_virq() to acquire the
interrupt number and this allows to get rid of da9052->irq_base.

Fix it and allow the driver to probe successfully.

Also provide a few more error logs and change the irq string to "adc-irq", so
that it appears as a single word in 'cat /proc/interrupts'

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/mfd/da9052-core.c |   34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c
index a0a62b2..c96cdbc 100644
--- a/drivers/mfd/da9052-core.c
+++ b/drivers/mfd/da9052-core.c
@@ -769,10 +769,15 @@ struct regmap_config da9052_regmap_config = {
 };
 EXPORT_SYMBOL_GPL(da9052_regmap_config);
 
+static int da9052_map_irq(struct da9052 *da9052, int irq)
+{
+	return regmap_irq_get_virq(da9052->irq_data, irq);
+}
+
 int __devinit da9052_device_init(struct da9052 *da9052, u8 chip_id)
 {
 	struct da9052_pdata *pdata = da9052->dev->platform_data;
-	int ret;
+	int ret, i;
 
 	mutex_init(&da9052->auxadc_lock);
 	init_completion(&da9052->done);
@@ -782,35 +787,34 @@ int __devinit da9052_device_init(struct da9052 *da9052, u8 chip_id)
 
 	da9052->chip_id = chip_id;
 
-	if (!pdata || !pdata->irq_base)
-		da9052->irq_base = -1;
-	else
-		da9052->irq_base = pdata->irq_base;
-
 	ret = regmap_add_irq_chip(da9052->regmap, da9052->chip_irq,
 				  IRQF_TRIGGER_LOW | IRQF_ONESHOT,
-				  da9052->irq_base, &da9052_regmap_irq_chip,
+				  -1, &da9052_regmap_irq_chip,
 				  &da9052->irq_data);
-	if (ret < 0)
+	if (ret < 0) {
+		dev_err(da9052->dev, "regmap_add_irq_chip failed: %d\n", ret);
 		goto regmap_err;
+	}
 
-	da9052->irq_base = regmap_irq_chip_get_base(da9052->irq_data);
-
-	ret = request_threaded_irq(DA9052_IRQ_ADC_EOM, NULL, da9052_auxadc_irq,
+	i = da9052_map_irq(da9052, DA9052_IRQ_ADC_EOM);
+	ret = request_threaded_irq(i, NULL, da9052_auxadc_irq,
 				   IRQF_TRIGGER_LOW | IRQF_ONESHOT,
-				   "adc irq", da9052);
+				   "adc-irq", da9052);
 	if (ret != 0)
 		dev_err(da9052->dev, "DA9052 ADC IRQ failed ret=%d\n", ret);
 
 	ret = mfd_add_devices(da9052->dev, -1, da9052_subdev_info,
 			      ARRAY_SIZE(da9052_subdev_info), NULL, 0, NULL);
-	if (ret)
+	if (ret) {
+		dev_err(da9052->dev, "mfd_add_devices failed: %d\n", ret);
 		goto err;
+	}
 
 	return 0;
 
 err:
-	free_irq(DA9052_IRQ_ADC_EOM, da9052);
+	free_irq(da9052_map_irq(da9052, DA9052_IRQ_ADC_EOM), da9052);
+	regmap_del_irq_chip(da9052->chip_irq, da9052->irq_data);
 	mfd_remove_devices(da9052->dev);
 regmap_err:
 	return ret;
@@ -818,7 +822,7 @@ regmap_err:
 
 void da9052_device_exit(struct da9052 *da9052)
 {
-	free_irq(DA9052_IRQ_ADC_EOM, da9052);
+	free_irq(da9052_map_irq(da9052, DA9052_IRQ_ADC_EOM), da9052);
 	regmap_del_irq_chip(da9052->chip_irq, da9052->irq_data);
 	mfd_remove_devices(da9052->dev);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2012-11-18 23:44 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-04  3:15 [PATCH 1/6] mfd: da9052-core: Use regmap_irq_get_virq() and fix the probe Fabio Estevam
2012-10-04  3:15 ` [PATCH 2/6] mfd: da9052: Introduce da9052-irq.c Fabio Estevam
2012-10-04  7:12   ` Arnd Bergmann
2012-10-04 11:14     ` Mark Brown
2012-10-04 12:17       ` Arnd Bergmann
2012-10-04 11:25   ` Mark Brown
2012-10-04  3:15 ` [PATCH 3/6] Input: da9052_tsi.c: Fix interrupt handling Fabio Estevam
2012-10-04  3:15 ` [PATCH 4/6] Input: da9052_onkey.c: Convert to the new da9052 interrupt functions Fabio Estevam
2012-10-05 18:57   ` Mark Brown
2012-10-04  3:15 ` [PATCH 5/6] power: da9052-battery: " Fabio Estevam
2012-10-05 18:58   ` Mark Brown
2012-11-18  4:20   ` Anton Vorontsov
2012-11-18 12:30     ` Fabio Estevam
2012-10-04  3:15 ` [PATCH 6/6] gpio: gpio-da9052: " Fabio Estevam
2012-10-04 11:26   ` Mark Brown
2012-10-08  6:20   ` Linus Walleij
2012-10-08 10:40     ` Fabio Estevam
2012-10-09 12:04       ` Linus Walleij
2012-10-09 12:19         ` Fabio Estevam
2012-10-04 11:26 ` [PATCH 1/6] mfd: da9052-core: Use regmap_irq_get_virq() and fix the probe Mark Brown
2012-11-12 16:22   ` Fabio Estevam
2012-11-18 23:44 ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).