ASoC: Constify local snd_sof_dsp_ops
Subsystems (5)
v2 cover ASoC: Constify local snd_sof_dsp_ops
Hi,
Changes in v2
=============
- Only rebase on for-next of broonie/sound.git
- Add tags.
- Link to v1: https://lore.kernel.org/r/[email protected]
Description
===========
The core code does not modify the 'struct snd_sof_dsp_ops' passed via pointer in various places, so this can be made pointer to const in few places. This in turn allows few drivers to have the local (usually static) 'struct snd_sof_dsp_ops' as const which increased code safety, as it is now part of rodata.
Not all drivers can be made safer that way. Intel and AMD rely on customizing that 'struct snd_sof_dsp_ops' before passing to SOF, so they won't benefit. They don't lose anything., either.
All further patches depend on the first four patches.
Best regards,
Krzysztof
---
Krzysztof Kozlowski (14):
ASoC: SOF: debug: Constify local snd_sof_dsp_ops
ASoC: SOF: ipc3: Constify local snd_sof_dsp_ops
ASoC: SOF: pcm: Constify local snd_sof_dsp_ops
ASoC: SOF: Constify stored pointer to snd_sof_dsp_ops
ASoC: SOF: intel: pci-tng: Constify snd_sof_dsp_ops
ASoC: SOF: intel: hda: Constify snd_sof_dsp_ops
ASoC: SOF: amd: acp: Constify snd_sof_dsp_ops
ASoC: SOF: imx8: Constify snd_sof_dsp_ops
ASoC: SOF: imx8m: Constify snd_sof_dsp_ops
ASoC: SOF: imx8ulp: Constify snd_sof_dsp_ops
ASoC: SOF: intel: bdw: Constify snd_sof_dsp_ops
ASoC: SOF: intel: byt: Constify snd_sof_dsp_ops
ASoC: SOF: mediatek: mt8186: Constify snd_sof_dsp_ops
ASoC: SOF: mediatek: mt8195: Constify snd_sof_dsp_ops
include/sound/sof.h | 2 +- sound/soc/sof/amd/acp-common.c | 2 +- sound/soc/sof/amd/acp.h | 2 +- sound/soc/sof/debug.c | 2 +- sound/soc/sof/imx/imx8.c | 4 ++-- sound/soc/sof/imx/imx8m.c | 2 +- sound/soc/sof/imx/imx8ulp.c | 2 +- sound/soc/sof/intel/bdw.c | 2 +- sound/soc/sof/intel/byt.c | 4 ++-- sound/soc/sof/intel/hda-common-ops.c | 2 +- sound/soc/sof/intel/hda.h | 2 +- sound/soc/sof/intel/pci-tng.c | 2 +- sound/soc/sof/intel/shim.h | 2 +- sound/soc/sof/ipc3-priv.h | 6 +++--- sound/soc/sof/mediatek/mt8186/mt8186.c | 2 +- sound/soc/sof/mediatek/mt8195/mt8195.c | 2 +- sound/soc/sof/pcm.c | 2 +- 17 files changed, 21 insertions(+), 21 deletions(-)
---
base-commit: efdfbbc4dcc8f98754056971f88af0f7ff906144
change-id: 20240414-n-const-ops-var-136f395b374b
Best regards,
Signature · 1 line
Krzysztof Kozlowski <[email protected]>
PATCH v2 1/14 ASoC: SOF: debug: Constify local snd_sof_dsp_ops
Constify the pointer to 'struct snd_sof_dsp_ops' to annotate that functioon does not modify pointed data.
--- sound/soc/sof/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/debug.c +1 -1
@@ -311,8 +311,8 @@ EXPORT_SYMBOL_GPL(snd_sof_dbg_memory_info_init);int snd_sof_dbg_init (struct snd_sof_dev *sdev) { +const struct snd_sof_dsp_ops *ops =sof_ops (sdev);struct snd_sof_pdata *plat_data = sdev->pdata; -struct snd_sof_dsp_ops *ops =sof_ops (sdev);const struct snd_sof_debugfs_map *map;struct dentry *fw_profile;int i;
Signature · 1 line
2.43.0
PATCH v2 2/14 ASoC: SOF: ipc3: Constify local snd_sof_dsp_ops
In reply to Krzysztof KozlowskiConstify the pointer to 'struct snd_sof_dsp_ops' to annotate that functioon does not modify pointed data.
--- sound/soc/sof/ipc3-priv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/sof/ipc3-priv.h +3 -3
@@ -36,7 +36,7 @@ static inline int sof_dtrace_host_init(struct snd_sof_dev *sdev,struct snd_dma_buffer *dmatb, struct sof_ipc_dma_trace_params_ext *dtrace_params) { - struct snd_sof_dsp_ops *dsp_ops = sdev->pdata->desc->ops; + const struct snd_sof_dsp_ops *dsp_ops = sdev->pdata->desc->ops;if (dsp_ops->trace_init)return dsp_ops->trace_init (sdev, dmatb, dtrace_params);
@@ -46,7 +46,7 @@ static inline int sof_dtrace_host_init(struct snd_sof_dev *sdev,static inline int sof_dtrace_host_release (struct snd_sof_dev *sdev) { -struct snd_sof_dsp_ops *dsp_ops = sdev->pdata->desc->ops; +const struct snd_sof_dsp_ops *dsp_ops = sdev->pdata->desc->ops;if (dsp_ops->trace_release)return dsp_ops->trace_release (sdev);
@@ -56,7 +56,7 @@ static inline int sof_dtrace_host_release(struct snd_sof_dev *sdev)static inline int sof_dtrace_host_trigger (struct snd_sof_dev *sdev,int cmd) { -struct snd_sof_dsp_ops *dsp_ops = sdev->pdata->desc->ops; +const struct snd_sof_dsp_ops *dsp_ops = sdev->pdata->desc->ops;if (dsp_ops->trace_trigger)return dsp_ops->trace_trigger (sdev, cmd);
Signature · 1 line
2.43.0
PATCH v2 3/14 ASoC: SOF: pcm: Constify local snd_sof_dsp_ops
In reply to Krzysztof KozlowskiConstify the pointer to 'struct snd_sof_dsp_ops' to annotate that functioon does not modify pointed data.
--- sound/soc/sof/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/pcm.c +1 -1
@@ -423,7 +423,7 @@ static int sof_pcm_open(struct snd_soc_component *component,struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream);struct snd_pcm_runtime *runtime = substream->runtime;struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (component); -struct snd_sof_dsp_ops *ops =sof_ops (sdev); +const struct snd_sof_dsp_ops *ops =sof_ops (sdev);struct snd_sof_pcm *spcm;struct snd_soc_tplg_stream_caps *caps;int ret;
Signature · 1 line
2.43.0
PATCH v2 4/14 ASoC: SOF: Constify stored pointer to snd_sof_dsp_ops
In reply to Krzysztof KozlowskiThe core code does not modify the 'struct snd_sof_dsp_ops', stored in 'struct sof_dev_desc'. Make the pointer to 'struct snd_sof_dsp_ops' const to annotate this, make code a bit safer and allow individual drivers to also define this structure as const.
--- include/sound/sof.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/sound/sof.h +1 -1
@@ -166,7 +166,7 @@ struct sof_dev_desc {/* default firmware name */ const char *default_fw_filename[SOF_IPC_TYPE_COUNT ]; -struct snd_sof_dsp_ops *ops; +const struct snd_sof_dsp_ops *ops;int (*ops_init)(struct snd_sof_dev *sdev);void (*ops_free)(struct snd_sof_dev *sdev); };
Signature · 1 line
2.43.0
PATCH v2 5/14 ASoC: SOF: intel: pci-tng: Constify snd_sof_dsp_ops
In reply to Krzysztof Kozlowski'struct snd_sof_dsp_ops' is not modified by core code, so it can be made const for increased code safety.
--- sound/soc/sof/intel/pci-tng.c | 2 +- sound/soc/sof/intel/shim.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/sof/intel/pci-tng.c +1 -1
@@ -132,7 +132,7 @@ static int tangier_pci_probe(struct snd_sof_dev *sdev)return ret; } -struct snd_sof_dsp_ops sof_tng_ops = { +const struct snd_sof_dsp_ops sof_tng_ops = {/* device init */ .probe = tangier_pci_probe,
sound/soc/sof/intel/shim.h +1 -1
@@ -196,7 +196,7 @@ struct sof_intel_dsp_desc {int (*cl_init)(struct snd_sof_dev *sdev,int stream_tag,bool imr_boot); }; -extern struct snd_sof_dsp_ops sof_tng_ops; +extern const struct snd_sof_dsp_ops sof_tng_ops;extern const struct sof_intel_dsp_desc tng_chip_info;
Signature · 1 line
2.43.0
PATCH v2 6/14 ASoC: SOF: intel: hda: Constify snd_sof_dsp_ops
In reply to Krzysztof Kozlowski'struct snd_sof_dsp_ops' is not modified by core code, so it can be made const for increased code safety.
--- sound/soc/sof/intel/hda-common-ops.c | 2 +- sound/soc/sof/intel/hda.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/sof/intel/hda-common-ops.c +1 -1
@@ -14,7 +14,7 @@#include "hda.h" #include "../sof-audio.h" -struct snd_sof_dsp_ops sof_hda_common_ops = { +const struct snd_sof_dsp_ops sof_hda_common_ops = {/* probe/remove/shutdown */ .probe_early = hda_dsp_probe_early, .probe = hda_dsp_probe,
sound/soc/sof/intel/hda.h +1 -1
@@ -874,7 +874,7 @@ int hda_dsp_dais_suspend(struct snd_sof_dev *sdev);/* * Platform Specific HW abstraction Ops. */ -extern struct snd_sof_dsp_ops sof_hda_common_ops; +extern const struct snd_sof_dsp_ops sof_hda_common_ops;extern struct snd_sof_dsp_ops sof_skl_ops;int sof_skl_ops_init (struct snd_sof_dev *sdev);
Signature · 1 line
2.43.0
PATCH v2 7/14 ASoC: SOF: amd: acp: Constify snd_sof_dsp_ops
In reply to Krzysztof Kozlowski'struct snd_sof_dsp_ops' is not modified by core code, so it can be made const for increased code safety.
--- sound/soc/sof/amd/acp-common.c | 2 +- sound/soc/sof/amd/acp.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/sof/amd/acp-common.c +1 -1
@@ -193,7 +193,7 @@ struct snd_soc_acpi_mach *amd_sof_machine_select(struct snd_sof_dev *sdev) }/* AMD Common DSP ops */ -struct snd_sof_dsp_ops sof_acp_common_ops = { +const struct snd_sof_dsp_ops sof_acp_common_ops = {/* probe and remove */ .probe = amd_sof_acp_probe, .remove = amd_sof_acp_remove,
sound/soc/sof/amd/acp.h +1 -1
@@ -310,7 +310,7 @@ int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substrsnd_pcm_uframes_t acp_pcm_pointer (struct snd_sof_dev *sdev,struct snd_pcm_substream *substream); -extern struct snd_sof_dsp_ops sof_acp_common_ops; +extern const struct snd_sof_dsp_ops sof_acp_common_ops;extern struct snd_sof_dsp_ops sof_renoir_ops;int sof_renoir_ops_init (struct snd_sof_dev *sdev);
Signature · 1 line
2.43.0
PATCH v2 8/14 ASoC: SOF: imx8: Constify snd_sof_dsp_ops
In reply to Krzysztof Kozlowski'struct snd_sof_dsp_ops' is not modified by core code, so it can be made const for increased code safety.
--- sound/soc/sof/imx/imx8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sof/imx/imx8.c +2 -2
@@ -478,7 +478,7 @@ static int imx8_dsp_set_power_state(struct snd_sof_dev *sdev, }/* i.MX8 ops */ -static struct snd_sof_dsp_ops sof_imx8_ops = { +static const struct snd_sof_dsp_ops sof_imx8_ops = {/* probe and remove */ .probe = imx8_probe, .remove = imx8_remove,
@@ -539,7 +539,7 @@ static struct snd_sof_dsp_ops sof_imx8_ops = { };/* i.MX8X ops */ -static struct snd_sof_dsp_ops sof_imx8x_ops = { +static const struct snd_sof_dsp_ops sof_imx8x_ops = {/* probe and remove */ .probe = imx8_probe, .remove = imx8_remove,
Signature · 1 line
2.43.0
PATCH v2 9/14 ASoC: SOF: imx8m: Constify snd_sof_dsp_ops
In reply to Krzysztof Kozlowski'struct snd_sof_dsp_ops' is not modified by core code, so it can be made const for increased code safety.
--- sound/soc/sof/imx/imx8m.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/imx/imx8m.c +1 -1
@@ -411,7 +411,7 @@ static int imx8m_dsp_suspend(struct snd_sof_dev *sdev, unsigned int target_state }/* i.MX8 ops */ -static struct snd_sof_dsp_ops sof_imx8m_ops = { +static const struct snd_sof_dsp_ops sof_imx8m_ops = {/* probe and remove */ .probe = imx8m_probe, .remove = imx8m_remove,
Signature · 1 line
2.43.0
PATCH v2 10/14 ASoC: SOF: imx8ulp: Constify snd_sof_dsp_ops
In reply to Krzysztof Kozlowski'struct snd_sof_dsp_ops' is not modified by core code, so it can be made const for increased code safety.
--- sound/soc/sof/imx/imx8ulp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/imx/imx8ulp.c +1 -1
@@ -408,7 +408,7 @@ static int imx8ulp_dsp_set_power_state(struct snd_sof_dev *sdev, }/* i.MX8 ops */ -static struct snd_sof_dsp_ops sof_imx8ulp_ops = { +static const struct snd_sof_dsp_ops sof_imx8ulp_ops = {/* probe and remove */ .probe = imx8ulp_probe, .remove = imx8ulp_remove,
Signature · 1 line
2.43.0
PATCH v2 11/14 ASoC: SOF: intel: bdw: Constify snd_sof_dsp_ops
In reply to Krzysztof Kozlowski'struct snd_sof_dsp_ops' is not modified by core code, so it can be made const for increased code safety.
--- sound/soc/sof/intel/bdw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/intel/bdw.c +1 -1
@@ -567,7 +567,7 @@ static struct snd_soc_dai_driver bdw_dai[] = { };/* broadwell ops */ -static struct snd_sof_dsp_ops sof_bdw_ops = { +static const struct snd_sof_dsp_ops sof_bdw_ops = {/*Device init */ .probe = bdw_probe,
Signature · 1 line
2.43.0
PATCH v2 12/14 ASoC: SOF: intel: byt: Constify snd_sof_dsp_ops
In reply to Krzysztof Kozlowski'struct snd_sof_dsp_ops' is not modified by core code, so it can be made const for increased code safety.
--- sound/soc/sof/intel/byt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sof/intel/byt.c +2 -2
@@ -214,7 +214,7 @@ static int byt_acpi_probe(struct snd_sof_dev *sdev) }/* baytrail ops */ -static struct snd_sof_dsp_ops sof_byt_ops = { +static const struct snd_sof_dsp_ops sof_byt_ops = {/* device init */ .probe = byt_acpi_probe, .remove = byt_remove,
@@ -289,7 +289,7 @@ static const struct sof_intel_dsp_desc byt_chip_info = { };/* cherrytrail and braswell ops */ -static struct snd_sof_dsp_ops sof_cht_ops = { +static const struct snd_sof_dsp_ops sof_cht_ops = {/* device init */ .probe = byt_acpi_probe, .remove = byt_remove,
Signature · 1 line
2.43.0
PATCH v2 13/14 ASoC: SOF: mediatek: mt8186: Constify snd_sof_dsp_ops
In reply to Krzysztof Kozlowski'struct snd_sof_dsp_ops' is not modified by core code, so it can be made const for increased code safety.
--- sound/soc/sof/mediatek/mt8186/mt8186.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/mediatek/mt8186/mt8186.c +1 -1
@@ -481,7 +481,7 @@ static struct snd_soc_dai_driver mt8186_dai[] = { };/* mt8186 ops */ -static struct snd_sof_dsp_ops sof_mt8186_ops = { +static const struct snd_sof_dsp_ops sof_mt8186_ops = {/* probe and remove */ .probe = mt8186_dsp_probe, .remove = mt8186_dsp_remove,
Signature · 1 line
2.43.0
PATCH v2 14/14 ASoC: SOF: mediatek: mt8195: Constify snd_sof_dsp_ops
In reply to Krzysztof Kozlowski'struct snd_sof_dsp_ops' is not modified by core code, so it can be made const for increased code safety.
--- sound/soc/sof/mediatek/mt8195/mt8195.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/mediatek/mt8195/mt8195.c +1 -1
@@ -505,7 +505,7 @@ static struct snd_soc_dai_driver mt8195_dai[] = { };/* mt8195 ops */ -static struct snd_sof_dsp_ops sof_mt8195_ops = { +static const struct snd_sof_dsp_ops sof_mt8195_ops = {/* probe and remove */ .probe = mt8195_dsp_probe, .remove = mt8195_dsp_remove,
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 14 lines · Krzysztof Kozlowski
Changes in v2
=============
- Only rebase on for-next of broonie/sound.git
- Add tags.
- Link to v1: https://lore.kernel.org/r/[email protected]Description
===========
The core code does not modify the 'structsnd_sof_dsp_ops' passed via pointer in various places, so this can be made pointer to const in few places. This in turn allows few drivers to have the local (usually static) 'structsnd_sof_dsp_ops' as const which increased code safety, as it is now part of rodata.
Quoted 1 line
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/14] ASoC: SOF: debug: Constify local snd_sof_dsp_ops
commit: ffca099bbff1978bc9c97b076f0d35b4fe6ddf27
[02/14] ASoC: SOF: ipc3: Constify local snd_sof_dsp_ops
commit: ee5acc1e035ec5ed5d9f0f63fda9d627220090c2
[03/14] ASoC: SOF: pcm: Constify local snd_sof_dsp_ops
commit: a0db037df9630edad76153c7937c6f5ca04ed44f
[04/14] ASoC: SOF: Constify stored pointer to snd_sof_dsp_ops
commit: 8bbc692d1abce5bc949dea9acba85fc686601c04
[05/14] ASoC: SOF: intel: pci-tng: Constify snd_sof_dsp_ops
commit: 8f2b0d55abc44676b076128903a5dc730aab23c6
[06/14] ASoC: SOF: intel: hda: Constify snd_sof_dsp_ops
commit: 6032eefc2c478243a511352dda04495c9a9fec6a
[07/14] ASoC: SOF: amd: acp: Constify snd_sof_dsp_ops
commit: 04f2f516be09d5493d764e0020a771c46b5470d8
[08/14] ASoC: SOF: imx8: Constify snd_sof_dsp_ops
commit: ab85c44973298b69eb32795de11ce4d426705532
[09/14] ASoC: SOF: imx8m: Constify snd_sof_dsp_ops
commit: 66d49ab5fb51bb8d1b4c2c9c8fa0fbe8e4c8ca1c
[10/14] ASoC: SOF: imx8ulp: Constify snd_sof_dsp_ops
commit: 232e0da9fa778233358586617bd22173bcac6bcc
[11/14] ASoC: SOF: intel: bdw: Constify snd_sof_dsp_ops
commit: 936cc56044a87ae7fbd0e4098a7daefa0f2f4e8e
[12/14] ASoC: SOF: intel: byt: Constify snd_sof_dsp_ops
commit: 48d5f1800d0cbda0212c5a58177918c419a24f8a
[13/14] ASoC: SOF: mediatek: mt8186: Constify snd_sof_dsp_ops
commit: fe80673f59da01776a1402e4b508a66fca43a24d
[14/14] ASoC: SOF: mediatek: mt8195: Constify snd_sof_dsp_ops
commit: 8b6d678fede700db6466d73f11fcbad496fa515eAll being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark