[media] pci: constify snd_pcm_ops structures
authorJulia Lawall <Julia.Lawall@lip6.fr>
Thu, 8 Sep 2016 00:44:39 +0000 (21:44 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Mon, 19 Sep 2016 19:18:42 +0000 (16:18 -0300)
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>
Acked-by: Andrey Utkin <andrey.utkin@corp.bluecherry.net>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/pci/cobalt/cobalt-alsa-pcm.c
drivers/media/pci/cx18/cx18-alsa-pcm.c
drivers/media/pci/cx23885/cx23885-alsa.c
drivers/media/pci/cx25821/cx25821-alsa.c
drivers/media/pci/cx88/cx88-alsa.c
drivers/media/pci/ivtv/ivtv-alsa-pcm.c
drivers/media/pci/saa7134/saa7134-alsa.c
drivers/media/pci/solo6x10/solo6x10-g723.c
drivers/media/pci/tw686x/tw686x-audio.c

index f0bdf10cfd570e0e65cabd4fa333298bfa6c5f45..49013c6b8646efb42c2c06bfb1f8ff526a4b27c5 100644 (file)
@@ -510,7 +510,7 @@ static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,
        return vmalloc_to_page(pageptr);
 }
 
-static struct snd_pcm_ops snd_cobalt_pcm_capture_ops = {
+static const struct snd_pcm_ops snd_cobalt_pcm_capture_ops = {
        .open           = snd_cobalt_pcm_capture_open,
        .close          = snd_cobalt_pcm_capture_close,
        .ioctl          = snd_cobalt_pcm_ioctl,
@@ -522,7 +522,7 @@ static struct snd_pcm_ops snd_cobalt_pcm_capture_ops = {
        .page           = snd_pcm_get_vmalloc_page,
 };
 
-static struct snd_pcm_ops snd_cobalt_pcm_playback_ops = {
+static const struct snd_pcm_ops snd_cobalt_pcm_playback_ops = {
        .open           = snd_cobalt_pcm_playback_open,
        .close          = snd_cobalt_pcm_playback_close,
        .ioctl          = snd_cobalt_pcm_ioctl,
index ffb6acdc575f65993f231d9f600f3ab0f7682883..5344510fbea30afb97cb99229b96e1eab67e1599 100644 (file)
@@ -311,7 +311,7 @@ static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,
        return vmalloc_to_page(pageptr);
 }
 
-static struct snd_pcm_ops snd_cx18_pcm_capture_ops = {
+static const struct snd_pcm_ops snd_cx18_pcm_capture_ops = {
        .open           = snd_cx18_pcm_capture_open,
        .close          = snd_cx18_pcm_capture_close,
        .ioctl          = snd_cx18_pcm_ioctl,
index ae7c2e89ad1cd6b9aebe8f0baea24d76e9065b79..6115d4e148ba4556ca6bbb379a74ead98ec44934 100644 (file)
@@ -506,7 +506,7 @@ static struct page *snd_cx23885_page(struct snd_pcm_substream *substream,
 /*
  * operators
  */
-static struct snd_pcm_ops snd_cx23885_pcm_ops = {
+static const struct snd_pcm_ops snd_cx23885_pcm_ops = {
        .open = snd_cx23885_pcm_open,
        .close = snd_cx23885_close,
        .ioctl = snd_pcm_lib_ioctl,
index df189b16af121152d68b9fc949ec36f4d6625fd0..4711583de8fe5325312cfb757f7c624cc27b11e0 100644 (file)
@@ -649,7 +649,7 @@ static struct page *snd_cx25821_page(struct snd_pcm_substream *substream,
 /*
  * operators
  */
-static struct snd_pcm_ops snd_cx25821_pcm_ops = {
+static const struct snd_pcm_ops snd_cx25821_pcm_ops = {
        .open = snd_cx25821_pcm_open,
        .close = snd_cx25821_close,
        .ioctl = snd_pcm_lib_ioctl,
index f3f13eb0c16e8dac5ce9d6ab72f07392d05101b5..723f0646210433a82c659c3f64efeabd49b5bd21 100644 (file)
@@ -599,7 +599,7 @@ static struct page *snd_cx88_page(struct snd_pcm_substream *substream,
 /*
  * operators
  */
-static struct snd_pcm_ops snd_cx88_pcm_ops = {
+static const struct snd_pcm_ops snd_cx88_pcm_ops = {
        .open = snd_cx88_pcm_open,
        .close = snd_cx88_close,
        .ioctl = snd_pcm_lib_ioctl,
index f198b9826ed8d63d5c43e623ba096eea0d853de7..a26f9800eca34e55e88436edc0ea93a57e4b2cff 100644 (file)
@@ -318,7 +318,7 @@ static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,
        return vmalloc_to_page(pageptr);
 }
 
-static struct snd_pcm_ops snd_ivtv_pcm_capture_ops = {
+static const struct snd_pcm_ops snd_ivtv_pcm_capture_ops = {
        .open           = snd_ivtv_pcm_capture_open,
        .close          = snd_ivtv_pcm_capture_close,
        .ioctl          = snd_ivtv_pcm_ioctl,
index 94f8162444071ca3168af652b0c260acaeeab021..dc0e2fc5f68be664b3e3e4859378329e9db1cf2a 100644 (file)
@@ -877,7 +877,7 @@ static struct page *snd_card_saa7134_page(struct snd_pcm_substream *substream,
  * ALSA capture callbacks definition
  */
 
-static struct snd_pcm_ops snd_card_saa7134_capture_ops = {
+static const struct snd_pcm_ops snd_card_saa7134_capture_ops = {
        .open =                 snd_card_saa7134_capture_open,
        .close =                snd_card_saa7134_capture_close,
        .ioctl =                snd_pcm_lib_ioctl,
index 4a37a1c51c48830274033981dd2cb07bc307b602..6a35107aca255b88555297567feb44c8f6eb74bc 100644 (file)
@@ -252,7 +252,7 @@ static int snd_solo_pcm_copy(struct snd_pcm_substream *ss, int channel,
        return 0;
 }
 
-static struct snd_pcm_ops snd_solo_pcm_ops = {
+static const struct snd_pcm_ops snd_solo_pcm_ops = {
        .open = snd_solo_pcm_open,
        .close = snd_solo_pcm_close,
        .ioctl = snd_pcm_lib_ioctl,
index 96e444c4917363b67524436081113182d47b0cd7..77190768622a6262418a6e62c7bed5bf341760e1 100644 (file)
@@ -269,7 +269,7 @@ static snd_pcm_uframes_t tw686x_pcm_pointer(struct snd_pcm_substream *ss)
        return bytes_to_frames(ss->runtime, ac->ptr);
 }
 
-static struct snd_pcm_ops tw686x_pcm_ops = {
+static const struct snd_pcm_ops tw686x_pcm_ops = {
        .open = tw686x_pcm_open,
        .close = tw686x_pcm_close,
        .ioctl = snd_pcm_lib_ioctl,