Linux Audio

Check our new training course

Loading...
v4.17
 
 1/*
 2 * Mediated device interal definitions
 3 *
 4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
 5 *     Author: Neo Jia <cjia@nvidia.com>
 6 *             Kirti Wankhede <kwankhede@nvidia.com>
 7 *
 8 * This program is free software; you can redistribute it and/or modify
 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef MDEV_PRIVATE_H
14#define MDEV_PRIVATE_H
15
16int  mdev_bus_register(void);
17void mdev_bus_unregister(void);
18
19struct mdev_parent {
20	struct device *dev;
21	const struct mdev_parent_ops *ops;
22	struct kref ref;
23	struct mutex lock;
24	struct list_head next;
25	struct kset *mdev_types_kset;
26	struct list_head type_list;
 
 
27};
28
29struct mdev_device {
30	struct device dev;
31	struct mdev_parent *parent;
32	uuid_le uuid;
33	void *driver_data;
34	struct kref ref;
35	struct list_head next;
36	struct kobject *type_kobj;
37};
38
39#define to_mdev_device(dev)	container_of(dev, struct mdev_device, dev)
40#define dev_is_mdev(d)		((d)->bus == &mdev_bus_type)
41
42struct mdev_type {
43	struct kobject kobj;
44	struct kobject *devices_kobj;
45	struct mdev_parent *parent;
46	struct list_head next;
47	struct attribute_group *group;
48};
49
50#define to_mdev_type_attr(_attr)	\
51	container_of(_attr, struct mdev_type_attribute, attr)
52#define to_mdev_type(_kobj)		\
53	container_of(_kobj, struct mdev_type, kobj)
54
 
 
55int  parent_create_sysfs_files(struct mdev_parent *parent);
56void parent_remove_sysfs_files(struct mdev_parent *parent);
57
58int  mdev_create_sysfs_files(struct device *dev, struct mdev_type *type);
59void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type);
 
 
 
 
 
60
61int  mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid);
62int  mdev_device_remove(struct device *dev, bool force_remove);
 
 
 
 
 
 
 
63
64#endif /* MDEV_PRIVATE_H */
v5.14.15
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * Mediated device internal definitions
 4 *
 5 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
 6 *     Author: Neo Jia <cjia@nvidia.com>
 7 *             Kirti Wankhede <kwankhede@nvidia.com>
 
 
 
 
 8 */
 9
10#ifndef MDEV_PRIVATE_H
11#define MDEV_PRIVATE_H
12
13int  mdev_bus_register(void);
14void mdev_bus_unregister(void);
15
16struct mdev_parent {
17	struct device *dev;
18	const struct mdev_parent_ops *ops;
19	struct kref ref;
 
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;
25};
26
 
 
 
 
 
 
 
 
 
 
 
 
 
27struct mdev_type {
28	struct kobject kobj;
29	struct kobject *devices_kobj;
30	struct mdev_parent *parent;
31	struct list_head next;
32	unsigned int type_group_id;
33};
34
35#define to_mdev_type_attr(_attr)	\
36	container_of(_attr, struct mdev_type_attribute, attr)
37#define to_mdev_type(_kobj)		\
38	container_of(_kobj, struct mdev_type, kobj)
39
40extern struct mdev_driver vfio_mdev_driver;
41
42int  parent_create_sysfs_files(struct mdev_parent *parent);
43void parent_remove_sysfs_files(struct mdev_parent *parent);
44
45int  mdev_create_sysfs_files(struct mdev_device *mdev);
46void mdev_remove_sysfs_files(struct mdev_device *mdev);
47
48int mdev_device_create(struct mdev_type *kobj, const guid_t *uuid);
49int  mdev_device_remove(struct mdev_device *dev);
50
51void mdev_release_parent(struct kref *kref);
52
53static inline void mdev_get_parent(struct mdev_parent *parent)
54{
55	kref_get(&parent->ref);
56}
57
58static inline void mdev_put_parent(struct mdev_parent *parent)
59{
60	kref_put(&parent->ref, mdev_release_parent);
61}
62
63#endif /* MDEV_PRIVATE_H */