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/device.h>
11 #include <linux/iommu.h>
12 #include <linux/mdev.h>
14 #include "mdev_private.h"
16 static int mdev_probe(struct device *dev)
18 struct mdev_driver *drv =
19 container_of(dev->driver, struct mdev_driver, driver);
23 return drv->probe(to_mdev_device(dev));
26 static void mdev_remove(struct device *dev)
28 struct mdev_driver *drv =
29 container_of(dev->driver, struct mdev_driver, driver);
32 drv->remove(to_mdev_device(dev));
35 static int mdev_match(struct device *dev, struct device_driver *drv)
38 * No drivers automatically match. Drivers are only bound by explicit
39 * device_driver_attach()
44 struct bus_type mdev_bus_type = {
47 .remove = mdev_remove,
50 EXPORT_SYMBOL_GPL(mdev_bus_type);
53 * mdev_register_driver - register a new MDEV driver
54 * @drv: the driver to register
56 * Returns a negative value on error, otherwise 0.
58 int mdev_register_driver(struct mdev_driver *drv)
60 /* initialize common driver fields */
61 drv->driver.bus = &mdev_bus_type;
63 /* register with core */
64 return driver_register(&drv->driver);
66 EXPORT_SYMBOL(mdev_register_driver);
69 * mdev_unregister_driver - unregister MDEV driver
70 * @drv: the driver to unregister
72 void mdev_unregister_driver(struct mdev_driver *drv)
74 driver_unregister(&drv->driver);
76 EXPORT_SYMBOL(mdev_unregister_driver);