[PATCH RFC RESEND 2/8] thermal: core: Set parent device in thermal_of_cooling_device_register()
From: Armin Wolf <W_Armin@gmx.de>
Date: 2025-11-20 03:41:42
Also in:
ath11k, dri-devel, imx, linux-acpi, linux-arm-kernel, linux-doc, linux-pci, linux-pm, linux-renesas-soc, linux-tegra, linux-wireless, lkml, netdev, platform-driver-x86
Subsystem:
drm drivers, drm drivers for vivante gpu ip, the rest, thermal, thermal/cpu_cooling · Maintainers:
David Airlie, Simona Vetter, Lucas Stach, Linus Torvalds, Rafael J. Wysocki, Daniel Lezcano, Amit Daniel Kachhap, Viresh Kumar
Extend thermal_of_cooling_device_register() to allow users to specify the parent device of the cooling device to be created. Signed-off-by: Armin Wolf <W_Armin@gmx.de> --- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 4 ++-- drivers/thermal/cpufreq_cooling.c | 2 +- drivers/thermal/cpuidle_cooling.c | 2 +- drivers/thermal/devfreq_cooling.c | 2 +- drivers/thermal/tegra/soctherm.c | 5 ++--- drivers/thermal/thermal_core.c | 5 +++-- include/linux/thermal.h | 9 ++++----- 7 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index cf0d9049bcf1..f2c98e46a1c6 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c@@ -1778,8 +1778,8 @@ static int etnaviv_gpu_bind(struct device *dev, struct device *master, int ret; if (IS_ENABLED(CONFIG_DRM_ETNAVIV_THERMAL)) { - gpu->cooling = thermal_of_cooling_device_register(dev->of_node, - (char *)dev_name(dev), gpu, &cooling_ops); + gpu->cooling = thermal_of_cooling_device_register(dev, dev->of_node, dev_name(dev), + gpu, &cooling_ops); if (IS_ERR(gpu->cooling)) return PTR_ERR(gpu->cooling); }
diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c
index 6b7ab1814c12..af9250c44da7 100644
--- a/drivers/thermal/cpufreq_cooling.c
+++ b/drivers/thermal/cpufreq_cooling.c@@ -593,7 +593,7 @@ __cpufreq_cooling_register(struct device_node *np, if (!name) goto remove_qos_req; - cdev = thermal_of_cooling_device_register(np, name, cpufreq_cdev, + cdev = thermal_of_cooling_device_register(dev, np, name, cpufreq_cdev, cooling_ops); kfree(name);
diff --git a/drivers/thermal/cpuidle_cooling.c b/drivers/thermal/cpuidle_cooling.c
index f678c1281862..520c89a36d90 100644
--- a/drivers/thermal/cpuidle_cooling.c
+++ b/drivers/thermal/cpuidle_cooling.c@@ -207,7 +207,7 @@ static int __cpuidle_cooling_register(struct device_node *np, goto out_unregister; } - cdev = thermal_of_cooling_device_register(np, name, idle_cdev, + cdev = thermal_of_cooling_device_register(dev, np, name, idle_cdev, &cpuidle_cooling_ops); if (IS_ERR(cdev)) { ret = PTR_ERR(cdev);
diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c
index 8fd7cf1932cd..d91695ed0f26 100644
--- a/drivers/thermal/devfreq_cooling.c
+++ b/drivers/thermal/devfreq_cooling.c@@ -454,7 +454,7 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df, if (!name) goto remove_qos_req; - cdev = thermal_of_cooling_device_register(np, name, dfc, ops); + cdev = thermal_of_cooling_device_register(dev, np, name, dfc, ops); kfree(name); if (IS_ERR(cdev)) {
diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c
index 5d26b52beaba..4f43da123be4 100644
--- a/drivers/thermal/tegra/soctherm.c
+++ b/drivers/thermal/tegra/soctherm.c@@ -1700,9 +1700,8 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) stc->init = true; } else { - tcd = thermal_of_cooling_device_register(np_stcc, - (char *)name, ts, - &throt_cooling_ops); + tcd = thermal_of_cooling_device_register(dev, np_stcc, name, ts, + &throt_cooling_ops); if (IS_ERR_OR_NULL(tcd)) { dev_err(dev, "throttle-cfg: %s: failed to register cooling device\n",
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c8b720194b44..5d752e712cc0 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c@@ -1166,6 +1166,7 @@ EXPORT_SYMBOL_GPL(thermal_cooling_device_register); /** * thermal_of_cooling_device_register() - register an OF thermal cooling device + * @parent: parent device pointer. * @np: a pointer to a device tree node. * @type: the thermal cooling device type. * @devdata: device private data.
@@ -1180,11 +1181,11 @@ EXPORT_SYMBOL_GPL(thermal_cooling_device_register); * ERR_PTR. Caller must check return value with IS_ERR*() helpers. */ struct thermal_cooling_device * -thermal_of_cooling_device_register(struct device_node *np, +thermal_of_cooling_device_register(struct device *parent, struct device_node *np, const char *type, void *devdata, const struct thermal_cooling_device_ops *ops) { - return __thermal_cooling_device_register(NULL, np, type, devdata, ops); + return __thermal_cooling_device_register(parent, np, type, devdata, ops); } EXPORT_SYMBOL_GPL(thermal_of_cooling_device_register);
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 0b5ed6821080..fa53d12173ce 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h@@ -253,8 +253,8 @@ void thermal_zone_device_update(struct thermal_zone_device *, struct thermal_cooling_device *thermal_cooling_device_register(const char *, void *, const struct thermal_cooling_device_ops *); struct thermal_cooling_device * -thermal_of_cooling_device_register(struct device_node *np, const char *, void *, - const struct thermal_cooling_device_ops *); +thermal_of_cooling_device_register(struct device *parent, struct device_node *np, const char *type, + void *devdata, const struct thermal_cooling_device_ops *); struct thermal_cooling_device * devm_thermal_of_cooling_device_register(struct device *dev, struct device_node *np,
@@ -302,9 +302,8 @@ thermal_cooling_device_register(const char *type, void *devdata, const struct thermal_cooling_device_ops *ops) { return ERR_PTR(-ENODEV); } static inline struct thermal_cooling_device * -thermal_of_cooling_device_register(struct device_node *np, - const char *type, void *devdata, - const struct thermal_cooling_device_ops *ops) +thermal_of_cooling_device_register(struct device *parent, struct device_node *np, const char *type, + void *devdata, const struct thermal_cooling_device_ops *ops) { return ERR_PTR(-ENODEV); } static inline struct thermal_cooling_device * devm_thermal_of_cooling_device_register(struct device *dev,
--
2.39.5