summaryrefslogtreecommitdiff
path: root/drivers/vfio/mdev/mdev_driver.c
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@nvidia.com>2021-06-17 16:22:15 +0200
committerAlex Williamson <alex.williamson@redhat.com>2021-06-21 15:29:25 -0600
commit88a21f265ce50a17e6e71e3fb4467625cf234c5a (patch)
tree284c8e38e4948e421c058d9e53f4e4c9dfac1158 /drivers/vfio/mdev/mdev_driver.c
parentaf3ab3f9b986cdbc1b97b8a3341ce78851edb0dd (diff)
downloadlinux-88a21f265ce50a17e6e71e3fb4467625cf234c5a.tar.gz
linux-88a21f265ce50a17e6e71e3fb4467625cf234c5a.tar.bz2
linux-88a21f265ce50a17e6e71e3fb4467625cf234c5a.zip
vfio/mdev: Allow the mdev_parent_ops to specify the device driver to bind
This allows a mdev driver to opt out of using vfio_mdev.c, instead the driver will provide a 'struct mdev_driver' and register directly with the driver core. Much of mdev_parent_ops becomes unused in this mode: - create()/remove() are done via the mdev_driver probe()/remove() - mdev_attr_groups becomes mdev_driver driver.dev_groups - Wrapper function callbacks are replaced with the same ones from struct vfio_device_ops Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com> Link: https://lore.kernel.org/r/20210617142218.1877096-8-hch@lst.de Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio/mdev/mdev_driver.c')
-rw-r--r--drivers/vfio/mdev/mdev_driver.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/vfio/mdev/mdev_driver.c b/drivers/vfio/mdev/mdev_driver.c
index 041699571b7e..c368ec824e2b 100644
--- a/drivers/vfio/mdev/mdev_driver.c
+++ b/drivers/vfio/mdev/mdev_driver.c
@@ -71,10 +71,20 @@ static int mdev_remove(struct device *dev)
return 0;
}
+static int mdev_match(struct device *dev, struct device_driver *drv)
+{
+ /*
+ * No drivers automatically match. Drivers are only bound by explicit
+ * device_driver_attach()
+ */
+ return 0;
+}
+
struct bus_type mdev_bus_type = {
.name = "mdev",
.probe = mdev_probe,
.remove = mdev_remove,
+ .match = mdev_match,
};
EXPORT_SYMBOL_GPL(mdev_bus_type);