Skip to content

Commit 228132b

Browse files
committed
ASoC: Constify local snd_sof_dsp_ops
Merge series from Krzysztof Kozlowski <[email protected]>: 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.
2 parents af2ab6c + 8b6d678 commit 228132b

File tree

17 files changed

+21
-21
lines changed

17 files changed

+21
-21
lines changed

include/sound/sof.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ struct sof_dev_desc {
166166
/* default firmware name */
167167
const char *default_fw_filename[SOF_IPC_TYPE_COUNT];
168168

169-
struct snd_sof_dsp_ops *ops;
169+
const struct snd_sof_dsp_ops *ops;
170170
int (*ops_init)(struct snd_sof_dev *sdev);
171171
void (*ops_free)(struct snd_sof_dev *sdev);
172172
};

sound/soc/sof/amd/acp-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ struct snd_soc_acpi_mach *amd_sof_machine_select(struct snd_sof_dev *sdev)
193193
}
194194

195195
/* AMD Common DSP ops */
196-
struct snd_sof_dsp_ops sof_acp_common_ops = {
196+
const struct snd_sof_dsp_ops sof_acp_common_ops = {
197197
/* probe and remove */
198198
.probe = amd_sof_acp_probe,
199199
.remove = amd_sof_acp_remove,

sound/soc/sof/amd/acp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substr
310310
snd_pcm_uframes_t acp_pcm_pointer(struct snd_sof_dev *sdev,
311311
struct snd_pcm_substream *substream);
312312

313-
extern struct snd_sof_dsp_ops sof_acp_common_ops;
313+
extern const struct snd_sof_dsp_ops sof_acp_common_ops;
314314

315315
extern struct snd_sof_dsp_ops sof_renoir_ops;
316316
int sof_renoir_ops_init(struct snd_sof_dev *sdev);

sound/soc/sof/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ EXPORT_SYMBOL_GPL(snd_sof_dbg_memory_info_init);
311311

312312
int snd_sof_dbg_init(struct snd_sof_dev *sdev)
313313
{
314+
const struct snd_sof_dsp_ops *ops = sof_ops(sdev);
314315
struct snd_sof_pdata *plat_data = sdev->pdata;
315-
struct snd_sof_dsp_ops *ops = sof_ops(sdev);
316316
const struct snd_sof_debugfs_map *map;
317317
struct dentry *fw_profile;
318318
int i;

sound/soc/sof/imx/imx8.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ static int imx8_dsp_set_power_state(struct snd_sof_dev *sdev,
478478
}
479479

480480
/* i.MX8 ops */
481-
static struct snd_sof_dsp_ops sof_imx8_ops = {
481+
static const struct snd_sof_dsp_ops sof_imx8_ops = {
482482
/* probe and remove */
483483
.probe = imx8_probe,
484484
.remove = imx8_remove,
@@ -539,7 +539,7 @@ static struct snd_sof_dsp_ops sof_imx8_ops = {
539539
};
540540

541541
/* i.MX8X ops */
542-
static struct snd_sof_dsp_ops sof_imx8x_ops = {
542+
static const struct snd_sof_dsp_ops sof_imx8x_ops = {
543543
/* probe and remove */
544544
.probe = imx8_probe,
545545
.remove = imx8_remove,

sound/soc/sof/imx/imx8m.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ static int imx8m_dsp_suspend(struct snd_sof_dev *sdev, unsigned int target_state
411411
}
412412

413413
/* i.MX8 ops */
414-
static struct snd_sof_dsp_ops sof_imx8m_ops = {
414+
static const struct snd_sof_dsp_ops sof_imx8m_ops = {
415415
/* probe and remove */
416416
.probe = imx8m_probe,
417417
.remove = imx8m_remove,

sound/soc/sof/imx/imx8ulp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static int imx8ulp_dsp_set_power_state(struct snd_sof_dev *sdev,
408408
}
409409

410410
/* i.MX8 ops */
411-
static struct snd_sof_dsp_ops sof_imx8ulp_ops = {
411+
static const struct snd_sof_dsp_ops sof_imx8ulp_ops = {
412412
/* probe and remove */
413413
.probe = imx8ulp_probe,
414414
.remove = imx8ulp_remove,

sound/soc/sof/intel/bdw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ static struct snd_soc_dai_driver bdw_dai[] = {
567567
};
568568

569569
/* broadwell ops */
570-
static struct snd_sof_dsp_ops sof_bdw_ops = {
570+
static const struct snd_sof_dsp_ops sof_bdw_ops = {
571571
/*Device init */
572572
.probe = bdw_probe,
573573

sound/soc/sof/intel/byt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static int byt_acpi_probe(struct snd_sof_dev *sdev)
214214
}
215215

216216
/* baytrail ops */
217-
static struct snd_sof_dsp_ops sof_byt_ops = {
217+
static const struct snd_sof_dsp_ops sof_byt_ops = {
218218
/* device init */
219219
.probe = byt_acpi_probe,
220220
.remove = byt_remove,
@@ -289,7 +289,7 @@ static const struct sof_intel_dsp_desc byt_chip_info = {
289289
};
290290

291291
/* cherrytrail and braswell ops */
292-
static struct snd_sof_dsp_ops sof_cht_ops = {
292+
static const struct snd_sof_dsp_ops sof_cht_ops = {
293293
/* device init */
294294
.probe = byt_acpi_probe,
295295
.remove = byt_remove,

sound/soc/sof/intel/hda-common-ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "hda.h"
1515
#include "../sof-audio.h"
1616

17-
struct snd_sof_dsp_ops sof_hda_common_ops = {
17+
const struct snd_sof_dsp_ops sof_hda_common_ops = {
1818
/* probe/remove/shutdown */
1919
.probe_early = hda_dsp_probe_early,
2020
.probe = hda_dsp_probe,

0 commit comments

Comments
 (0)