[PATCH 3/4] power-supply: smb347-charger: move IRQ enabling to the end of probe

From: Mika Westerberg
Date: Mon Apr 16 2012 - 04:48:04 EST


There is a potential problem if we call smb347_irq_enable() from
smb347_irq_init() because smb347_irq_enable() makes the device registers
read-only once it returns and smb347_irq_init() expects them to still be
read-write. Currently no harm happens because it is the last call we make in
smb347_irq_init().

Anyway a better place for enabling IRQs is at the end of probe function and
this is also symmetric to call smb347_irq_disable() which is done at the
beginning of remove function.

Signed-off-by: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>
---
drivers/power/smb347-charger.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/power/smb347-charger.c b/drivers/power/smb347-charger.c
index d774fd3..781c058 100644
--- a/drivers/power/smb347-charger.c
+++ b/drivers/power/smb347-charger.c
@@ -923,10 +923,6 @@ static int smb347_irq_init(struct smb347_charger *smb)
if (ret < 0)
goto fail_readonly;

- ret = smb347_irq_enable(smb);
- if (ret < 0)
- goto fail_readonly;
-
smb347_set_writable(smb, false);
smb->client->irq = irq;
return 0;
@@ -1233,6 +1229,8 @@ static int smb347_probe(struct i2c_client *client,
if (ret < 0) {
dev_warn(dev, "failed to initialize IRQ: %d\n", ret);
dev_warn(dev, "disabling IRQ support\n");
+ } else {
+ smb347_irq_enable(smb);
}
}

--
1.7.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/