mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 14:41:39 +00:00
thermal/drivers/devfreq_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-devfreq-0 thermal-devfreq-1 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: devfreq-5000000.gpu devfreq-1d84000.ufshc etc ... Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Link: https://lore.kernel.org/r/20210314111333.16551-3-daniel.lezcano@linaro.org
This commit is contained in:
parent
ef37d1f9ac
commit
f8d354e821
@ -14,7 +14,6 @@
|
|||||||
#include <linux/devfreq_cooling.h>
|
#include <linux/devfreq_cooling.h>
|
||||||
#include <linux/energy_model.h>
|
#include <linux/energy_model.h>
|
||||||
#include <linux/export.h>
|
#include <linux/export.h>
|
||||||
#include <linux/idr.h>
|
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/pm_opp.h>
|
#include <linux/pm_opp.h>
|
||||||
#include <linux/pm_qos.h>
|
#include <linux/pm_qos.h>
|
||||||
@ -25,11 +24,8 @@
|
|||||||
#define HZ_PER_KHZ 1000
|
#define HZ_PER_KHZ 1000
|
||||||
#define SCALE_ERROR_MITIGATION 100
|
#define SCALE_ERROR_MITIGATION 100
|
||||||
|
|
||||||
static DEFINE_IDA(devfreq_ida);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct devfreq_cooling_device - Devfreq cooling device
|
* struct devfreq_cooling_device - Devfreq cooling device
|
||||||
* @id: unique integer value corresponding to each
|
|
||||||
* devfreq_cooling_device registered.
|
* devfreq_cooling_device registered.
|
||||||
* @cdev: Pointer to associated thermal cooling device.
|
* @cdev: Pointer to associated thermal cooling device.
|
||||||
* @devfreq: Pointer to associated devfreq device.
|
* @devfreq: Pointer to associated devfreq device.
|
||||||
@ -51,7 +47,6 @@ static DEFINE_IDA(devfreq_ida);
|
|||||||
* @em_pd: Energy Model for the associated Devfreq device
|
* @em_pd: Energy Model for the associated Devfreq device
|
||||||
*/
|
*/
|
||||||
struct devfreq_cooling_device {
|
struct devfreq_cooling_device {
|
||||||
int id;
|
|
||||||
struct thermal_cooling_device *cdev;
|
struct thermal_cooling_device *cdev;
|
||||||
struct devfreq *devfreq;
|
struct devfreq *devfreq;
|
||||||
unsigned long cooling_state;
|
unsigned long cooling_state;
|
||||||
@ -363,7 +358,7 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
|
|||||||
struct thermal_cooling_device *cdev;
|
struct thermal_cooling_device *cdev;
|
||||||
struct device *dev = df->dev.parent;
|
struct device *dev = df->dev.parent;
|
||||||
struct devfreq_cooling_device *dfc;
|
struct devfreq_cooling_device *dfc;
|
||||||
char dev_name[THERMAL_NAME_LENGTH];
|
char *name;
|
||||||
int err, num_opps;
|
int err, num_opps;
|
||||||
|
|
||||||
dfc = kzalloc(sizeof(*dfc), GFP_KERNEL);
|
dfc = kzalloc(sizeof(*dfc), GFP_KERNEL);
|
||||||
@ -407,30 +402,27 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
|
|||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto free_table;
|
goto free_table;
|
||||||
|
|
||||||
err = ida_simple_get(&devfreq_ida, 0, 0, GFP_KERNEL);
|
cdev = ERR_PTR(-ENOMEM);
|
||||||
if (err < 0)
|
name = kasprintf(GFP_KERNEL, "devfreq-%s", dev_name(dev));
|
||||||
|
if (!name)
|
||||||
goto remove_qos_req;
|
goto remove_qos_req;
|
||||||
|
|
||||||
dfc->id = err;
|
cdev = thermal_of_cooling_device_register(np, name, dfc,
|
||||||
|
|
||||||
snprintf(dev_name, sizeof(dev_name), "thermal-devfreq-%d", dfc->id);
|
|
||||||
|
|
||||||
cdev = thermal_of_cooling_device_register(np, dev_name, dfc,
|
|
||||||
&devfreq_cooling_ops);
|
&devfreq_cooling_ops);
|
||||||
|
kfree(name);
|
||||||
|
|
||||||
if (IS_ERR(cdev)) {
|
if (IS_ERR(cdev)) {
|
||||||
err = PTR_ERR(cdev);
|
err = PTR_ERR(cdev);
|
||||||
dev_err(dev,
|
dev_err(dev,
|
||||||
"Failed to register devfreq cooling device (%d)\n",
|
"Failed to register devfreq cooling device (%d)\n",
|
||||||
err);
|
err);
|
||||||
goto release_ida;
|
goto remove_qos_req;
|
||||||
}
|
}
|
||||||
|
|
||||||
dfc->cdev = cdev;
|
dfc->cdev = cdev;
|
||||||
|
|
||||||
return cdev;
|
return cdev;
|
||||||
|
|
||||||
release_ida:
|
|
||||||
ida_simple_remove(&devfreq_ida, dfc->id);
|
|
||||||
remove_qos_req:
|
remove_qos_req:
|
||||||
dev_pm_qos_remove_request(&dfc->req_max_freq);
|
dev_pm_qos_remove_request(&dfc->req_max_freq);
|
||||||
free_table:
|
free_table:
|
||||||
@ -527,7 +519,6 @@ void devfreq_cooling_unregister(struct thermal_cooling_device *cdev)
|
|||||||
dev = dfc->devfreq->dev.parent;
|
dev = dfc->devfreq->dev.parent;
|
||||||
|
|
||||||
thermal_cooling_device_unregister(dfc->cdev);
|
thermal_cooling_device_unregister(dfc->cdev);
|
||||||
ida_simple_remove(&devfreq_ida, dfc->id);
|
|
||||||
dev_pm_qos_remove_request(&dfc->req_max_freq);
|
dev_pm_qos_remove_request(&dfc->req_max_freq);
|
||||||
|
|
||||||
em_dev_unregister_perf_domain(dev);
|
em_dev_unregister_perf_domain(dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user