From 3479214899184bdd15c6d14c12a1b20da3e31f9c Mon Sep 17 00:00:00 2001 From: David Arcari Date: Thu, 4 Sep 2025 08:30:41 -0400 Subject: [PATCH] PM: EM: Consify two parameters of em_dev_register_perf_domain() JIRA: https://issues.redhat.com/browse/RHEL-112493 commit 860a731f52f83309c213b943bac8f4ea70a88805 Author: Rafael J. Wysocki Date: Wed Mar 5 22:08:21 2025 +0100 PM: EM: Consify two parameters of em_dev_register_perf_domain() Notice that em_dev_register_perf_domain() and the functions called by it do not update objects pointed to by its cb and cpus parameters, so the const modifier can be added to them. This allows the return value of cpumask_of() or a pointer to a struct em_data_callback declared as const to be passed to em_dev_register_perf_domain() directly without explicit type casting which is rather handy. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Lukasz Luba Link: https://patch.msgid.link/4648962.LvFx2qVVIh@rjwysocki.net Signed-off-by: David Arcari --- include/linux/energy_model.h | 8 ++++---- kernel/power/energy_model.c | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index 4e2d2ecb401f..3c9295635c3f 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -169,8 +169,8 @@ struct em_perf_domain *em_pd_get(struct device *dev); int em_dev_update_perf_domain(struct device *dev, struct em_perf_table __rcu *new_table); int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, - struct em_data_callback *cb, cpumask_t *span, - bool microwatts); + const struct em_data_callback *cb, + const cpumask_t *cpus, bool microwatts); void em_dev_unregister_perf_domain(struct device *dev); struct em_perf_table __rcu *em_table_alloc(struct em_perf_domain *pd); void em_table_free(struct em_perf_table __rcu *table); @@ -345,8 +345,8 @@ struct em_data_callback {}; static inline int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, - struct em_data_callback *cb, cpumask_t *span, - bool microwatts) + const struct em_data_callback *cb, + const cpumask_t *cpus, bool microwatts) { return -EINVAL; } diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c index 11e7831b4ad4..b1537ba4c9fd 100644 --- a/kernel/power/energy_model.c +++ b/kernel/power/energy_model.c @@ -231,7 +231,7 @@ static void em_init_performance(struct device *dev, struct em_perf_domain *pd, } static int em_compute_costs(struct device *dev, struct em_perf_state *table, - struct em_data_callback *cb, int nr_states, + const struct em_data_callback *cb, int nr_states, unsigned long flags) { unsigned long prev_cost = ULONG_MAX; @@ -400,7 +400,7 @@ void em_rebuild_sched_domains(void) static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd, struct em_perf_state *table, - struct em_data_callback *cb, + const struct em_data_callback *cb, unsigned long flags) { unsigned long power, freq, prev_freq = 0; @@ -455,7 +455,8 @@ static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd, } static int em_create_pd(struct device *dev, int nr_states, - struct em_data_callback *cb, cpumask_t *cpus, + const struct em_data_callback *cb, + const cpumask_t *cpus, unsigned long flags) { struct em_perf_table __rcu *em_table; @@ -615,8 +616,8 @@ EXPORT_SYMBOL_GPL(em_cpu_get); * Return 0 on success */ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, - struct em_data_callback *cb, cpumask_t *cpus, - bool microwatts) + const struct em_data_callback *cb, + const cpumask_t *cpus, bool microwatts) { unsigned long cap, prev_cap = 0; unsigned long flags = 0;