1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Mediated device internal 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 struct mdev_driver *mdev_driver;
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 kobject *devices_kobj;
30 struct mdev_parent *parent;
31 struct list_head next;
32 unsigned int type_group_id;
35 extern const struct attribute_group *mdev_device_groups[];
37 #define to_mdev_type_attr(_attr) \
38 container_of(_attr, struct mdev_type_attribute, attr)
39 #define to_mdev_type(_kobj) \
40 container_of(_kobj, struct mdev_type, kobj)
42 int parent_create_sysfs_files(struct mdev_parent *parent);
43 void parent_remove_sysfs_files(struct mdev_parent *parent);
45 int mdev_create_sysfs_files(struct mdev_device *mdev);
46 void mdev_remove_sysfs_files(struct mdev_device *mdev);
48 int mdev_device_create(struct mdev_type *kobj, const guid_t *uuid);
49 int mdev_device_remove(struct mdev_device *dev);
51 void mdev_release_parent(struct kref *kref);
53 static inline void mdev_get_parent(struct mdev_parent *parent)
55 kref_get(&parent->ref);
58 static inline void mdev_put_parent(struct mdev_parent *parent)
60 kref_put(&parent->ref, mdev_release_parent);
63 #endif /* MDEV_PRIVATE_H */