Skip to content

Commit e5f9889

Browse files
committed
thermal: trip: Split thermal_zone_device_set_mode()
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 <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 539fbb9 commit e5f9889

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

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.
@@ -540,22 +556,23 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
540556
static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
541557
enum thermal_device_mode mode)
542558
{
543-
int ret = 0;
559+
int ret;
544560

545561
mutex_lock(&tz->lock);
546562

547563
/* do nothing if mode isn't changing */
548564
if (mode == tz->mode) {
549565
mutex_unlock(&tz->lock);
550566

551-
return ret;
567+
return 0;
552568
}
553569

554-
if (tz->ops.change_mode)
555-
ret = tz->ops.change_mode(tz, mode);
570+
ret = __thermal_zone_device_set_mode(tz, mode);
571+
if (ret) {
572+
mutex_unlock(&tz->lock);
556573

557-
if (!ret)
558-
tz->mode = mode;
574+
return ret;
575+
}
559576

560577
__thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
561578

@@ -566,7 +583,7 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
566583
else
567584
thermal_notify_tz_disable(tz);
568585

569-
return ret;
586+
return 0;
570587
}
571588

572589
int thermal_zone_device_enable(struct thermal_zone_device *tz)

0 commit comments

Comments
 (0)