Skip to content

Commit 4530d81

Browse files
rafaeljwgregkh
authored andcommitted
thermal: trip: Split thermal_zone_device_set_mode()
[ Upstream commit e5f9889 ] Pull a wrapper around thermal zone .change_mode() callback out of thermal_zone_device_set_mode() because it will be used elsewhere subsequently. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/2206793.irdbgypaU6@rjwysocki.net Stable-dep-of: f7c1b0e ("thermal: core: Back off when polling thermal zones on errors") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d5fe884 commit 4530d81

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

drivers/thermal/thermal_core.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,22 @@ static int __init thermal_register_governors(void)
272272
return ret;
273273
}
274274

275+
static int __thermal_zone_device_set_mode(struct thermal_zone_device *tz,
276+
enum thermal_device_mode mode)
277+
{
278+
if (tz->ops.change_mode) {
279+
int ret;
280+
281+
ret = tz->ops.change_mode(tz, mode);
282+
if (ret)
283+
return ret;
284+
}
285+
286+
tz->mode = mode;
287+
288+
return 0;
289+
}
290+
275291
/*
276292
* Zone update section: main control loop applied to each zone while monitoring
277293
* in polling mode. The monitoring is done using a workqueue.
@@ -537,22 +553,23 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
537553
static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
538554
enum thermal_device_mode mode)
539555
{
540-
int ret = 0;
556+
int ret;
541557

542558
mutex_lock(&tz->lock);
543559

544560
/* do nothing if mode isn't changing */
545561
if (mode == tz->mode) {
546562
mutex_unlock(&tz->lock);
547563

548-
return ret;
564+
return 0;
549565
}
550566

551-
if (tz->ops.change_mode)
552-
ret = tz->ops.change_mode(tz, mode);
567+
ret = __thermal_zone_device_set_mode(tz, mode);
568+
if (ret) {
569+
mutex_unlock(&tz->lock);
553570

554-
if (!ret)
555-
tz->mode = mode;
571+
return ret;
572+
}
556573

557574
__thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
558575

@@ -563,7 +580,7 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
563580
else
564581
thermal_notify_tz_disable(tz);
565582

566-
return ret;
583+
return 0;
567584
}
568585

569586
int thermal_zone_device_enable(struct thermal_zone_device *tz)

0 commit comments

Comments
 (0)