Commit 2e83a5c5 authored by Daniel Mack's avatar Daniel Mack Committed by Anton Vorontsov

ds2760_battery: delay power supply registration

This fixes a race condition I recently introduced with the PMOD feature
addition (cef437e3: "w1: ds2760_battery: add support for sleep mode
feature").

Postpone the call to power_supply_register() to fix it.
Signed-off-by: default avatarDaniel Mack <daniel@caiaq.de>
Cc: Szabolcs Gyurko <szabolcs.gyurko@tlt.hu>
Acked-by: default avatarMatt Reimer <mreimer@vpop.net>
Signed-off-by: default avatarAnton Vorontsov <cbouatmailru@gmail.com>
parent 4aed03ae
...@@ -381,12 +381,6 @@ static int ds2760_battery_probe(struct platform_device *pdev) ...@@ -381,12 +381,6 @@ static int ds2760_battery_probe(struct platform_device *pdev)
di->charge_status = POWER_SUPPLY_STATUS_UNKNOWN; di->charge_status = POWER_SUPPLY_STATUS_UNKNOWN;
retval = power_supply_register(&pdev->dev, &di->bat);
if (retval) {
dev_err(di->dev, "failed to register battery\n");
goto batt_failed;
}
/* enable sleep mode feature */ /* enable sleep mode feature */
ds2760_battery_read_status(di); ds2760_battery_read_status(di);
status = di->raw[DS2760_STATUS_REG]; status = di->raw[DS2760_STATUS_REG];
...@@ -397,6 +391,12 @@ static int ds2760_battery_probe(struct platform_device *pdev) ...@@ -397,6 +391,12 @@ static int ds2760_battery_probe(struct platform_device *pdev)
ds2760_battery_write_status(di, status); ds2760_battery_write_status(di, status);
retval = power_supply_register(&pdev->dev, &di->bat);
if (retval) {
dev_err(di->dev, "failed to register battery\n");
goto batt_failed;
}
INIT_DELAYED_WORK(&di->monitor_work, ds2760_battery_work); INIT_DELAYED_WORK(&di->monitor_work, ds2760_battery_work);
di->monitor_wqueue = create_singlethread_workqueue(dev_name(&pdev->dev)); di->monitor_wqueue = create_singlethread_workqueue(dev_name(&pdev->dev));
if (!di->monitor_wqueue) { if (!di->monitor_wqueue) {
......
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