Skip to contentSkip to conversation

regulator: ltc3589: Make IRQ optional

PATCH Superseded Bernhard Walle 2 participants 3 messages Feb 9, 2016 – Feb 10, 2016 Voltage and current regulator framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regulator: ltc3589: Make IRQ optional

It's perfectly valid to use the LTC3589 without an interrupt pin connected to it. Currently, the driver probing fails when client->irq is 0 (which means "no interrupt"). Don't register the interrupt handler in that case but successfully finish the device probing instead.

---
 drivers/regulator/ltc3589.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/regulator/ltc3589.c +8 -6
index 972c386..f2149d07 100644
@@ -520,12 +520,14 @@ static int ltc3589_probe(struct i2c_client *client,
 		}
 	}
 
-	ret = devm_request_threaded_irq(dev, client->irq, NULL, ltc3589_isr,
-					IRQF_TRIGGER_LOW | IRQF_ONESHOT,
-					client->name, ltc3589);
-	if (ret) {
-		dev_err(dev, "Failed to request IRQ: %d\n", ret);
-		return ret;
+	if (client->irq != 0) {
+		ret = devm_request_threaded_irq(dev, client->irq, NULL, ltc3589_isr,
+						IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+						client->name, ltc3589);
+		if (ret) {
+			dev_err(dev, "Failed to request IRQ %d: %d\n", client->irq, ret);
+			return ret;
+		}
 	}
 
 	return 0;
Signature · 1 line
2.7.1
Acked-by on v1 1/1
#1 lore raw

Am Dienstag, den 09.02.2016, 21:14 +0100 schrieb Bernhard Walle:

Quoted 6 lines

It's perfectly valid to use the LTC3589 without an interrupt pin connected to it. Currently, the driver probing fails when client->irq is 0 (which means "no interrupt"). Don't register the interrupt handler in that case but successfully finish the device probing instead.

I suggest these small changes:

[...]

drivers/regulator/ltc3589.c static int ltc3589_probe(struct i2c_client *client, · line 523

Quoted 11 lines
drivers/regulator/ltc3589.c +1 -6
@@ -520,12 +520,14 @@ static int ltc3589_probe(struct i2c_client *client,
 		}
 	}
 
-	ret = devm_request_threaded_irq(dev, client->irq, NULL, ltc3589_isr,
-					IRQF_TRIGGER_LOW | IRQF_ONESHOT,
-					client->name, ltc3589);
-	if (ret) {
-		dev_err(dev, "Failed to request IRQ: %d\n", ret);
-		return ret;
+	if (client->irq != 0) {

How about using

	if (client->irq) {

here ...

drivers/regulator/ltc3589.c static int ltc3589_probe(struct i2c_client *client, · line 524

Quoted 1 line
drivers/regulator/ltc3589.c +1 -0
+		ret = devm_request_threaded_irq(dev, client->irq, NULL, ltc3589_isr,

... and reflowing this ...

drivers/regulator/ltc3589.c static int ltc3589_probe(struct i2c_client *client, · line 528

Quoted 4 lines
drivers/regulator/ltc3589.c +4 -0
+						IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+						client->name, ltc3589);
+		if (ret) {
+			dev_err(dev, "Failed to request IRQ %d: %d\n", client->irq, ret);

... and this long line.

regards
Philipp

#2 lore raw

Hi,

thanks for the review!

Am 10.02.2016 10:44, schrieb Philipp Zabel:

Quoted 7 lines

drivers/regulator/ltc3589.c static int ltc3589_probe(struct i2c_client *client, · line 528

Quoted 5 lines
drivers/regulator/ltc3589.c +4 -0
+						IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+						client->name, ltc3589);
+		if (ret) {
+			dev_err(dev, "Failed to request IRQ %d: %d\n", client->irq, ret);

... and this long line.

This was actually a mistake because I added the IRQ number to debug my problem.

Will send an updated version of the patch just now.

Regards,
Bernhard