Skip to content

Commit 860a731

Browse files
committed
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 <[email protected]> Reviewed-by: Lukasz Luba <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent a29ba00 commit 860a731

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

include/linux/energy_model.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ struct em_perf_domain *em_pd_get(struct device *dev);
169169
int em_dev_update_perf_domain(struct device *dev,
170170
struct em_perf_table __rcu *new_table);
171171
int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
172-
struct em_data_callback *cb, cpumask_t *span,
173-
bool microwatts);
172+
const struct em_data_callback *cb,
173+
const cpumask_t *cpus, bool microwatts);
174174
void em_dev_unregister_perf_domain(struct device *dev);
175175
struct em_perf_table __rcu *em_table_alloc(struct em_perf_domain *pd);
176176
void em_table_free(struct em_perf_table __rcu *table);
@@ -346,8 +346,8 @@ struct em_data_callback {};
346346

347347
static inline
348348
int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
349-
struct em_data_callback *cb, cpumask_t *span,
350-
bool microwatts)
349+
const struct em_data_callback *cb,
350+
const cpumask_t *cpus, bool microwatts)
351351
{
352352
return -EINVAL;
353353
}

kernel/power/energy_model.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static void em_init_performance(struct device *dev, struct em_perf_domain *pd,
231231
}
232232

233233
static int em_compute_costs(struct device *dev, struct em_perf_state *table,
234-
struct em_data_callback *cb, int nr_states,
234+
const struct em_data_callback *cb, int nr_states,
235235
unsigned long flags)
236236
{
237237
unsigned long prev_cost = ULONG_MAX;
@@ -333,7 +333,7 @@ EXPORT_SYMBOL_GPL(em_dev_update_perf_domain);
333333

334334
static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd,
335335
struct em_perf_state *table,
336-
struct em_data_callback *cb,
336+
const struct em_data_callback *cb,
337337
unsigned long flags)
338338
{
339339
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,
388388
}
389389

390390
static int em_create_pd(struct device *dev, int nr_states,
391-
struct em_data_callback *cb, cpumask_t *cpus,
391+
const struct em_data_callback *cb,
392+
const cpumask_t *cpus,
392393
unsigned long flags)
393394
{
394395
struct em_perf_table __rcu *em_table;
@@ -548,8 +549,8 @@ EXPORT_SYMBOL_GPL(em_cpu_get);
548549
* Return 0 on success
549550
*/
550551
int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
551-
struct em_data_callback *cb, cpumask_t *cpus,
552-
bool microwatts)
552+
const struct em_data_callback *cb,
553+
const cpumask_t *cpus, bool microwatts)
553554
{
554555
unsigned long cap, prev_cap = 0;
555556
unsigned long flags = 0;

0 commit comments

Comments
 (0)