Skip to content

Commit 75a3a99

Browse files
lukaszluba-armrafaeljw
authored andcommitted
PM: EM: Change the order of arguments in the .active_power() callback
The .active_power() callback passes the device pointer when it's called. Aligned with a convetion present in other subsystems and pass the 'dev' as a first argument. It looks more cleaner. Adjust all affected drivers which implement that API callback. Suggested-by: Ionela Voinescu <ionela.voinescu@arm.com> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Reviewed-by: Ionela Voinescu <ionela.voinescu@arm.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 9136246 commit 75a3a99

6 files changed

Lines changed: 13 additions & 13 deletions

File tree

Documentation/power/energy-model.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ EM framework::
181181

182182
-> drivers/cpufreq/foo_cpufreq.c
183183

184-
01 static int est_power(unsigned long *mW, unsigned long *KHz,
185-
02 struct device *dev)
184+
01 static int est_power(struct device *dev, unsigned long *mW,
185+
02 unsigned long *KHz)
186186
03 {
187187
04 long freq, power;
188188
05

drivers/cpufreq/mediatek-cpufreq-hw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ static const u16 cpufreq_mtk_offsets[REG_ARRAY_SIZE] = {
5151
};
5252

5353
static int __maybe_unused
54-
mtk_cpufreq_get_cpu_power(unsigned long *mW,
55-
unsigned long *KHz, struct device *cpu_dev)
54+
mtk_cpufreq_get_cpu_power(struct device *cpu_dev, unsigned long *mW,
55+
unsigned long *KHz)
5656
{
5757
struct mtk_cpufreq_data *data;
5858
struct cpufreq_policy *policy;

drivers/cpufreq/scmi-cpufreq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ scmi_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask)
9696
}
9797

9898
static int __maybe_unused
99-
scmi_get_cpu_power(unsigned long *power, unsigned long *KHz,
100-
struct device *cpu_dev)
99+
scmi_get_cpu_power(struct device *cpu_dev, unsigned long *power,
100+
unsigned long *KHz)
101101
{
102102
unsigned long Hz;
103103
int ret, domain;

drivers/opp/of.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_of_node);
14481448
* Returns 0 on success or a proper -EINVAL value in case of error.
14491449
*/
14501450
static int __maybe_unused
1451-
_get_dt_power(unsigned long *mW, unsigned long *kHz, struct device *dev)
1451+
_get_dt_power(struct device *dev, unsigned long *mW, unsigned long *kHz)
14521452
{
14531453
struct dev_pm_opp *opp;
14541454
unsigned long opp_freq, opp_power;
@@ -1482,8 +1482,8 @@ _get_dt_power(unsigned long *mW, unsigned long *kHz, struct device *dev)
14821482
* Returns -EINVAL if the power calculation failed because of missing
14831483
* parameters, 0 otherwise.
14841484
*/
1485-
static int __maybe_unused _get_power(unsigned long *mW, unsigned long *kHz,
1486-
struct device *dev)
1485+
static int __maybe_unused _get_power(struct device *dev, unsigned long *mW,
1486+
unsigned long *kHz)
14871487
{
14881488
struct dev_pm_opp *opp;
14891489
struct device_node *np;

include/linux/energy_model.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ struct em_data_callback {
101101
/**
102102
* active_power() - Provide power at the next performance state of
103103
* a device
104+
* @dev : Device for which we do this operation (can be a CPU)
104105
* @power : Active power at the performance state
105106
* (modified)
106107
* @freq : Frequency at the performance state in kHz
107108
* (modified)
108-
* @dev : Device for which we do this operation (can be a CPU)
109109
*
110110
* active_power() must find the lowest performance state of 'dev' above
111111
* 'freq' and update 'power' and 'freq' to the matching active power
@@ -117,8 +117,8 @@ struct em_data_callback {
117117
*
118118
* Return 0 on success.
119119
*/
120-
int (*active_power)(unsigned long *power, unsigned long *freq,
121-
struct device *dev);
120+
int (*active_power)(struct device *dev, unsigned long *power,
121+
unsigned long *freq);
122122

123123
/**
124124
* get_cost() - Provide the cost at the given performance state of

kernel/power/energy_model.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd,
140140
* lowest performance state of 'dev' above 'freq' and updates
141141
* 'power' and 'freq' accordingly.
142142
*/
143-
ret = cb->active_power(&power, &freq, dev);
143+
ret = cb->active_power(dev, &power, &freq);
144144
if (ret) {
145145
dev_err(dev, "EM: invalid perf. state: %d\n",
146146
ret);

0 commit comments

Comments
 (0)