Linux Power Management development
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Ricardo Neri <ricardo.neri-calderon@linux.intel.com>,
	Linux PM <linux-pm@vger.kernel.org>
Subject: Re: [PATCH v1 1/3] PM: EM: Consify two parameters of em_dev_register_perf_domain()
Date: Thu, 6 Mar 2025 09:22:43 +0000	[thread overview]
Message-ID: <9a9bdf37-1462-4aca-b513-268b4f2b235c@arm.com> (raw)
In-Reply-To: <4648962.LvFx2qVVIh@rjwysocki.net>



On 3/5/25 21:08, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> 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>
> ---
>   include/linux/energy_model.h |    8 ++++----
>   kernel/power/energy_model.c  |   11 ++++++-----
>   2 files changed, 10 insertions(+), 9 deletions(-)
> 
> --- a/include/linux/energy_model.h
> +++ b/include/linux/energy_model.h
> @@ -169,8 +169,8 @@
>   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 @@
>   
>   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;
>   }
> --- a/kernel/power/energy_model.c
> +++ b/kernel/power/energy_model.c
> @@ -231,7 +231,7 @@
>   }
>   
>   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 @@
>   
>   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_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 @@
>    * 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;
> 
> 
> 

LGTM,

Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>

  reply	other threads:[~2025-03-06  9:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05 21:06 [PATCH v1 0/3] PM: EM: API cleanups and elimination of __rcu-related sparse warnings Rafael J. Wysocki
2025-03-05 21:08 ` [PATCH v1 1/3] PM: EM: Consify two parameters of em_dev_register_perf_domain() Rafael J. Wysocki
2025-03-06  9:22   ` Lukasz Luba [this message]
2025-03-05 21:11 ` [PATCH v1 2/3] PM: EM: Make three functions static Rafael J. Wysocki
2025-03-06 10:01   ` Lukasz Luba
2025-03-06 10:37     ` Rafael J. Wysocki
2025-03-05 21:13 ` [PATCH v1 3/3] PM: EM: Address RCU-related sparse warnings Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a9bdf37-1462-4aca-b513-268b4f2b235c@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=ricardo.neri-calderon@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox