Commit ebe8733e authored by Liam Breck's avatar Liam Breck Committed by Ben Hutchings

power: supply: bq24190_charger: Install irq_handler_thread() at end of probe()

commit d62acc5e upstream.

The device specific data is not fully initialized on
request_threaded_irq(). This may cause a crash when the IRQ handler
tries to reference them.

Fix the issue by installing IRQ handler at the end of the probe.

Fixes: d7bf353f ("bq24190_charger: Add support for TI BQ24190 Battery Charger")
Signed-off-by: default avatarLiam Breck <kernel@networkimprov.net>
Acked-by: default avatarMark Greer <mgreer@animalcreek.com>
Acked-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
[bwh: Backported to 3.16: adjust filename, context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent cddddea5
...@@ -1398,22 +1398,13 @@ static int bq24190_probe(struct i2c_client *client, ...@@ -1398,22 +1398,13 @@ static int bq24190_probe(struct i2c_client *client,
return -EINVAL; return -EINVAL;
} }
ret = devm_request_threaded_irq(dev, bdi->irq, NULL,
bq24190_irq_handler_thread,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
"bq24190-charger", bdi);
if (ret < 0) {
dev_err(dev, "Can't set up irq handler\n");
goto out1;
}
pm_runtime_enable(dev); pm_runtime_enable(dev);
pm_runtime_resume(dev); pm_runtime_resume(dev);
ret = bq24190_hw_init(bdi); ret = bq24190_hw_init(bdi);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "Hardware init failed\n"); dev_err(dev, "Hardware init failed\n");
goto out2; goto out1;
} }
bq24190_charger_init(&bdi->charger); bq24190_charger_init(&bdi->charger);
...@@ -1421,7 +1412,7 @@ static int bq24190_probe(struct i2c_client *client, ...@@ -1421,7 +1412,7 @@ static int bq24190_probe(struct i2c_client *client,
ret = power_supply_register(dev, &bdi->charger); ret = power_supply_register(dev, &bdi->charger);
if (ret) { if (ret) {
dev_err(dev, "Can't register charger\n"); dev_err(dev, "Can't register charger\n");
goto out2; goto out1;
} }
bq24190_battery_init(&bdi->battery); bq24190_battery_init(&bdi->battery);
...@@ -1429,24 +1420,34 @@ static int bq24190_probe(struct i2c_client *client, ...@@ -1429,24 +1420,34 @@ static int bq24190_probe(struct i2c_client *client,
ret = power_supply_register(dev, &bdi->battery); ret = power_supply_register(dev, &bdi->battery);
if (ret) { if (ret) {
dev_err(dev, "Can't register battery\n"); dev_err(dev, "Can't register battery\n");
goto out3; goto out2;
} }
ret = bq24190_sysfs_create_group(bdi); ret = bq24190_sysfs_create_group(bdi);
if (ret) { if (ret) {
dev_err(dev, "Can't create sysfs entries\n"); dev_err(dev, "Can't create sysfs entries\n");
goto out3;
}
ret = devm_request_threaded_irq(dev, bdi->irq, NULL,
bq24190_irq_handler_thread,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
"bq24190-charger", bdi);
if (ret < 0) {
dev_err(dev, "Can't set up irq handler\n");
goto out4; goto out4;
} }
return 0; return 0;
out4: out4:
power_supply_unregister(&bdi->battery); bq24190_sysfs_remove_group(bdi);
out3: out3:
power_supply_unregister(&bdi->charger); power_supply_unregister(&bdi->battery);
out2: out2:
pm_runtime_disable(dev); power_supply_unregister(&bdi->charger);
out1: out1:
pm_runtime_disable(dev);
if (bdi->gpio_int) if (bdi->gpio_int)
gpio_free(bdi->gpio_int); gpio_free(bdi->gpio_int);
......
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