]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PM: EM: Consify two parameters of em_dev_register_perf_domain()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 5 Mar 2025 21:08:21 +0000 (22:08 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 6 Mar 2025 20:23:29 +0000 (21:23 +0100)
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 <rafael.j.wysocki@intel.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/4648962.LvFx2qVVIh@rjwysocki.net
include/linux/energy_model.h
kernel/power/energy_model.c

index 78318d49276dc049bcd79e381b61d3aade49b648..b23c8c798dac2181499be02647a65af054c68d42 100644 (file)
@@ -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);
@@ -346,8 +346,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;
 }
index 16f6dcafdb904330d34ac78b0a4d27dccc69b9ba..1e3caa96c2718742f8ac0ad62416ae4749322622 100644 (file)
@@ -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;
@@ -333,7 +333,7 @@ EXPORT_SYMBOL_GPL(em_dev_update_perf_domain);
 
 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;
@@ -388,7 +388,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;
@@ -548,8 +549,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;