Files
android/drivers/thermal/backward_compatible.c
threeeye bc1d038eac REVVL 6 Pro kernel bring-up: full working tree snapshot (2026-09-12)
Squashed backup commit (no shallow-clone history issues) of
xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2 branch, upstream
commit 9eece662e) plus all fixes applied to get everpal_defconfig building
clean against a modern (GCC 15.2.0) toolchain -- see the previous commit
message on the lineage-23.2 branch (also in this repo history is not
available here since this is a squashed snapshot; full incremental history
lives in the local DL380 checkout and the upstream GitHub remote).

Upstream: https://github.com/xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2)
2026-09-12 13:36:46 +00:00

80 lines
2.0 KiB
C

/*
* Copyright (C) 2015 MediaTek Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/thermal.h>
#include "thermal_core.h"
/**
* backward_compatible_throttle
* @tz - thermal_zone_device
*
* This function update the cooler state by monitoring the current
* temperature and trip points
*/
static int backward_compatible_throttle(struct thermal_zone_device *tz,
int trip)
{
int trip_temp;
struct thermal_instance *instance;
if (trip == THERMAL_TRIPS_NONE)
trip_temp = tz->forced_passive;
else
tz->ops->get_trip_temp(tz, trip, &trip_temp);
mutex_lock(&tz->lock);
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
if (instance->trip != trip)
continue;
if (tz->temperature >= trip_temp)
instance->target = 1;
else
instance->target = 0;
instance->cdev->updated = false;
thermal_cdev_update(instance->cdev);
}
mutex_unlock(&tz->lock);
return 0;
}
static struct thermal_governor thermal_gov_backward_compatible = {
.name = "backward_compatible",
.throttle = backward_compatible_throttle,
};
static int __init thermal_gov_backward_compatible_init(void)
{
return thermal_register_governor(&thermal_gov_backward_compatible);
}
static void __exit thermal_gov_backward_compatible_exit(void)
{
thermal_unregister_governor(&thermal_gov_backward_compatible);
}
/* This should load after thermal framework */
fs_initcall(thermal_gov_backward_compatible_init);
module_exit(thermal_gov_backward_compatible_exit);
MODULE_AUTHOR("Weiyi Lu");
MODULE_DESCRIPTION("A backward compatible Thermal governor");
MODULE_LICENSE("GPL");