Skip to content

Commit

Permalink
max17042_battery: Fix power supply and irq registration ordering
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
  • Loading branch information
Ramakrishna Pallala authored and Anton Vorontsov committed May 5, 2012
1 parent 0d4ed4e commit 243e352
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/power/max17042_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,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,
Expand All @@ -706,18 +712,14 @@ 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);
} else {
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)
Expand Down

0 comments on commit 243e352

Please sign in to comment.