1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Mediated device interal definitions
5 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
6 * Author: Neo Jia <cjia@nvidia.com>
7 * Kirti Wankhede <kwankhede@nvidia.com>
10 #ifndef MDEV_PRIVATE_H
11 #define MDEV_PRIVATE_H
13 int mdev_bus_register(void);
14 void mdev_bus_unregister(void);
18 const struct mdev_parent_ops *ops;
20 struct list_head next;
21 struct kset *mdev_types_kset;
22 struct list_head type_list;
23 /* Synchronize device creation/removal with parent unregistration */
24 struct rw_semaphore unreg_sem;
29 struct mdev_parent *parent;
32 struct list_head next;
33 struct kobject *type_kobj;
34 struct device *iommu_device;
38 static inline struct mdev_device *to_mdev_device(struct device *dev)
40 return container_of(dev, struct mdev_device, dev);
42 #define dev_is_mdev(d) ((d)->bus == &mdev_bus_type)
46 struct kobject *devices_kobj;
47 struct mdev_parent *parent;
48 struct list_head next;
49 struct attribute_group *group;
52 #define to_mdev_type_attr(_attr) \
53 container_of(_attr, struct mdev_type_attribute, attr)
54 #define to_mdev_type(_kobj) \
55 container_of(_kobj, struct mdev_type, kobj)
57 int parent_create_sysfs_files(struct mdev_parent *parent);
58 void parent_remove_sysfs_files(struct mdev_parent *parent);
60 int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type);
61 void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type);
63 int mdev_device_create(struct kobject *kobj,
64 struct device *dev, const guid_t *uuid);
65 int mdev_device_remove(struct device *dev);
67 #endif /* MDEV_PRIVATE_H */