Commit 6c7f98b3 authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Zhi Wang
Browse files

vfio/mdev: Remove vfio_mdev.c



Now that all mdev drivers directly create their own mdev_device driver and
directly register with the vfio core's vfio_device_ops this is all dead
code.

Delete vfio_mdev.c and the mdev_parent_ops members that are connected to
it.

Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarZhi Wang <zhi.a.wang@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20220411141403.86980-31-hch@lst.de


Reviewed-by: default avatarKirti Wankhede <kwankhede@nvidia.com>
Reviewed-by: default avatarZhi Wang <zhi.a.wang@intel.com>
parent cba619cb
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -138,9 +138,6 @@ The structures in the mdev_parent_ops structure are as follows:
* supported_config: attributes to define supported configurations
* device_driver: device driver to bind for mediated device instances

The mdev_parent_ops also still has various functions pointers.  Theses exist
for historical reasons only and shall not be used for new drivers.

When a driver wants to add the GUID creation sysfs to an existing device it has
probe'd to then it should call::

+1 −1
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only

mdev-y := mdev_core.o mdev_sysfs.o mdev_driver.o vfio_mdev.o
mdev-y := mdev_core.o mdev_sysfs.o mdev_driver.o

obj-$(CONFIG_VFIO_MDEV) += mdev.o
+4 −36
Original line number Diff line number Diff line
@@ -89,17 +89,10 @@ void mdev_release_parent(struct kref *kref)
static void mdev_device_remove_common(struct mdev_device *mdev)
{
	struct mdev_parent *parent = mdev->type->parent;
	int ret;

	mdev_remove_sysfs_files(mdev);
	device_del(&mdev->dev);
	lockdep_assert_held(&parent->unreg_sem);
	if (parent->ops->remove) {
		ret = parent->ops->remove(mdev);
		if (ret)
			dev_err(&mdev->dev, "Remove failed: err=%d\n", ret);
	}

	/* Balances with device_initialize() */
	put_device(&mdev->dev);
}
@@ -131,7 +124,7 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
	/* check for mandatory ops */
	if (!ops || !ops->supported_type_groups)
		return -EINVAL;
	if (!ops->device_driver && (!ops->create || !ops->remove))
	if (!ops->device_driver)
		return -EINVAL;

	dev = get_device(dev);
@@ -297,18 +290,10 @@ int mdev_device_create(struct mdev_type *type, const guid_t *uuid)
		goto out_put_device;
	}

	if (parent->ops->create) {
		ret = parent->ops->create(mdev);
		if (ret)
			goto out_unlock;
	}

	ret = device_add(&mdev->dev);
	if (ret)
		goto out_remove;
		goto out_unlock;

	if (!drv)
		drv = &vfio_mdev_driver;
	ret = device_driver_attach(&drv->driver, &mdev->dev);
	if (ret)
		goto out_del;
@@ -325,9 +310,6 @@ int mdev_device_create(struct mdev_type *type, const guid_t *uuid)

out_del:
	device_del(&mdev->dev);
out_remove:
	if (parent->ops->remove)
		parent->ops->remove(mdev);
out_unlock:
	up_read(&parent->unreg_sem);
out_put_device:
@@ -370,28 +352,14 @@ int mdev_device_remove(struct mdev_device *mdev)

static int __init mdev_init(void)
{
	int rc;

	rc = mdev_bus_register();
	if (rc)
		return rc;
	rc = mdev_register_driver(&vfio_mdev_driver);
	if (rc)
		goto err_bus;
	return 0;
err_bus:
	mdev_bus_unregister();
	return rc;
	return bus_register(&mdev_bus_type);
}

static void __exit mdev_exit(void)
{
	mdev_unregister_driver(&vfio_mdev_driver);

	if (mdev_bus_compat_class)
		class_compat_unregister(mdev_bus_compat_class);

	mdev_bus_unregister();
	bus_unregister(&mdev_bus_type);
}

subsys_initcall(mdev_init)
+0 −10
Original line number Diff line number Diff line
@@ -74,13 +74,3 @@ void mdev_unregister_driver(struct mdev_driver *drv)
	driver_unregister(&drv->driver);
}
EXPORT_SYMBOL(mdev_unregister_driver);

int mdev_bus_register(void)
{
	return bus_register(&mdev_bus_type);
}

void mdev_bus_unregister(void)
{
	bus_unregister(&mdev_bus_type);
}
+0 −2
Original line number Diff line number Diff line
@@ -37,8 +37,6 @@ struct mdev_type {
#define to_mdev_type(_kobj)		\
	container_of(_kobj, struct mdev_type, kobj)

extern struct mdev_driver vfio_mdev_driver;

int  parent_create_sysfs_files(struct mdev_parent *parent);
void parent_remove_sysfs_files(struct mdev_parent *parent);

Loading