diff options
author | Ramakrishna Pallala <ramakrishna.pallala@intel.com> | 2012-05-05 03:08:37 +0530 |
---|---|---|
committer | Anton Vorontsov <anton.vorontsov@linaro.org> | 2012-05-04 23:42:56 -0700 |
commit | 243e3527ffbda96434429e618324f80ca0d98902 (patch) | |
tree | 2605526fe5555735bbf9e3009b671064a4b38fdc /drivers/power/max17042_battery.c | |
parent | 0d4ed4e27a4cb180af395fa3d7aa98d79f3d3015 (diff) |
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: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Diffstat (limited to 'drivers/power/max17042_battery.c')
-rw-r--r-- | 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 42c4be9a664..b4c8af01627 100644 --- a/drivers/power/max17042_battery.c +++ b/drivers/power/max17042_battery.c @@ -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, @@ -706,7 +712,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); @@ -714,10 +719,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) |