From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: daniel.lezcano@linaro.org, rui.zhang@intel.com
Cc: amitk@kernel.org, linux-pm@vger.kernel.org,
Amit Daniel Kachhap <amit.kachhap@gmail.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
Javi Merino <javi.merino@kernel.org>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 3/3] thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering
Date: Wed, 10 Mar 2021 12:46:00 +0100 [thread overview]
Message-ID: <20210310114600.27178-3-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <20210310114600.27178-1-daniel.lezcano@linaro.org>
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: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/thermal/cpuidle_cooling.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/thermal/cpuidle_cooling.c b/drivers/thermal/cpuidle_cooling.c
index 7ecab4b16b29..8bc0a9b46358 100644
--- a/drivers/thermal/cpuidle_cooling.c
+++ b/drivers/thermal/cpuidle_cooling.c
@@ -9,6 +9,7 @@
#include <linux/cpu_cooling.h>
#include <linux/cpuidle.h>
+#include <linux/device.h>
#include <linux/err.h>
#include <linux/idle_inject.h>
#include <linux/idr.h>
@@ -26,8 +27,6 @@ struct cpuidle_cooling_device {
unsigned long state;
};
-static DEFINE_IDA(cpuidle_ida);
-
/**
* cpuidle_cooling_runtime - Running time computation
* @idle_duration_us: CPU idle time to inject in microseconds
@@ -174,10 +173,11 @@ static int __cpuidle_cooling_register(struct device_node *np,
struct idle_inject_device *ii_dev;
struct cpuidle_cooling_device *idle_cdev;
struct thermal_cooling_device *cdev;
+ struct device *dev;
unsigned int idle_duration_us = TICK_USEC;
unsigned int latency_us = UINT_MAX;
- char dev_name[THERMAL_NAME_LENGTH];
- int id, ret;
+ char name[THERMAL_NAME_LENGTH];
+ int ret;
idle_cdev = kzalloc(sizeof(*idle_cdev), GFP_KERNEL);
if (!idle_cdev) {
@@ -185,16 +185,10 @@ static int __cpuidle_cooling_register(struct device_node *np,
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);
if (!ii_dev) {
ret = -EINVAL;
- goto out_id;
+ goto out_kfree;
}
of_property_read_u32(np, "duration-us", &idle_duration_us);
@@ -205,9 +199,11 @@ static int __cpuidle_cooling_register(struct device_node *np,
idle_cdev->ii_dev = ii_dev;
- snprintf(dev_name, sizeof(dev_name), "thermal-idle-%d", id);
+ dev = get_cpu_device(cpumask_first(drv->cpumask));
+
+ snprintf(name, sizeof(name), "idle-%s", dev_name(dev));
- cdev = thermal_of_cooling_device_register(np, dev_name, idle_cdev,
+ cdev = thermal_of_cooling_device_register(np, name, idle_cdev,
&cpuidle_cooling_ops);
if (IS_ERR(cdev)) {
ret = PTR_ERR(cdev);
@@ -215,14 +211,12 @@ static int __cpuidle_cooling_register(struct device_node *np,
}
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;
out_unregister:
idle_inject_unregister(ii_dev);
-out_id:
- ida_simple_remove(&cpuidle_ida, id);
out_kfree:
kfree(idle_cdev);
out:
--
2.17.1
next prev parent reply other threads:[~2021-03-10 11:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-10 11:45 [PATCH 1/3] thermal/drivers/cpufreq_cooling: " Daniel Lezcano
2021-03-10 11:45 ` [PATCH 2/3] thermal/drivers/devfreq_cooling: " Daniel Lezcano
2021-03-12 11:15 ` Lukasz Luba
2021-03-12 15:53 ` Daniel Lezcano
2021-03-10 11:46 ` Daniel Lezcano [this message]
2021-03-12 11:34 ` [PATCH 3/3] thermal/drivers/cpuidle_cooling: " Lukasz Luba
2021-03-12 5:10 ` [PATCH 1/3] thermal/drivers/cpufreq_cooling: " Viresh Kumar
2021-03-12 10:58 ` Lukasz Luba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210310114600.27178-3-daniel.lezcano@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=amit.kachhap@gmail.com \
--cc=amitk@kernel.org \
--cc=javi.merino@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rui.zhang@intel.com \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®