Skip to content

Commit c85c191

Browse files
akemnadesre
authored andcommitted
power: supply: remove faulty cooling logic
The rn5t618 power driver fails to register a cooling device because POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX is missing but availability is not checked before registering cooling device. After improved error checking in the thermal code, the registration of the power supply fails entirely. Checking for availability of _MAX before registering cooling device fixes the rn5t618 problem. But the whole logic feels questionable. First, the logic is inverted here: the code tells: max_current = max_cooling but 0 = max_cooling, so there needs to be some inversion in the code which cannot be found. Comparing with other cooling devices, it can be found that value for fan speed is not inverted, value for cpufreq cooling is inverted (similar situation as here lowest frequency = max cooling) Second, analyzing usage of _MAX: it is seems that maximum capabilities of charging controller are specified and not of the battery. Probably there is not too much mismatch in the drivers actually implementing that. So nothing has exploded yet. So there is no easy and safe way to specifify a max cooling value now. Conclusion for now (as a regression fix) just remove the cooling device registration and do it properly later on. Fixes: e49a1e1 ("thermal/core: fix error code in __thermal_cooling_device_register()") Fixes: 952aeeb ("power_supply: Register power supply for thermal cooling device") Signed-off-by: Andreas Kemnade <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent e633329 commit c85c191

File tree

1 file changed

+0
-93
lines changed

1 file changed

+0
-93
lines changed

drivers/power/supply/power_supply_core.c

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,83 +1186,6 @@ static void psy_unregister_thermal(struct power_supply *psy)
11861186
thermal_zone_device_unregister(psy->tzd);
11871187
}
11881188

1189-
/* thermal cooling device callbacks */
1190-
static int ps_get_max_charge_cntl_limit(struct thermal_cooling_device *tcd,
1191-
unsigned long *state)
1192-
{
1193-
struct power_supply *psy;
1194-
union power_supply_propval val;
1195-
int ret;
1196-
1197-
psy = tcd->devdata;
1198-
ret = power_supply_get_property(psy,
1199-
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, &val);
1200-
if (ret)
1201-
return ret;
1202-
1203-
*state = val.intval;
1204-
1205-
return ret;
1206-
}
1207-
1208-
static int ps_get_cur_charge_cntl_limit(struct thermal_cooling_device *tcd,
1209-
unsigned long *state)
1210-
{
1211-
struct power_supply *psy;
1212-
union power_supply_propval val;
1213-
int ret;
1214-
1215-
psy = tcd->devdata;
1216-
ret = power_supply_get_property(psy,
1217-
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val);
1218-
if (ret)
1219-
return ret;
1220-
1221-
*state = val.intval;
1222-
1223-
return ret;
1224-
}
1225-
1226-
static int ps_set_cur_charge_cntl_limit(struct thermal_cooling_device *tcd,
1227-
unsigned long state)
1228-
{
1229-
struct power_supply *psy;
1230-
union power_supply_propval val;
1231-
int ret;
1232-
1233-
psy = tcd->devdata;
1234-
val.intval = state;
1235-
ret = psy->desc->set_property(psy,
1236-
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val);
1237-
1238-
return ret;
1239-
}
1240-
1241-
static const struct thermal_cooling_device_ops psy_tcd_ops = {
1242-
.get_max_state = ps_get_max_charge_cntl_limit,
1243-
.get_cur_state = ps_get_cur_charge_cntl_limit,
1244-
.set_cur_state = ps_set_cur_charge_cntl_limit,
1245-
};
1246-
1247-
static int psy_register_cooler(struct power_supply *psy)
1248-
{
1249-
/* Register for cooling device if psy can control charging */
1250-
if (psy_has_property(psy->desc, POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT)) {
1251-
psy->tcd = thermal_cooling_device_register(
1252-
(char *)psy->desc->name,
1253-
psy, &psy_tcd_ops);
1254-
return PTR_ERR_OR_ZERO(psy->tcd);
1255-
}
1256-
1257-
return 0;
1258-
}
1259-
1260-
static void psy_unregister_cooler(struct power_supply *psy)
1261-
{
1262-
if (IS_ERR_OR_NULL(psy->tcd))
1263-
return;
1264-
thermal_cooling_device_unregister(psy->tcd);
1265-
}
12661189
#else
12671190
static int psy_register_thermal(struct power_supply *psy)
12681191
{
@@ -1272,15 +1195,6 @@ static int psy_register_thermal(struct power_supply *psy)
12721195
static void psy_unregister_thermal(struct power_supply *psy)
12731196
{
12741197
}
1275-
1276-
static int psy_register_cooler(struct power_supply *psy)
1277-
{
1278-
return 0;
1279-
}
1280-
1281-
static void psy_unregister_cooler(struct power_supply *psy)
1282-
{
1283-
}
12841198
#endif
12851199

12861200
static struct power_supply *__must_check
@@ -1354,10 +1268,6 @@ __power_supply_register(struct device *parent,
13541268
if (rc)
13551269
goto register_thermal_failed;
13561270

1357-
rc = psy_register_cooler(psy);
1358-
if (rc)
1359-
goto register_cooler_failed;
1360-
13611271
rc = power_supply_create_triggers(psy);
13621272
if (rc)
13631273
goto create_triggers_failed;
@@ -1387,8 +1297,6 @@ __power_supply_register(struct device *parent,
13871297
add_hwmon_sysfs_failed:
13881298
power_supply_remove_triggers(psy);
13891299
create_triggers_failed:
1390-
psy_unregister_cooler(psy);
1391-
register_cooler_failed:
13921300
psy_unregister_thermal(psy);
13931301
register_thermal_failed:
13941302
wakeup_init_failed:
@@ -1540,7 +1448,6 @@ void power_supply_unregister(struct power_supply *psy)
15401448
sysfs_remove_link(&psy->dev.kobj, "powers");
15411449
power_supply_remove_hwmon_sysfs(psy);
15421450
power_supply_remove_triggers(psy);
1543-
psy_unregister_cooler(psy);
15441451
psy_unregister_thermal(psy);
15451452
device_init_wakeup(&psy->dev, false);
15461453
device_unregister(&psy->dev);

0 commit comments

Comments
 (0)