misc: mic: constify virtio_config_ops structures
PATCH 1/1 misc: mic: constify virtio_config_ops structures
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
--- drivers/misc/mic/vop/vop_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mic/vop/vop_main.c +1 -1
@@ -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,
Signature · 1 line
1.9.1