Commit 06107359 authored by Georges Savoundararadj's avatar Georges Savoundararadj Committed by Sebastian Reichel

power: bq24257: Fix use of uninitialized pointer bq->charger

bq->charger is initialized in bq24257_power_supply_init.
Therefore, bq24257_power_supply_init should be called before the
registration of the IRQ handler bq24257_irq_handler_thread that calls
power_supply_changed(bq->charger).
Signed-off-by: default avatarGeorges Savoundararadj <savoundg@gmail.com>
Cc: Aurelien Chanot <chanot.a@gmail.com>
Cc: Andreas Dannenberg <dannenberg@ti.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Fixes: 2219a935 ("power_supply: Add TI BQ24257 charger driver")
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 9edeaada
...@@ -1068,6 +1068,12 @@ static int bq24257_probe(struct i2c_client *client, ...@@ -1068,6 +1068,12 @@ static int bq24257_probe(struct i2c_client *client,
return ret; return ret;
} }
ret = bq24257_power_supply_init(bq);
if (ret < 0) {
dev_err(dev, "Failed to register power supply\n");
return ret;
}
ret = devm_request_threaded_irq(dev, client->irq, NULL, ret = devm_request_threaded_irq(dev, client->irq, NULL,
bq24257_irq_handler_thread, bq24257_irq_handler_thread,
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_FALLING |
...@@ -1078,12 +1084,6 @@ static int bq24257_probe(struct i2c_client *client, ...@@ -1078,12 +1084,6 @@ static int bq24257_probe(struct i2c_client *client,
return ret; return ret;
} }
ret = bq24257_power_supply_init(bq);
if (ret < 0) {
dev_err(dev, "Failed to register power supply\n");
return ret;
}
ret = sysfs_create_group(&bq->charger->dev.kobj, &bq24257_attr_group); ret = sysfs_create_group(&bq->charger->dev.kobj, &bq24257_attr_group);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "Can't create sysfs entries\n"); dev_err(dev, "Can't create sysfs entries\n");
......
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