Skip to contentSkip to conversation

mfd: da9052-core: Fix request_threaded_irq() parameter

PATCH In review Fabio Estevam 4 participants 5 messages Sep 27, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: da9052-core: Fix request_threaded_irq() parameter

From: Fabio Estevam <[email protected]>

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

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

In request_threaded_irq() the first parameter is missing the da9052->irq_base.

Fix it and avoid the error.

Also define 'DA9052_IRQF' for improving readability.

---
 drivers/mfd/da9052-core.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mfd/da9052-core.c +5 -5
index a0a62b2..a3450d2 100644
@@ -33,6 +33,7 @@
 #define DA9052_IRQ_MASK_POS_6		0x20
 #define DA9052_IRQ_MASK_POS_7		0x40
 #define DA9052_IRQ_MASK_POS_8		0x80
+#define DA9052_IRQF			(IRQF_TRIGGER_LOW | IRQF_ONESHOT)
 
 static bool da9052_reg_readable(struct device *dev, unsigned int reg)
 {
@@ -788,16 +789,15 @@ int __devinit da9052_device_init(struct da9052 *da9052, u8 chip_id)
 		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,
-				  &da9052->irq_data);
+				  DA9052_IRQF, da9052->irq_base,
+				  &da9052_regmap_irq_chip, &da9052->irq_data);
 	if (ret < 0)
 		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,
-				   IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+	ret = request_threaded_irq(da9052->irq_base + DA9052_IRQ_ADC_EOM, NULL,
+				   da9052_auxadc_irq, DA9052_IRQF,
 				   "adc irq", da9052);
 	if (ret != 0)
 		dev_err(da9052->dev, "DA9052 ADC IRQ failed ret=%d\n", ret);
Signature · 1 line
1.7.9.5
Reviewed-by on v1 1/1
#1 lore raw

Dear Fabio Estevam,

Quoted 6 lines

From: Fabio Estevam <[email protected]>

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

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

Quoted 8 lines

In request_threaded_irq() the first parameter is missing the da9052->irq_base.

Fix it and avoid the error.

Also define 'DA9052_IRQF' for improving readability.

Quoted 27 lines
---
 drivers/mfd/da9052-core.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mfd/da9052-core.c +3 -3
index a0a62b2..a3450d2 100644
@@ -33,6 +33,7 @@
 #define DA9052_IRQ_MASK_POS_6		0x20
 #define DA9052_IRQ_MASK_POS_7		0x40
 #define DA9052_IRQ_MASK_POS_8		0x80
+#define DA9052_IRQF			(IRQF_TRIGGER_LOW | IRQF_ONESHOT)
 
 static bool da9052_reg_readable(struct device *dev, unsigned int reg)
 {
@@ -788,16 +789,15 @@ int __devinit da9052_device_init(struct da9052
 *da9052, u8 chip_id) 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,
-				  &da9052->irq_data);
+				  DA9052_IRQF, da9052->irq_base,
+				  &da9052_regmap_irq_chip, &da9052->irq_data);
 	if (ret < 0)
 		goto regmap_err;

drivers/mfd/da9052-core.c int __devinit da9052_device_init(struct da9052 · line 803

Quoted 10 lines
drivers/mfd/da9052-core.c +2 -2
 
 	da9052->irq_base = regmap_irq_chip_get_base(da9052->irq_data);
 
-	ret = request_threaded_irq(DA9052_IRQ_ADC_EOM, NULL, da9052_auxadc_irq,
-				   IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+	ret = request_threaded_irq(da9052->irq_base + DA9052_IRQ_ADC_EOM, NULL,
+				   da9052_auxadc_irq, DA9052_IRQF,
 				   "adc irq", da9052);
 	if (ret != 0)
 		dev_err(da9052->dev, "DA9052 ADC IRQ failed ret=%d\n", ret);

Best regards,
Marek Vasut

#2 lore raw
In reply to Fabio Estevam
Quoted 9 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

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

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

In request_threaded_irq() the first parameter is missing the da9052->irq_base.

Fix it and avoid the error.

The driver shouldn't be relying on irq_base at all, it should use regmap_get_virq() to look up the interrupt number. If it relies on irq_base then the user is forced to assign one (or rely on automatic assignment, which is a bit erratic. Otherwise it can use a linear domain which doesn't rely on being able to allocate a big block of interrupt numbers.

#3 lore raw
Quoted 9 lines · Mark Brown
Quoted 8 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

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

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

In request_threaded_irq() the first parameter is missing the da9052->irq_base.

Quoted 8 lines
Quoted 1 line

Fix it and avoid the error.

The driver shouldn't be relying on irq_base at all, it should use regmap_get_virq() to look up the interrupt number. If it relies on irq_base then the user is forced to assign one (or rely on automatic assignment, which is a bit erratic. Otherwise it can use a linear domain which doesn't rely on being able to allocate a big block of interrupt numbers.

For all I can tell, the driver implements the automatic assignment correctly, but I was also going to ask for removing the da9052->irq_base variable and using the linear domain instead.

We don't have any platforms actually setting the irq_base in the mainline kernel (I assume some of out tree platforms do this), but there are a few drivers that need to be adapted to use regmap_irq_get_virq or irq_to_desc(irq)->hw_irq, respectively:

drivers/gpio/gpio-da9052.c: return da9052->irq_base + DA9052_IRQ_GPI0 + offset;
drivers/input/touchscreen/da9052_tsi.c: tsi->irq_pendwn = da9052->irq_base + irq_pendwn; drivers/input/touchscreen/da9052_tsi.c: tsi->irq_datardy = da9052->irq_base + irq_datardy;

drivers/power/da9052-battery.c: irq -= bat->da9052->irq_base;
drivers/power/da9052-battery.c:         ret = request_threaded_irq(bat->da9052->irq_base + irq,
drivers/power/da9052-battery.c:         free_irq(bat->da9052->irq_base + irq, bat);
drivers/power/da9052-battery.c:         free_irq(bat->da9052->irq_base + irq, bat);

Arnd

#4 lore raw
Quoted 9 lines · Arnd Bergmann
Quoted 6 lines · Mark Brown

The driver shouldn't be relying on irq_base at all, it should use regmap_get_virq() to look up the interrupt number. If it relies on irq_base then the user is forced to assign one (or rely on automatic assignment, which is a bit erratic. Otherwise it can use a linear domain which doesn't rely on being able to allocate a big block of interrupt numbers.

Quoted 3 lines

For all I can tell, the driver implements the automatic assignment correctly, but I was also going to ask for removing the da9052->irq_base variable and using the linear domain instead.

It's possible, IIRC last time I looked at it for API updates I decided it was so clearly never going to work due to requesting without using irq_base that I just ignored it for the purposes of compliation.

Quoted 2 lines

We don't have any platforms actually setting the irq_base in the mainline kernel (I assume some of out tree platforms do this), but there

It's relatively rare to use the GPIOs as IRQs which is the only reason you'd need to do this. That said I'm frankly unconvinced that the driver has ever been tested given the general pain with the original submission process.

Quoted 4 lines

are a few drivers that need to be adapted to use regmap_irq_get_virq or irq_to_desc(irq)->hw_irq, respectively:

drivers/gpio/gpio-da9052.c: return da9052->irq_base + DA9052_IRQ_GPI0 + offset;

Yeah, they all ought to be converted.