From c4be067a7b67f616b9ec85423a20be6be9b8ec37 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 19 Dec 2025 12:45:44 +0100 Subject: [PATCH] ASoC: qcom: topology: Constify pointed topology and vendor structs Several functions in topology.c receive pointers to 'struct snd_soc_tplg_vendor_array' and 'struct snd_soc_tplg_private', and do not modify their contents. Constify the pointers for self-explanatory code (pointed memory is not modified by the function) and a bit safer code. Signed-off-by: Krzysztof Kozlowski Link: https://patch.msgid.link/20251219-b4-container-of-const-asoc-qcom-v2-1-05fd2ecc06fe@oss.qualcomm.com Signed-off-by: Mark Brown --- sound/soc/qcom/qdsp6/topology.c | 70 ++++++++++++++++----------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/sound/soc/qcom/qdsp6/topology.c b/sound/soc/qcom/qdsp6/topology.c index 5ce6edf3305ea..062eb01fc7a7b 100644 --- a/sound/soc/qcom/qdsp6/topology.c +++ b/sound/soc/qcom/qdsp6/topology.c @@ -206,15 +206,15 @@ static struct audioreach_module *audioreach_tplg_alloc_module(struct q6apm *apm, return mod; } -static struct snd_soc_tplg_vendor_array *audioreach_get_sg_array( - struct snd_soc_tplg_private *private) +static const struct snd_soc_tplg_vendor_array * +audioreach_get_sg_array(const struct snd_soc_tplg_private *private) { - struct snd_soc_tplg_vendor_array *sg_array = NULL; + const struct snd_soc_tplg_vendor_array *sg_array = NULL; bool found = false; int sz; for (sz = 0; !found && (sz < le32_to_cpu(private->size)); ) { - struct snd_soc_tplg_vendor_value_elem *sg_elem; + const struct snd_soc_tplg_vendor_value_elem *sg_elem; int tkn_count = 0; sg_array = (struct snd_soc_tplg_vendor_array *)((u8 *)private->array + sz); @@ -239,15 +239,15 @@ static struct snd_soc_tplg_vendor_array *audioreach_get_sg_array( return NULL; } -static struct snd_soc_tplg_vendor_array *audioreach_get_cont_array( - struct snd_soc_tplg_private *private) +static const struct snd_soc_tplg_vendor_array * +audioreach_get_cont_array(const struct snd_soc_tplg_private *private) { - struct snd_soc_tplg_vendor_array *cont_array = NULL; + const struct snd_soc_tplg_vendor_array *cont_array = NULL; bool found = false; int sz; for (sz = 0; !found && (sz < le32_to_cpu(private->size)); ) { - struct snd_soc_tplg_vendor_value_elem *cont_elem; + const struct snd_soc_tplg_vendor_value_elem *cont_elem; int tkn_count = 0; cont_array = (struct snd_soc_tplg_vendor_array *)((u8 *)private->array + sz); @@ -272,15 +272,15 @@ static struct snd_soc_tplg_vendor_array *audioreach_get_cont_array( return NULL; } -static struct snd_soc_tplg_vendor_array *audioreach_get_module_array( - struct snd_soc_tplg_private *private) +static const struct snd_soc_tplg_vendor_array * +audioreach_get_module_array(const struct snd_soc_tplg_private *private) { - struct snd_soc_tplg_vendor_array *mod_array = NULL; + const struct snd_soc_tplg_vendor_array *mod_array = NULL; bool found = false; int sz = 0; for (sz = 0; !found && (sz < le32_to_cpu(private->size)); ) { - struct snd_soc_tplg_vendor_value_elem *mod_elem; + const struct snd_soc_tplg_vendor_value_elem *mod_elem; int tkn_count = 0; mod_array = (struct snd_soc_tplg_vendor_array *)((u8 *)private->array + sz); @@ -305,13 +305,13 @@ static struct snd_soc_tplg_vendor_array *audioreach_get_module_array( return NULL; } -static struct audioreach_module_priv_data *audioreach_get_module_priv_data( - struct snd_soc_tplg_private *private) +static struct audioreach_module_priv_data * +audioreach_get_module_priv_data(const struct snd_soc_tplg_private *private) { int sz; for (sz = 0; sz < le32_to_cpu(private->size); ) { - struct snd_soc_tplg_vendor_array *mod_array; + const struct snd_soc_tplg_vendor_array *mod_array; mod_array = (struct snd_soc_tplg_vendor_array *)((u8 *)private->array + sz); if (le32_to_cpu(mod_array->type) == SND_SOC_AR_TPLG_MODULE_CFG_TYPE) { @@ -334,10 +334,10 @@ static struct audioreach_module_priv_data *audioreach_get_module_priv_data( } static struct audioreach_sub_graph *audioreach_parse_sg_tokens(struct q6apm *apm, - struct snd_soc_tplg_private *private) + const struct snd_soc_tplg_private *private) { - struct snd_soc_tplg_vendor_value_elem *sg_elem; - struct snd_soc_tplg_vendor_array *sg_array; + const struct snd_soc_tplg_vendor_value_elem *sg_elem; + const struct snd_soc_tplg_vendor_array *sg_array; struct audioreach_graph_info *info = NULL; int graph_id, sub_graph_id, tkn_count = 0; struct audioreach_sub_graph *sg; @@ -392,10 +392,10 @@ static struct audioreach_sub_graph *audioreach_parse_sg_tokens(struct q6apm *apm static struct audioreach_container *audioreach_parse_cont_tokens(struct q6apm *apm, struct audioreach_sub_graph *sg, - struct snd_soc_tplg_private *private) + const struct snd_soc_tplg_private *private) { - struct snd_soc_tplg_vendor_value_elem *cont_elem; - struct snd_soc_tplg_vendor_array *cont_array; + const struct snd_soc_tplg_vendor_value_elem *cont_elem; + const struct snd_soc_tplg_vendor_array *cont_array; struct audioreach_container *cont; int container_id, tkn_count = 0; bool found = false; @@ -437,7 +437,7 @@ static struct audioreach_container *audioreach_parse_cont_tokens(struct q6apm *a static struct audioreach_module *audioreach_parse_common_tokens(struct q6apm *apm, struct audioreach_container *cont, - struct snd_soc_tplg_private *private, + const struct snd_soc_tplg_private *private, struct snd_soc_dapm_widget *w) { uint32_t max_ip_port = 0, max_op_port = 0; @@ -447,8 +447,8 @@ static struct audioreach_module *audioreach_parse_common_tokens(struct q6apm *ap uint32_t src_mod_inst_id = 0; int module_id = 0, instance_id = 0, tkn_count = 0; - struct snd_soc_tplg_vendor_value_elem *mod_elem; - struct snd_soc_tplg_vendor_array *mod_array; + const struct snd_soc_tplg_vendor_value_elem *mod_elem; + const struct snd_soc_tplg_vendor_array *mod_array; struct audioreach_module *mod = NULL; uint32_t token; bool found; @@ -622,8 +622,8 @@ static int audioreach_widget_load_enc_dec_cnv(struct snd_soc_component *componen int index, struct snd_soc_dapm_widget *w, struct snd_soc_tplg_dapm_widget *tplg_w) { - struct snd_soc_tplg_vendor_value_elem *mod_elem; - struct snd_soc_tplg_vendor_array *mod_array; + const struct snd_soc_tplg_vendor_value_elem *mod_elem; + const struct snd_soc_tplg_vendor_array *mod_array; struct audioreach_module *mod; struct snd_soc_dobj *dobj; int tkn_count = 0; @@ -660,9 +660,9 @@ static int audioreach_widget_load_enc_dec_cnv(struct snd_soc_component *componen } static int audioreach_widget_log_module_load(struct audioreach_module *mod, - struct snd_soc_tplg_vendor_array *mod_array) + const struct snd_soc_tplg_vendor_array *mod_array) { - struct snd_soc_tplg_vendor_value_elem *mod_elem; + const struct snd_soc_tplg_vendor_value_elem *mod_elem; int tkn_count = 0; mod_elem = mod_array->value; @@ -690,9 +690,9 @@ static int audioreach_widget_log_module_load(struct audioreach_module *mod, } static int audioreach_widget_dma_module_load(struct audioreach_module *mod, - struct snd_soc_tplg_vendor_array *mod_array) + const struct snd_soc_tplg_vendor_array *mod_array) { - struct snd_soc_tplg_vendor_value_elem *mod_elem; + const struct snd_soc_tplg_vendor_value_elem *mod_elem; int tkn_count = 0; mod_elem = mod_array->value; @@ -719,9 +719,9 @@ static int audioreach_widget_dma_module_load(struct audioreach_module *mod, } static int audioreach_widget_i2s_module_load(struct audioreach_module *mod, - struct snd_soc_tplg_vendor_array *mod_array) + const struct snd_soc_tplg_vendor_array *mod_array) { - struct snd_soc_tplg_vendor_value_elem *mod_elem; + const struct snd_soc_tplg_vendor_value_elem *mod_elem; int tkn_count = 0; mod_elem = mod_array->value; @@ -754,9 +754,9 @@ static int audioreach_widget_i2s_module_load(struct audioreach_module *mod, } static int audioreach_widget_dp_module_load(struct audioreach_module *mod, - struct snd_soc_tplg_vendor_array *mod_array) + const struct snd_soc_tplg_vendor_array *mod_array) { - struct snd_soc_tplg_vendor_value_elem *mod_elem; + const struct snd_soc_tplg_vendor_value_elem *mod_elem; int tkn_count = 0; mod_elem = mod_array->value; @@ -780,7 +780,7 @@ static int audioreach_widget_load_buffer(struct snd_soc_component *component, int index, struct snd_soc_dapm_widget *w, struct snd_soc_tplg_dapm_widget *tplg_w) { - struct snd_soc_tplg_vendor_array *mod_array; + const struct snd_soc_tplg_vendor_array *mod_array; struct audioreach_module *mod; struct snd_soc_dobj *dobj; int ret; -- 2.47.3