Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit c797bb4

Browse files
jgunthorpezhiwang1
authored andcommitted
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: Jason Gunthorpe <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Zhi Wang <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Kirti Wankhede <[email protected]> Reviewed-by: Zhi Wang <[email protected]>
1 parent 7c3584e commit c797bb4

File tree

7 files changed

+6
-251
lines changed

7 files changed

+6
-251
lines changed

Documentation/driver-api/vfio-mediated-device.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ The structures in the mdev_parent_ops structure are as follows:
138138
* supported_config: attributes to define supported configurations
139139
* device_driver: device driver to bind for mediated device instances
140140

141-
The mdev_parent_ops also still has various functions pointers. Theses exist
142-
for historical reasons only and shall not be used for new drivers.
143-
144141
When a driver wants to add the GUID creation sysfs to an existing device it has
145142
probe'd to then it should call::
146143

drivers/vfio/mdev/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22

3-
mdev-y := mdev_core.o mdev_sysfs.o mdev_driver.o vfio_mdev.o
3+
mdev-y := mdev_core.o mdev_sysfs.o mdev_driver.o
44

55
obj-$(CONFIG_VFIO_MDEV) += mdev.o

drivers/vfio/mdev/mdev_core.c

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,10 @@ void mdev_release_parent(struct kref *kref)
8989
static void mdev_device_remove_common(struct mdev_device *mdev)
9090
{
9191
struct mdev_parent *parent = mdev->type->parent;
92-
int ret;
9392

9493
mdev_remove_sysfs_files(mdev);
9594
device_del(&mdev->dev);
9695
lockdep_assert_held(&parent->unreg_sem);
97-
if (parent->ops->remove) {
98-
ret = parent->ops->remove(mdev);
99-
if (ret)
100-
dev_err(&mdev->dev, "Remove failed: err=%d\n", ret);
101-
}
102-
10396
/* Balances with device_initialize() */
10497
put_device(&mdev->dev);
10598
}
@@ -131,7 +124,7 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
131124
/* check for mandatory ops */
132125
if (!ops || !ops->supported_type_groups)
133126
return -EINVAL;
134-
if (!ops->device_driver && (!ops->create || !ops->remove))
127+
if (!ops->device_driver)
135128
return -EINVAL;
136129

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

300-
if (parent->ops->create) {
301-
ret = parent->ops->create(mdev);
302-
if (ret)
303-
goto out_unlock;
304-
}
305-
306293
ret = device_add(&mdev->dev);
307294
if (ret)
308-
goto out_remove;
295+
goto out_unlock;
309296

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

326311
out_del:
327312
device_del(&mdev->dev);
328-
out_remove:
329-
if (parent->ops->remove)
330-
parent->ops->remove(mdev);
331313
out_unlock:
332314
up_read(&parent->unreg_sem);
333315
out_put_device:
@@ -370,28 +352,14 @@ int mdev_device_remove(struct mdev_device *mdev)
370352

371353
static int __init mdev_init(void)
372354
{
373-
int rc;
374-
375-
rc = mdev_bus_register();
376-
if (rc)
377-
return rc;
378-
rc = mdev_register_driver(&vfio_mdev_driver);
379-
if (rc)
380-
goto err_bus;
381-
return 0;
382-
err_bus:
383-
mdev_bus_unregister();
384-
return rc;
355+
return bus_register(&mdev_bus_type);
385356
}
386357

387358
static void __exit mdev_exit(void)
388359
{
389-
mdev_unregister_driver(&vfio_mdev_driver);
390-
391360
if (mdev_bus_compat_class)
392361
class_compat_unregister(mdev_bus_compat_class);
393-
394-
mdev_bus_unregister();
362+
bus_unregister(&mdev_bus_type);
395363
}
396364

397365
subsys_initcall(mdev_init)

