Commit 243e3527 authored by Ramakrishna Pallala's avatar Ramakrishna Pallala Committed by Anton Vorontsov

max17042_battery: Fix power supply and irq registration ordering

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: default avatarRamakrishna Pallala <ramakrishna.pallala@intel.com>
Signed-off-by: default avatarAnton Vorontsov <anton.vorontsov@linaro.org>
parent 0d4ed4e2
...@@ -690,6 +690,12 @@ static int __devinit max17042_probe(struct i2c_client *client, ...@@ -690,6 +690,12 @@ static int __devinit max17042_probe(struct i2c_client *client,
max17042_write_reg(client, MAX17042_LearnCFG, 0x0007); 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) { if (client->irq) {
ret = request_threaded_irq(client->irq, NULL, ret = request_threaded_irq(client->irq, NULL,
max17042_thread_handler, max17042_thread_handler,
...@@ -706,7 +712,6 @@ static int __devinit max17042_probe(struct i2c_client *client, ...@@ -706,7 +712,6 @@ static int __devinit max17042_probe(struct i2c_client *client,
} }
reg = max17042_read_reg(chip->client, MAX17042_STATUS); reg = max17042_read_reg(chip->client, MAX17042_STATUS);
if (reg & STATUS_POR_BIT) { if (reg & STATUS_POR_BIT) {
INIT_WORK(&chip->work, max17042_init_worker); INIT_WORK(&chip->work, max17042_init_worker);
schedule_work(&chip->work); schedule_work(&chip->work);
...@@ -714,10 +719,7 @@ static int __devinit max17042_probe(struct i2c_client *client, ...@@ -714,10 +719,7 @@ static int __devinit max17042_probe(struct i2c_client *client,
chip->init_complete = 1; chip->init_complete = 1;
} }
ret = power_supply_register(&client->dev, &chip->battery); return 0;
if (ret)
dev_err(&client->dev, "failed: power supply register\n");
return ret;
} }
static int __devexit max17042_remove(struct i2c_client *client) static int __devexit max17042_remove(struct i2c_client *client)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment