Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 115c7254 authored by Julia Lawall's avatar Julia Lawall Committed by Mark Brown
Browse files

ASoC: constify snd_pcm_ops structures

Check for snd_pcm_ops structures that are only stored in the ops field of a
snd_soc_platform_driver structure or passed as the third argument to
snd_pcm_set_ops.  The corresponding field or parameter is declared const,
so snd_pcm_ops structures that have this property can be declared as const
also.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/

)

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct snd_pcm_ops i@p = { ... };

@ok1@
identifier r.i;
struct snd_soc_platform_driver e;
position p;
@@
e.ops = &i@p;

@ok2@
identifier r.i;
expression e1, e2;
position p;
@@
snd_pcm_set_ops(e1, e2, &i@p)

@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
struct snd_pcm_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct snd_pcm_ops i = { ... };
// </smpl>

Signed-off-by: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 29b4817d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -897,7 +897,7 @@ static int acp_dma_close(struct snd_pcm_substream *substream)
	return 0;
}

static struct snd_pcm_ops acp_dma_ops = {
static const struct snd_pcm_ops acp_dma_ops = {
	.open = acp_dma_open,
	.close = acp_dma_close,
	.ioctl = snd_pcm_lib_ioctl,
+1 −1
Original line number Diff line number Diff line
@@ -381,7 +381,7 @@ static int atmel_pcm_close(struct snd_pcm_substream *substream)
	return 0;
}

static struct snd_pcm_ops atmel_pcm_ops = {
static const struct snd_pcm_ops atmel_pcm_ops = {
	.open		= atmel_pcm_open,
	.close		= atmel_pcm_close,
	.ioctl		= snd_pcm_lib_ioctl,
+1 −1
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ static snd_pcm_uframes_t rt5514_spi_pcm_pointer(
	return bytes_to_frames(runtime, rt5514_dsp->dma_offset);
}

static struct snd_pcm_ops rt5514_spi_pcm_ops = {
static const struct snd_pcm_ops rt5514_spi_pcm_ops = {
	.open		= rt5514_spi_pcm_open,
	.hw_params	= rt5514_spi_hw_params,
	.hw_free	= rt5514_spi_hw_free,
+1 −1
Original line number Diff line number Diff line
@@ -322,7 +322,7 @@ static snd_pcm_uframes_t fsl_asrc_dma_pcm_pointer(struct snd_pcm_substream *subs
	return bytes_to_frames(substream->runtime, pair->pos);
}

static struct snd_pcm_ops fsl_asrc_dma_pcm_ops = {
static const struct snd_pcm_ops fsl_asrc_dma_pcm_ops = {
	.ioctl		= snd_pcm_lib_ioctl,
	.hw_params	= fsl_asrc_dma_hw_params,
	.hw_free	= fsl_asrc_dma_hw_free,
+1 −1
Original line number Diff line number Diff line
@@ -670,7 +670,7 @@ static snd_pcm_uframes_t sst_platform_pcm_pointer
	return str_info->buffer_ptr;
}

static struct snd_pcm_ops sst_platform_ops = {
static const struct snd_pcm_ops sst_platform_ops = {
	.open = sst_platform_open,
	.ioctl = snd_pcm_lib_ioctl,
	.trigger = sst_platform_pcm_trigger,
Loading