1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
6 * Author: Neo Jia <cjia@nvidia.com>
7 * Kirti Wankhede <kwankhede@nvidia.com>
10 #include <linux/iommu.h>
11 #include <linux/mdev.h>
13 #include "mdev_private.h"
15 static int mdev_probe(struct device *dev)
17 struct mdev_driver *drv =
18 container_of(dev->driver, struct mdev_driver, driver);
22 return drv->probe(to_mdev_device(dev));
25 static void mdev_remove(struct device *dev)
27 struct mdev_driver *drv =
28 container_of(dev->driver, struct mdev_driver, driver);
31 drv->remove(to_mdev_device(dev));
34 static int mdev_match(struct device *dev, struct device_driver *drv)
37 * No drivers automatically match. Drivers are only bound by explicit
38 * device_driver_attach()
43 const struct bus_type mdev_bus_type = {
46 .remove = mdev_remove,
51 * mdev_register_driver - register a new MDEV driver
52 * @drv: the driver to register
54 * Returns a negative value on error, otherwise 0.
56 int mdev_register_driver(struct mdev_driver *drv)
61 /* initialize common driver fields */
62 drv->driver.bus = &mdev_bus_type;
63 return driver_register(&drv->driver);
65 EXPORT_SYMBOL(mdev_register_driver);
68 * mdev_unregister_driver - unregister MDEV driver
69 * @drv: the driver to unregister
71 void mdev_unregister_driver(struct mdev_driver *drv)
73 driver_unregister(&drv->driver);
75 EXPORT_SYMBOL(mdev_unregister_driver);