Skip to contentSkip to conversation

vfio-mdev: make mdev_fops const and static

PATCH Applied Bhumika Goyal 2 participants 2 messages Sep 30, 2017 – Oct 2, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio-mdev: make mdev_fops const and static

Make this const as it is only passed to a const argument of the function mdev_register_device. Make it static as it is not referenced in any other file.

Structure found using Coccinelle and changes done by hand.

---
 samples/vfio-mdev/mtty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
samples/vfio-mdev/mtty.c +1 -1
index ca49568..09f255b 100644
@@ -1413,7 +1413,7 @@ struct attribute_group *mdev_type_groups[] = {
 	NULL,
 };
 
-struct mdev_parent_ops mdev_fops = {
+static const struct mdev_parent_ops mdev_fops = {
 	.owner                  = THIS_MODULE,
 	.dev_attr_groups        = mtty_dev_groups,
 	.mdev_attr_groups       = mdev_dev_groups,
Signature · 1 line
1.9.1
#1 lore raw
Quoted 16 lines · On Sat, 30 Sep 2017 21:47:24 +0530 Bhumika Goyal <[email protected]> wrote:

Make this const as it is only passed to a const argument of the function mdev_register_device. Make it static as it is not referenced in any other file.

Structure found using Coccinelle and changes done by hand.

---
 samples/vfio-mdev/mtty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
samples/vfio-mdev/mtty.c +0 -0
index ca49568..09f255b 100644

samples/vfio-mdev/mtty.c struct attribute_group *mdev_type_groups[] = { · line 1419

Quoted 8 lines
samples/vfio-mdev/mtty.c +1 -1
@@ -1413,7 +1413,7 @@ struct attribute_group *mdev_type_groups[] = {
 	NULL,
 };
 
-struct mdev_parent_ops mdev_fops = {
+static const struct mdev_parent_ops mdev_fops = {
 	.owner                  = THIS_MODULE,
 	.dev_attr_groups        = mtty_dev_groups,
 	.mdev_attr_groups       = mdev_dev_groups,

Applied to vfio next branch for v4.15. Thanks,

Alex