All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] max17042_battery: Fix power supply and irq registration ordering
@ 2012-05-04 21:38 Ramakrishna Pallala
  2012-05-05  6:48 ` Anton Vorontsov
  0 siblings, 1 reply; 3+ messages in thread
From: Ramakrishna Pallala @ 2012-05-04 21:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: Anton Vorontsov, Ramakrishna Pallala

IRQ registration should happen only after power supply object usable.
This patch fixes the ordering of power supply and irq registration
calls.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
---
 drivers/power/max17042_battery.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
index 915767d..3c16724 100644
--- a/drivers/power/max17042_battery.c
+++ b/drivers/power/max17042_battery.c
@@ -691,6 +691,12 @@ static int __devinit max17042_probe(struct i2c_client *client,
 		max17042_write_reg(client, MAX17042_LearnCFG, 0x0007);
 	}
 
+	ret = power_supply_register(&client->dev, &chip->battery);
+	if (ret) {
+		dev_err(&client->dev, "failed: power supply register\n");
+		return ret;
+	}
+
 	if (client->irq) {
 		ret = request_threaded_irq(client->irq, NULL,
 						max17042_thread_handler,
@@ -707,7 +713,6 @@ static int __devinit max17042_probe(struct i2c_client *client,
 	}
 
 	reg = max17042_read_reg(chip->client, MAX17042_STATUS);
-
 	if (reg & STATUS_POR_BIT) {
 		INIT_WORK(&chip->work, max17042_init_worker);
 		schedule_work(&chip->work);
@@ -715,10 +720,7 @@ static int __devinit max17042_probe(struct i2c_client *client,
 		chip->init_complete = 1;
 	}
 
-	ret = power_supply_register(&client->dev, &chip->battery);
-	if (ret)
-		dev_err(&client->dev, "failed: power supply register\n");
-	return ret;
+	return 0;
 }
 
 static int __devexit max17042_remove(struct i2c_client *client)
-- 
1.7.0.4


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

* Re: [PATCH] max17042_battery: Fix power supply and irq registration ordering
  2012-05-04 21:38 [PATCH] max17042_battery: Fix power supply and irq registration ordering Ramakrishna Pallala
@ 2012-05-05  6:48 ` Anton Vorontsov
  2012-05-05  6:56   ` Pallala, Ramakrishna
  0 siblings, 1 reply; 3+ messages in thread
From: Anton Vorontsov @ 2012-05-05  6:48 UTC (permalink / raw)
  To: Ramakrishna Pallala; +Cc: linux-kernel

On Sat, May 05, 2012 at 03:08:37AM +0530, Ramakrishna Pallala wrote:
> IRQ registration should happen only after power supply object usable.
> This patch fixes the ordering of power supply and irq registration
> calls.
> 
> Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
> ---

Applied, thank you!

And I noticed another small issue: if request_threaded_irq() fails,
we continue with probing (which is OK), but since request failed,
during max17042_remove() and suspend/resume we would call IRQ
routines on a non-requested IRQ.

So, probably you'd want to set client->irq = 0 when request_irq
fails.

Thanks,

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

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

* RE: [PATCH] max17042_battery: Fix power supply and irq registration ordering
  2012-05-05  6:48 ` Anton Vorontsov
@ 2012-05-05  6:56   ` Pallala, Ramakrishna
  0 siblings, 0 replies; 3+ messages in thread
From: Pallala, Ramakrishna @ 2012-05-05  6:56 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linux-kernel@vger.kernel.org

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 886 bytes --]

> On Sat, May 05, 2012 at 03:08:37AM +0530, Ramakrishna Pallala wrote:
> > IRQ registration should happen only after power supply object usable.
> > This patch fixes the ordering of power supply and irq registration
> > calls.
> >
> > Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
> > ---
> 
> Applied, thank you!
> 
> And I noticed another small issue: if request_threaded_irq() fails, we continue with
> probing (which is OK), but since request failed, during max17042_remove() and
> suspend/resume we would call IRQ routines on a non-requested IRQ.
> 
> So, probably you'd want to set client->irq = 0 when request_irq fails.
> 

right, I should have checked this :(
I will submit the fix.

Thanks,
Ram
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

end of thread, other threads:[~2012-05-05  6:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-04 21:38 [PATCH] max17042_battery: Fix power supply and irq registration ordering Ramakrishna Pallala
2012-05-05  6:48 ` Anton Vorontsov
2012-05-05  6:56   ` Pallala, Ramakrishna

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.