drivers/vfio/mdev/mdev_driver.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,3 @@ void mdev_unregister_driver(struct mdev_driver *drv)
7474
driver_unregister(&drv->driver);
7575
}
7676
EXPORT_SYMBOL(mdev_unregister_driver);
77-
78-
int mdev_bus_register(void)
79-
{
80-
return bus_register(&mdev_bus_type);
81-
}
82-
83-
void mdev_bus_unregister(void)
84-
{
85-
bus_unregister(&mdev_bus_type);
86-
}

drivers/vfio/mdev/mdev_private.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ struct mdev_type {
3737
#define to_mdev_type(_kobj) \
3838
container_of(_kobj, struct mdev_type, kobj)
3939

40-
extern struct mdev_driver vfio_mdev_driver;
41-
4240
int parent_create_sysfs_files(struct mdev_parent *parent);
4341
void parent_remove_sysfs_files(struct mdev_parent *parent);
4442

drivers/vfio/mdev/vfio_mdev.c

Lines changed: 0 additions & 152 deletions
This file was deleted.

include/linux/mdev.h

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -40,40 +40,7 @@ struct device *mtype_get_parent_dev(struct mdev_type *mtype);
4040
* @mdev_attr_groups: Attributes of the mediated device.
4141
* @supported_type_groups: Attributes to define supported types. It is mandatory
4242
* to provide supported types.
43-
* @create: Called to allocate basic resources in parent device's
44-
* driver for a particular mediated device. It is
45-
* mandatory to provide create ops.
46-
* @mdev: mdev_device structure on of mediated device
47-
* that is being created
48-
* Returns integer: success (0) or error (< 0)
49-
* @remove: Called to free resources in parent device's driver for
50-
* a mediated device. It is mandatory to provide 'remove'
51-
* ops.
52-
* @mdev: mdev_device device structure which is being
53-
* destroyed
54-
* Returns integer: success (0) or error (< 0)
55-
* @read: Read emulation callback
56-
* @mdev: mediated device structure
57-
* @buf: read buffer
58-
* @count: number of bytes to read
59-
* @ppos: address.
60-
* Retuns number on bytes read on success or error.
61-
* @write: Write emulation callback
62-
* @mdev: mediated device structure
63-
* @buf: write buffer
64-
* @count: number of bytes to be written
65-
* @ppos: address.
66-
* Retuns number on bytes written on success or error.
67-
* @ioctl: IOCTL callback
68-
* @mdev: mediated device structure
69-
* @cmd: ioctl command
70-
* @arg: arguments to ioctl
71-
* @mmap: mmap callback
72-
* @mdev: mediated device structure
73-
* @vma: vma structure
74-
* @request: request callback to release device
75-
* @mdev: mediated device structure
76-
* @count: request sequence number
43+
*
7744
* Parent device that support mediated device should be registered with mdev
7845
* module with mdev_parent_ops structure.
7946
**/
@@ -83,19 +50,6 @@ struct mdev_parent_ops {
8350
const struct attribute_group **dev_attr_groups;
8451
const struct attribute_group **mdev_attr_groups;
8552
struct attribute_group **supported_type_groups;
86-
87-
int (*create)(struct mdev_device *mdev);
88-
int (*remove)(struct mdev_device *mdev);
89-
int (*open_device)(struct mdev_device *mdev);
90-
void (*close_device)(struct mdev_device *mdev);
91-
ssize_t (*read)(struct mdev_device *mdev, char __user *buf,
92-
size_t count, loff_t *ppos);
93-
ssize_t (*write)(struct mdev_device *mdev, const char __user *buf,
94-
size_t count, loff_t *ppos);
95-
long (*ioctl)(struct mdev_device *mdev, unsigned int cmd,
96-
unsigned long arg);
97-
int (*mmap)(struct mdev_device *mdev, struct vm_area_struct *vma);
98-
void (*request)(struct mdev_device *mdev, unsigned int count);
9953
};
10054

10155
/* interface for exporting mdev supported type attributes */

0 commit comments

Comments
 (0)