power_supply: Register cooling device outside of probe
Registering the cooling device from the probe, can result in the execution of get_property() function, before the probe is complete. To avoid this, register the cooling device from a workqueue, instead of registering in the probe. Change-Id: Ic9279fd5ca5476df66baa6e0f302a7f3bd6b899b Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
This commit is contained in:
parent
8eabe1219d
commit
1a4e929c60
1 changed files with 4 additions and 6 deletions
|
@ -126,6 +126,7 @@ void power_supply_changed(struct power_supply *psy)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(power_supply_changed);
|
||||
|
||||
static int psy_register_cooler(struct device *dev, struct power_supply *psy);
|
||||
/*
|
||||
* Notify that power supply was registered after parent finished the probing.
|
||||
*
|
||||
|
@ -133,6 +134,8 @@ EXPORT_SYMBOL_GPL(power_supply_changed);
|
|||
* calling power_supply_changed() directly from power_supply_register()
|
||||
* would lead to execution of get_property() function provided by the driver
|
||||
* too early - before the probe ends.
|
||||
* Also, registering cooling device from the probe will execute the
|
||||
* get_property() function. So register the cooling device after the probe.
|
||||
*
|
||||
* Avoid that by waiting on parent's mutex.
|
||||
*/
|
||||
|
@ -149,6 +152,7 @@ static void power_supply_deferred_register_work(struct work_struct *work)
|
|||
}
|
||||
}
|
||||
|
||||
psy_register_cooler(psy->dev.parent, psy);
|
||||
power_supply_changed(psy);
|
||||
|
||||
if (psy->dev.parent)
|
||||
|
@ -920,10 +924,6 @@ __power_supply_register(struct device *parent,
|
|||
if (rc)
|
||||
goto register_thermal_failed;
|
||||
|
||||
rc = psy_register_cooler(parent, psy);
|
||||
if (rc)
|
||||
goto register_cooler_failed;
|
||||
|
||||
rc = power_supply_create_triggers(psy);
|
||||
if (rc)
|
||||
goto create_triggers_failed;
|
||||
|
@ -947,8 +947,6 @@ __power_supply_register(struct device *parent,
|
|||
return psy;
|
||||
|
||||
create_triggers_failed:
|
||||
psy_unregister_cooler(psy);
|
||||
register_cooler_failed:
|
||||
psy_unregister_thermal(psy);
|
||||
register_thermal_failed:
|
||||
device_del(dev);
|
||||
|
|
Loading…
Reference in a new issue