Skip to content

Commit a69d82b

Browse files
krzksre
authored andcommitted
power_supply: Add no_thermal property to prevent recursive get_temp calls
Add a 'no_thermal' property to the power supply class. If true then thermal zone won't be created for this power supply in power_supply_register(). Power supply drivers may want to set it if they support POWER_SUPPLY_PROP_TEMP and they are forwarding this get property call to other thermal zone. If they won't set it lockdep may report false positive deadlock for thermal zone's mutex because of nested calls to thermal_zone_get_temp(). First is the call to thermal_zone_get_temp() of the driver's thermal zone. Thermal core gets POWER_SUPPLY_PROP_TEMP property from this driver. The driver then calls other thermal zone thermal_zone_get_temp() and returns result. Example of such driver is charger manager. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
1 parent 21e863b commit a69d82b

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎drivers/power/power_supply_core.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ static int psy_register_thermal(struct power_supply *psy)
417417
{
418418
int i;
419419

420+
if (psy->no_thermal)
421+
return 0;
422+
420423
/* Register battery zone device psy reports temperature */
421424
for (i = 0; i < psy->num_properties; i++) {
422425
if (psy->properties[i] == POWER_SUPPLY_PROP_TEMP) {

‎include/linux/power_supply.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ struct power_supply {
200200
void (*external_power_changed)(struct power_supply *psy);
201201
void (*set_charged)(struct power_supply *psy);
202202

203+
/*
204+
* Set if thermal zone should not be created for this power supply.
205+
* For example for virtual supplies forwarding calls to actual
206+
* sensors or other supplies.
207+
*/
208+
bool no_thermal;
203209
/* For APM emulation, think legacy userspace. */
204210
int use_for_apm;
205211

0 commit comments

Comments
 (0)