arm_scmi: Constify ops pointers in struct scmi_handle
Subsystems (2)
cover arm_scmi: Constify ops pointers in struct scmi_handle
A small patch series aiming to constify static scmi_*_ops structs in drivers/firmware/arm_scmi. Since these are not modified, constify them to allow the compiler to put them in read-only memory.
Rikard Falkeborn (3):
cpufreq: arm_scmi: Constify scmi_perf_ops pointers
firmware: arm_scmi: Constify ops pointers in scmi_handle
firmware: arm_scmi: Constify static scmi-ops
drivers/cpufreq/scmi-cpufreq.c | 6 +++--- drivers/firmware/arm_scmi/clock.c | 2 +- drivers/firmware/arm_scmi/common.h | 2 +- drivers/firmware/arm_scmi/mailbox.c | 2 +- drivers/firmware/arm_scmi/notify.c | 2 +- drivers/firmware/arm_scmi/perf.c | 2 +- drivers/firmware/arm_scmi/power.c | 2 +- drivers/firmware/arm_scmi/reset.c | 2 +- drivers/firmware/arm_scmi/sensors.c | 2 +- drivers/firmware/arm_scmi/smc.c | 2 +- include/linux/scmi_protocol.h | 12 ++++++------ 11 files changed, 18 insertions(+), 18 deletions(-)
Signature · 1 line
2.28.0
PATCH 1/3 cpufreq: arm_scmi: Constify scmi_perf_ops pointers
The perf_ops are not modified through this pointer. Make them const to indicate that. This is in preparation to make the scmi-ops pointers in scmi_handle const.
--- drivers/cpufreq/scmi-cpufreq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/cpufreq/scmi-cpufreq.c +3 -3
@@ -29,7 +29,7 @@ static const struct scmi_handle *handle;static unsigned int scmi_cpufreq_get_rate (unsigned int cpu) {struct cpufreq_policy *policy =cpufreq_cpu_get_raw (cpu); -struct scmi_perf_ops *perf_ops = handle->perf_ops; +const struct scmi_perf_ops *perf_ops = handle->perf_ops;struct scmi_data *priv = policy->driver_data;unsigned long rate;int ret;
@@ -50,7 +50,7 @@ scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) {int ret;struct scmi_data *priv = policy->driver_data; -struct scmi_perf_ops *perf_ops = handle->perf_ops; +const struct scmi_perf_ops *perf_ops = handle->perf_ops;u64 freq = policy->freq_table[index].frequency; ret = perf_ops->freq_set (handle, priv->domain_id, freq *1000 , false);
@@ -64,7 +64,7 @@ static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy, unsigned int target_freq) {struct scmi_data *priv = policy->driver_data; -struct scmi_perf_ops *perf_ops = handle->perf_ops; +const struct scmi_perf_ops *perf_ops = handle->perf_ops;if (!perf_ops->freq_set (handle, priv->domain_id, target_freq *1000 , true)) {
Signature · 1 line
2.28.0
Re: [PATCH 1/3] cpufreq: arm_scmi: Constify scmi_perf_ops pointers
Hi Viresh,
Quoted 4 lines · Rikard Falkeborn
The
perf_opsare not modified through this pointer. Make them const to indicate that. This is in preparation to make the scmi-ops pointers inscmi_handleconst.
Your ack needed to take this as series via {arm-,}soc
Signature · 2 lines
Regards, Sudeep
Viresh Kumar
maintainerRe: [PATCH 1/3] cpufreq: arm_scmi: Constify scmi_perf_ops pointers
Quoted 9 lines · Sudeep Holla
Hi Viresh,
Quoted 4 lines · Rikard Falkeborn
The
perf_opsare not modified through this pointer. Make them const to indicate that. This is in preparation to make the scmi-ops pointers inscmi_handleconst.Your ack needed to take this as series via {arm-,}soc
Can I just pick the first patch and you do the rest ? Will it result in any warnings at either end ?
Signature · 1 line
viresh
Re: [PATCH 1/3] cpufreq: arm_scmi: Constify scmi_perf_ops pointers
Quoted 9 lines · Viresh Kumar
Quoted 8 lines · Sudeep Holla
Hi Viresh,
Quoted 4 lines · Rikard Falkeborn
The
perf_opsare not modified through this pointer. Make them const to indicate that. This is in preparation to make the scmi-ops pointers inscmi_handleconst.
Quoted 5 lines
Quoted 1 line
Your ack needed to take this as series via {arm-,}soc
Can I just pick the first patch and you do the rest ? Will it result in any warnings at either end ?
Initially I thought out suggesting the same, but then I realised(not checked though), without this change in arm-soc the scmi-cpufreq driver might produce warnings as the const value gets assigned to non const. No ?
--
Regards,
Sudeep
Re: [PATCH 1/3] cpufreq: arm_scmi: Constify scmi_perf_ops pointers
Quoted 12 lines · Sudeep Holla
Quoted 11 lines · Viresh Kumar
Quoted 9 lines · Sudeep Holla
Hi Viresh,
Quoted 4 lines · Rikard Falkeborn
The
perf_opsare not modified through this pointer. Make them const to indicate that. This is in preparation to make the scmi-ops pointers inscmi_handleconst.Your ack needed to take this as series via {arm-,}soc
Quoted 8 lines
Quoted 3 lines
Can I just pick the first patch and you do the rest ? Will it result in any warnings at either end ?
Initially I thought out suggesting the same, but then I realised(not checked though), without this change in arm-soc the scmi-cpufreq driver might produce warnings as the const value gets assigned to non const. No ?
Signature · 1 line
viresh
PATCH 2/3 firmware: arm_scmi: Constify ops pointers in scmi_handle
In reply to Rikard FalkebornThese are never modified, so make them const to allow drivers to make them const.
--- include/linux/scmi_protocol.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
include/linux/scmi_protocol.h +6 -6
@@ -279,12 +279,12 @@ struct scmi_notify_ops {struct scmi_handle {struct device *dev;struct scmi_revision_info *version; -struct scmi_perf_ops *perf_ops; -struct scmi_clk_ops *clk_ops; -struct scmi_power_ops *power_ops; -struct scmi_sensor_ops *sensor_ops; -struct scmi_reset_ops *reset_ops; -struct scmi_notify_ops *notify_ops; +const struct scmi_perf_ops *perf_ops; +const struct scmi_clk_ops *clk_ops; +const struct scmi_power_ops *power_ops; +const struct scmi_sensor_ops *sensor_ops; +const struct scmi_reset_ops *reset_ops; +const struct scmi_notify_ops *notify_ops;/* for protocol internal use */ void *perf_priv;void *clk_priv;
Signature · 1 line
2.28.0
PATCH 3/3 firmware: arm_scmi: Constify static scmi-ops
In reply to Rikard FalkebornThese are never modified, so make them const to allow the compiler to put them in read-only memory.
--- drivers/firmware/arm_scmi/clock.c | 2 +- drivers/firmware/arm_scmi/common.h | 2 +- drivers/firmware/arm_scmi/mailbox.c | 2 +- drivers/firmware/arm_scmi/notify.c | 2 +- drivers/firmware/arm_scmi/perf.c | 2 +- drivers/firmware/arm_scmi/power.c | 2 +- drivers/firmware/arm_scmi/reset.c | 2 +- drivers/firmware/arm_scmi/sensors.c | 2 +- drivers/firmware/arm_scmi/smc.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-)
drivers/firmware/arm_scmi/clock.c +1 -1
@@ -318,7 +318,7 @@ scmi_clock_info_get(const struct scmi_handle *handle, u32 clk_id)return clk; } -static struct scmi_clk_ops clk_ops = { +static const struct scmi_clk_ops clk_ops = { .count_get = scmi_clock_count_get, .info_get = scmi_clock_info_get, .rate_get = scmi_clock_rate_get,
drivers/firmware/arm_scmi/common.h +1 -1
@@ -210,7 +210,7 @@ struct scmi_transport_ops {* @max_msg_size: Maximum size of data per message that can be handled. */ struct scmi_desc { -struct scmi_transport_ops *ops; +const struct scmi_transport_ops *ops;int max_rx_timeout_ms;int max_msg;int max_msg_size;
drivers/firmware/arm_scmi/mailbox.c +1 -1
@@ -181,7 +181,7 @@ mailbox_poll_done(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer)return shmem_poll_done (smbox->shmem, xfer); } -static struct scmi_transport_ops scmi_mailbox_ops = { +static const struct scmi_transport_ops scmi_mailbox_ops = { .chan_available = mailbox_chan_available, .chan_setup = mailbox_chan_setup, .chan_free = mailbox_chan_free,
drivers/firmware/arm_scmi/notify.c +1 -1
@@ -1421,7 +1421,7 @@ static void scmi_protocols_late_init(struct work_struct *work)* notify_ops are attached to the handle so that can be accessed * directly from an scmi_driver to register its own notifiers. */ -static struct scmi_notify_ops notify_ops = { +static const struct scmi_notify_ops notify_ops = { .register_event_notifier = scmi_register_notifier, .unregister_event_notifier = scmi_unregister_notifier, };
drivers/firmware/arm_scmi/perf.c +1 -1
@@ -748,7 +748,7 @@ static bool scmi_fast_switch_possible(const struct scmi_handle *handle,return dom->fc_info && dom->fc_info->level_set_addr; } -static struct scmi_perf_ops perf_ops = { +static const struct scmi_perf_ops perf_ops = { .limits_set = scmi_perf_limits_set, .limits_get = scmi_perf_limits_get, .level_set = scmi_perf_level_set,
drivers/firmware/arm_scmi/power.c +1 -1
@@ -184,7 +184,7 @@ static char *scmi_power_name_get(const struct scmi_handle *handle, u32 domain)return dom->name; } -static struct scmi_power_ops power_ops = { +static const struct scmi_power_ops power_ops = { .num_domains_get = scmi_power_num_domains_get, .name_get = scmi_power_name_get, .state_set = scmi_power_state_set,
drivers/firmware/arm_scmi/reset.c +1 -1
@@ -194,7 +194,7 @@ scmi_reset_domain_deassert(const struct scmi_handle *handle, u32 domain)return scmi_domain_reset (handle, domain,0 ,ARCH_COLD_RESET ); } -static struct scmi_reset_ops reset_ops = { +static const struct scmi_reset_ops reset_ops = { .num_domains_get = scmi_reset_num_domains_get, .name_get = scmi_reset_name_get, .latency_get = scmi_reset_latency_get,
drivers/firmware/arm_scmi/sensors.c +1 -1
@@ -275,7 +275,7 @@ static int scmi_sensor_count_get(const struct scmi_handle *handle)return si->num_sensors; } -static struct scmi_sensor_ops sensor_ops = { +static const struct scmi_sensor_ops sensor_ops = { .count_get = scmi_sensor_count_get, .info_get = scmi_sensor_info_get, .trip_point_config = scmi_sensor_trip_point_config,
drivers/firmware/arm_scmi/smc.c +1 -1
@@ -137,7 +137,7 @@ smc_poll_done(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer)return shmem_poll_done (scmi_info->shmem, xfer); } -static struct scmi_transport_ops scmi_smc_ops = { +static const struct scmi_transport_ops scmi_smc_ops = { .chan_available = smc_chan_available, .chan_setup = smc_chan_setup, .chan_free = smc_chan_free,
Signature · 1 line
2.28.0
Sudeep Holla
AppliedQuoted 10 lines · Rikard Falkeborn
A small patch series aiming to constify static scmi_*_ops structs in
drivers/firmware/arm_scmi. Since these are not modified, constify them to allow the compiler to put them in read-only memory.Rikard Falkeborn (3):
cpufreq:arm_scmi: Constifyscmi_perf_opspointers
firmware:arm_scmi: Constify ops pointers inscmi_handle
firmware:arm_scmi: Constify static scmi-ops[...]
Applied to sudeep.holla/linux (for-next/scmi), thanks!
[1/3] cpufreq: arm_scmi: Constify scmi_perf_ops pointers
https://git.kernel.org/sudeep.holla/c/69ecb3230b [2/3] firmware: arm_scmi: Constify ops pointers in scmi_handle https://git.kernel.org/sudeep.holla/c/82894c1d39 [3/3] firmware: arm_scmi: Constify static scmi-ops https://git.kernel.org/sudeep.holla/c/3de7b83017
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel