Commit 228132b4 authored by Mark Brown's avatar Mark Brown

ASoC: Constify local snd_sof_dsp_ops

Merge series from Krzysztof Kozlowski <krzk@kernel.org>:

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.
parents af2ab6cc 8b6d678f
...@@ -166,7 +166,7 @@ struct sof_dev_desc { ...@@ -166,7 +166,7 @@ struct sof_dev_desc {
/* default firmware name */ /* default firmware name */
const char *default_fw_filename[SOF_IPC_TYPE_COUNT]; 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); int (*ops_init)(struct snd_sof_dev *sdev);
void (*ops_free)(struct snd_sof_dev *sdev); void (*ops_free)(struct snd_sof_dev *sdev);
}; };
......
...@@ -193,7 +193,7 @@ struct snd_soc_acpi_mach *amd_sof_machine_select(struct snd_sof_dev *sdev) ...@@ -193,7 +193,7 @@ struct snd_soc_acpi_mach *amd_sof_machine_select(struct snd_sof_dev *sdev)
} }
/* AMD Common DSP ops */ /* 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 and remove */
.probe = amd_sof_acp_probe, .probe = amd_sof_acp_probe,
.remove = amd_sof_acp_remove, .remove = amd_sof_acp_remove,
......
...@@ -310,7 +310,7 @@ int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substr ...@@ -310,7 +310,7 @@ int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substr
snd_pcm_uframes_t acp_pcm_pointer(struct snd_sof_dev *sdev, snd_pcm_uframes_t acp_pcm_pointer(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream); 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; extern struct snd_sof_dsp_ops sof_renoir_ops;
int sof_renoir_ops_init(struct snd_sof_dev *sdev); int sof_renoir_ops_init(struct snd_sof_dev *sdev);
......
...@@ -311,8 +311,8 @@ EXPORT_SYMBOL_GPL(snd_sof_dbg_memory_info_init); ...@@ -311,8 +311,8 @@ EXPORT_SYMBOL_GPL(snd_sof_dbg_memory_info_init);
int snd_sof_dbg_init(struct snd_sof_dev *sdev) 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_pdata *plat_data = sdev->pdata;
struct snd_sof_dsp_ops *ops = sof_ops(sdev);
const struct snd_sof_debugfs_map *map; const struct snd_sof_debugfs_map *map;
struct dentry *fw_profile; struct dentry *fw_profile;
int i; int i;
......
...@@ -478,7 +478,7 @@ static int imx8_dsp_set_power_state(struct snd_sof_dev *sdev, ...@@ -478,7 +478,7 @@ static int imx8_dsp_set_power_state(struct snd_sof_dev *sdev,
} }
/* i.MX8 ops */ /* 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 and remove */
.probe = imx8_probe, .probe = imx8_probe,
.remove = imx8_remove, .remove = imx8_remove,
...@@ -539,7 +539,7 @@ static struct snd_sof_dsp_ops sof_imx8_ops = { ...@@ -539,7 +539,7 @@ static struct snd_sof_dsp_ops sof_imx8_ops = {
}; };
/* i.MX8X 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 and remove */
.probe = imx8_probe, .probe = imx8_probe,
.remove = imx8_remove, .remove = imx8_remove,
......
...@@ -411,7 +411,7 @@ static int imx8m_dsp_suspend(struct snd_sof_dev *sdev, unsigned int target_state ...@@ -411,7 +411,7 @@ static int imx8m_dsp_suspend(struct snd_sof_dev *sdev, unsigned int target_state
} }
/* i.MX8 ops */ /* 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 and remove */
.probe = imx8m_probe, .probe = imx8m_probe,
.remove = imx8m_remove, .remove = imx8m_remove,
......
...@@ -408,7 +408,7 @@ static int imx8ulp_dsp_set_power_state(struct snd_sof_dev *sdev, ...@@ -408,7 +408,7 @@ static int imx8ulp_dsp_set_power_state(struct snd_sof_dev *sdev,
} }
/* i.MX8 ops */ /* 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 and remove */
.probe = imx8ulp_probe, .probe = imx8ulp_probe,
.remove = imx8ulp_remove, .remove = imx8ulp_remove,
......
...@@ -567,7 +567,7 @@ static struct snd_soc_dai_driver bdw_dai[] = { ...@@ -567,7 +567,7 @@ static struct snd_soc_dai_driver bdw_dai[] = {
}; };
/* broadwell ops */ /* broadwell ops */
static struct snd_sof_dsp_ops sof_bdw_ops = { static const struct snd_sof_dsp_ops sof_bdw_ops = {
/*Device init */ /*Device init */
.probe = bdw_probe, .probe = bdw_probe,
......
...@@ -214,7 +214,7 @@ static int byt_acpi_probe(struct snd_sof_dev *sdev) ...@@ -214,7 +214,7 @@ static int byt_acpi_probe(struct snd_sof_dev *sdev)
} }
/* baytrail ops */ /* baytrail ops */
static struct snd_sof_dsp_ops sof_byt_ops = { static const struct snd_sof_dsp_ops sof_byt_ops = {
/* device init */ /* device init */
.probe = byt_acpi_probe, .probe = byt_acpi_probe,
.remove = byt_remove, .remove = byt_remove,
...@@ -289,7 +289,7 @@ static const struct sof_intel_dsp_desc byt_chip_info = { ...@@ -289,7 +289,7 @@ static const struct sof_intel_dsp_desc byt_chip_info = {
}; };
/* cherrytrail and braswell ops */ /* 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 */ /* device init */
.probe = byt_acpi_probe, .probe = byt_acpi_probe,
.remove = byt_remove, .remove = byt_remove,
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "hda.h" #include "hda.h"
#include "../sof-audio.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/remove/shutdown */
.probe_early = hda_dsp_probe_early, .probe_early = hda_dsp_probe_early,
.probe = hda_dsp_probe, .probe = hda_dsp_probe,
......
...@@ -874,7 +874,7 @@ int hda_dsp_dais_suspend(struct snd_sof_dev *sdev); ...@@ -874,7 +874,7 @@ int hda_dsp_dais_suspend(struct snd_sof_dev *sdev);
/* /*
* Platform Specific HW abstraction Ops. * 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; extern struct snd_sof_dsp_ops sof_skl_ops;
int sof_skl_ops_init(struct snd_sof_dev *sdev); int sof_skl_ops_init(struct snd_sof_dev *sdev);
......
...@@ -132,7 +132,7 @@ static int tangier_pci_probe(struct snd_sof_dev *sdev) ...@@ -132,7 +132,7 @@ static int tangier_pci_probe(struct snd_sof_dev *sdev)
return ret; return ret;
} }
struct snd_sof_dsp_ops sof_tng_ops = { const struct snd_sof_dsp_ops sof_tng_ops = {
/* device init */ /* device init */
.probe = tangier_pci_probe, .probe = tangier_pci_probe,
......
...@@ -196,7 +196,7 @@ struct sof_intel_dsp_desc { ...@@ -196,7 +196,7 @@ struct sof_intel_dsp_desc {
int (*cl_init)(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot); 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; extern const struct sof_intel_dsp_desc tng_chip_info;
......
...@@ -36,7 +36,7 @@ static inline int sof_dtrace_host_init(struct snd_sof_dev *sdev, ...@@ -36,7 +36,7 @@ static inline int sof_dtrace_host_init(struct snd_sof_dev *sdev,
struct snd_dma_buffer *dmatb, struct snd_dma_buffer *dmatb,
struct sof_ipc_dma_trace_params_ext *dtrace_params) 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) if (dsp_ops->trace_init)
return dsp_ops->trace_init(sdev, dmatb, dtrace_params); 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, ...@@ -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) 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) if (dsp_ops->trace_release)
return dsp_ops->trace_release(sdev); return dsp_ops->trace_release(sdev);
...@@ -56,7 +56,7 @@ static inline int sof_dtrace_host_release(struct snd_sof_dev *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) 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) if (dsp_ops->trace_trigger)
return dsp_ops->trace_trigger(sdev, cmd); return dsp_ops->trace_trigger(sdev, cmd);
......
...@@ -481,7 +481,7 @@ static struct snd_soc_dai_driver mt8186_dai[] = { ...@@ -481,7 +481,7 @@ static struct snd_soc_dai_driver mt8186_dai[] = {
}; };
/* mt8186 ops */ /* 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 and remove */
.probe = mt8186_dsp_probe, .probe = mt8186_dsp_probe,
.remove = mt8186_dsp_remove, .remove = mt8186_dsp_remove,
......
...@@ -505,7 +505,7 @@ static struct snd_soc_dai_driver mt8195_dai[] = { ...@@ -505,7 +505,7 @@ static struct snd_soc_dai_driver mt8195_dai[] = {
}; };
/* mt8195 ops */ /* 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 and remove */
.probe = mt8195_dsp_probe, .probe = mt8195_dsp_probe,
.remove = mt8195_dsp_remove, .remove = mt8195_dsp_remove,
......
...@@ -423,7 +423,7 @@ static int sof_pcm_open(struct snd_soc_component *component, ...@@ -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_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); 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_sof_pcm *spcm;
struct snd_soc_tplg_stream_caps *caps; struct snd_soc_tplg_stream_caps *caps;
int ret; int ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment