Commit 6fd1b186 authored by Daniel Lezcano's avatar Daniel Lezcano

thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering

Currently the naming of a cooling device is just a cooling technique
followed by a number. When there are multiple cooling devices using
the same technique, it is impossible to clearly identify the related
device as this one is just a number.

For instance:

 thermal-idle-0
 thermal-idle-1
 thermal-idle-2
 thermal-idle-3
 etc ...

The 'thermal' prefix is redundant with the subsystem namespace. This
patch removes the 'thermal prefix and changes the number by the device
name. So the naming above becomes:

 idle-cpu0
 idle-cpu1
 idle-cpu2
 idle-cpu3
 etc ...
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: default avatarLukasz Luba <lukasz.luba@arm.com>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/20210314111333.16551-4-daniel.lezcano@linaro.org
parent f8d354e8
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#include <linux/cpu_cooling.h> #include <linux/cpu_cooling.h>
#include <linux/cpuidle.h> #include <linux/cpuidle.h>
#include <linux/device.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/idle_inject.h> #include <linux/idle_inject.h>
#include <linux/idr.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/thermal.h> #include <linux/thermal.h>
...@@ -26,8 +26,6 @@ struct cpuidle_cooling_device { ...@@ -26,8 +26,6 @@ struct cpuidle_cooling_device {
unsigned long state; unsigned long state;
}; };
static DEFINE_IDA(cpuidle_ida);
/** /**
* cpuidle_cooling_runtime - Running time computation * cpuidle_cooling_runtime - Running time computation
* @idle_duration_us: CPU idle time to inject in microseconds * @idle_duration_us: CPU idle time to inject in microseconds
...@@ -174,10 +172,11 @@ static int __cpuidle_cooling_register(struct device_node *np, ...@@ -174,10 +172,11 @@ static int __cpuidle_cooling_register(struct device_node *np,
struct idle_inject_device *ii_dev; struct idle_inject_device *ii_dev;
struct cpuidle_cooling_device *idle_cdev; struct cpuidle_cooling_device *idle_cdev;
struct thermal_cooling_device *cdev; struct thermal_cooling_device *cdev;
struct device *dev;
unsigned int idle_duration_us = TICK_USEC; unsigned int idle_duration_us = TICK_USEC;
unsigned int latency_us = UINT_MAX; unsigned int latency_us = UINT_MAX;
char dev_name[THERMAL_NAME_LENGTH]; char *name;
int id, ret; int ret;
idle_cdev = kzalloc(sizeof(*idle_cdev), GFP_KERNEL); idle_cdev = kzalloc(sizeof(*idle_cdev), GFP_KERNEL);
if (!idle_cdev) { if (!idle_cdev) {
...@@ -185,16 +184,10 @@ static int __cpuidle_cooling_register(struct device_node *np, ...@@ -185,16 +184,10 @@ static int __cpuidle_cooling_register(struct device_node *np,
goto out; goto out;
} }
id = ida_simple_get(&cpuidle_ida, 0, 0, GFP_KERNEL);
if (id < 0) {
ret = id;
goto out_kfree;
}
ii_dev = idle_inject_register(drv->cpumask); ii_dev = idle_inject_register(drv->cpumask);
if (!ii_dev) { if (!ii_dev) {
ret = -EINVAL; ret = -EINVAL;
goto out_id; goto out_kfree;
} }
of_property_read_u32(np, "duration-us", &idle_duration_us); of_property_read_u32(np, "duration-us", &idle_duration_us);
...@@ -205,24 +198,30 @@ static int __cpuidle_cooling_register(struct device_node *np, ...@@ -205,24 +198,30 @@ static int __cpuidle_cooling_register(struct device_node *np,
idle_cdev->ii_dev = ii_dev; idle_cdev->ii_dev = ii_dev;
snprintf(dev_name, sizeof(dev_name), "thermal-idle-%d", id); dev = get_cpu_device(cpumask_first(drv->cpumask));
cdev = thermal_of_cooling_device_register(np, dev_name, idle_cdev, name = kasprintf(GFP_KERNEL, "idle-%s", dev_name(dev));
if (!name) {
ret = -ENOMEM;
goto out_unregister;
}
cdev = thermal_of_cooling_device_register(np, name, idle_cdev,
&cpuidle_cooling_ops); &cpuidle_cooling_ops);
kfree(name);
if (IS_ERR(cdev)) { if (IS_ERR(cdev)) {
ret = PTR_ERR(cdev); ret = PTR_ERR(cdev);
goto out_unregister; goto out_unregister;
} }
pr_debug("%s: Idle injection set with idle duration=%u, latency=%u\n", pr_debug("%s: Idle injection set with idle duration=%u, latency=%u\n",
dev_name, idle_duration_us, latency_us); name, idle_duration_us, latency_us);
return 0; return 0;
out_unregister: out_unregister:
idle_inject_unregister(ii_dev); idle_inject_unregister(ii_dev);
out_id:
ida_simple_remove(&cpuidle_ida, id);
out_kfree: out_kfree:
kfree(idle_cdev); kfree(idle_cdev);
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment