ASoC: constify snd_pcm_ops structures
authorJulia Lawall <Julia.Lawall@lip6.fr>
Thu, 8 Sep 2016 00:35:23 +0000 (02:35 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 12 Sep 2016 19:04:09 +0000 (20:04 +0100)
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: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/amd/acp-pcm-dma.c
sound/soc/atmel/atmel-pcm-pdc.c
sound/soc/codecs/rt5514-spi.c
sound/soc/fsl/fsl_asrc_dma.c
sound/soc/intel/atom/sst-mfld-platform-pcm.c
sound/soc/intel/haswell/sst-haswell-pcm.c
sound/soc/intel/skylake/skl-pcm.c
sound/soc/kirkwood/kirkwood-dma.c
sound/soc/qcom/lpass-platform.c
sound/soc/soc-utils.c

index d1fb035f44db8fd7026d97e1148f0c09eb4d1679..504c7cd7f58a335b4c5c35c1cccb36f5d4536c22 100644 (file)
@@ -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,
index da861b44413f7f7f6e199b9d2aa9340691ed5b2f..91b7069c34994b8248d44218066e0ff20124a1bb 100644 (file)
@@ -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,
index 77ff8ebe6dfbed557c856cf18de6aeccf810654f..09103aab0cb2639486cb59f746619c9ea743890a 100644 (file)
@@ -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,
index ffc000bc1f15bffb9c96937e532d04feadddac4a..dc30d780f8742437d9fd6ef3db7cd0ada76c9013 100644 (file)
@@ -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,
index 52ed434cbca6a9e0a08ebc64bb8ee84111f479d9..25c6d87c818e7caf4bdd904b7b72d17887f58b25 100644 (file)
@@ -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,
index 3154525c2b83596eac3a2c57ce4d6b2ac0dfaf8d..9e4094e2c6e319a02aefecd039e68d5fd1465201 100644 (file)
@@ -871,7 +871,7 @@ out:
        return ret;
 }
 
-static struct snd_pcm_ops hsw_pcm_ops = {
+static const struct snd_pcm_ops hsw_pcm_ops = {
        .open           = hsw_pcm_open,
        .close          = hsw_pcm_close,
        .ioctl          = snd_pcm_lib_ioctl,
index 6e05bf8622f7ad1f1cf0ac6f9b11516469e4b86f..7555b1291c9d42f2c426be8cc1b8ea30392dfab7 100644 (file)
@@ -1093,7 +1093,7 @@ static int skl_get_time_info(struct snd_pcm_substream *substream,
        return 0;
 }
 
-static struct snd_pcm_ops skl_platform_ops = {
+static const struct snd_pcm_ops skl_platform_ops = {
        .open = skl_platform_open,
        .ioctl = snd_pcm_lib_ioctl,
        .trigger = skl_platform_pcm_trigger,
index dbfdfe99c69df940259363d7404e0690aa07b92f..dafd22e874e99139ccca45599fd8393c93f75dd2 100644 (file)
@@ -242,7 +242,7 @@ static snd_pcm_uframes_t kirkwood_dma_pointer(struct snd_pcm_substream
        return count;
 }
 
-static struct snd_pcm_ops kirkwood_dma_ops = {
+static const struct snd_pcm_ops kirkwood_dma_ops = {
        .open =         kirkwood_dma_open,
        .close =        kirkwood_dma_close,
        .ioctl =        snd_pcm_lib_ioctl,
index db000c6987a1ced1695d9127398cc8a479853c6f..ccc577042dd8d5f9d569cb2305c24a79cd75ba72 100644 (file)
@@ -372,7 +372,7 @@ static int lpass_platform_pcmops_mmap(struct snd_pcm_substream *substream,
                        runtime->dma_bytes);
 }
 
-static struct snd_pcm_ops lpass_platform_pcm_ops = {
+static const struct snd_pcm_ops lpass_platform_pcm_ops = {
        .open           = lpass_platform_pcmops_open,
        .ioctl          = snd_pcm_lib_ioctl,
        .hw_params      = lpass_platform_pcmops_hw_params,
index 53dd085d3ee20fd5db326366db72054990886118..393e8f0fe2cc6902c4bfaf7a54519496c2d073a5 100644 (file)
@@ -80,7 +80,7 @@ static int dummy_dma_open(struct snd_pcm_substream *substream)
        return 0;
 }
 
-static struct snd_pcm_ops dummy_dma_ops = {
+static const struct snd_pcm_ops dummy_dma_ops = {
        .open           = dummy_dma_open,
        .ioctl          = snd_pcm_lib_ioctl,
 };