Declare virtio_config_ops structure as const as it is only stored in the
config field of a virtio_device structure. This field is of type const, so
virtio_config_ops structures having this property can be declared const.
Done using Coccinelle:

@r1 disable optional_qualifier@
identifier i;
position p;
@@
static struct virtio_config_ops i@p={...};

@ok1@
identifier r1.i;
position p;
struct _vop_vdev x;
@@
x.vdev.config=&i@p

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct virtio_config_ops i;

File size before: drivers/misc/mic/vop/vop_main.o
   text    data     bss     dec     hex filename
   4588     256       0    4844    12ec drivers/misc/mic/vop/vop_main.o

File size after: drivers/misc/mic/vop/vop_main.o
   text    data     bss     dec     hex filename
   4704     160       0    4864    1300 drivers/misc/mic/vop/vop_main.o

Signed-off-by: Bhumika Goyal <bhumi...@gmail.com>
---
 drivers/misc/mic/vop/vop_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/mic/vop/vop_main.c b/drivers/misc/mic/vop/vop_main.c
index 1a2b67f3..3b7c8ea 100644
--- a/drivers/misc/mic/vop/vop_main.c
+++ b/drivers/misc/mic/vop/vop_main.c
@@ -422,7 +422,7 @@ static int vop_find_vqs(struct virtio_device *dev, unsigned 
nvqs,
 /*
  * The config ops structure as defined by virtio config
  */
-static struct virtio_config_ops vop_vq_config_ops = {
+static const struct virtio_config_ops vop_vq_config_ops = {
        .get_features = vop_get_features,
        .finalize_features = vop_finalize_features,
        .get = vop_get,
-- 
1.9.1

Reply via email to