* [PATCH] misc: mic: constify virtio_config_ops structures
@ 2017-01-13 18:18 Bhumika Goyal
0 siblings, 0 replies; only message in thread
From: Bhumika Goyal @ 2017-01-13 18:18 UTC (permalink / raw)
To: julia.lawall, sudeep.dutt, ashutosh.dixit, linux-kernel; +Cc: Bhumika Goyal
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 <bhumirks@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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-01-13 18:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-13 18:18 [PATCH] misc: mic: constify virtio_config_ops structures Bhumika Goyal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).