blob: b5819b7d7ef7016f2467f07b57495be54ce33940 [file] [log] [blame]
Kirti Wankhede7b969532016-11-17 02:16:13 +05301/*
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
Alex Williamson9372e6fe2016-12-30 08:13:41 -070019struct mdev_parent {
20 struct device *dev;
21 const struct mdev_parent_ops *ops;
22 struct kref ref;
Alex Williamson9372e6fe2016-12-30 08:13:41 -070023 struct list_head next;
24 struct kset *mdev_types_kset;
25 struct list_head type_list;
26};
27
Alex Williamson99e31232016-12-30 08:13:44 -070028struct mdev_device {
29 struct device dev;
30 struct mdev_parent *parent;
31 uuid_le uuid;
32 void *driver_data;
33 struct kref ref;
34 struct list_head next;
35 struct kobject *type_kobj;
Alex Williamson8f381522018-05-15 13:53:55 -060036 bool active;
Alex Williamson99e31232016-12-30 08:13:44 -070037};
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
Kirti Wankhede7b969532016-11-17 02:16:13 +053042struct mdev_type {
43 struct kobject kobj;
44 struct kobject *devices_kobj;
Alex Williamson42930552016-12-30 08:13:38 -070045 struct mdev_parent *parent;
Kirti Wankhede7b969532016-11-17 02:16:13 +053046 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
Alex Williamson42930552016-12-30 08:13:38 -070055int parent_create_sysfs_files(struct mdev_parent *parent);
56void parent_remove_sysfs_files(struct mdev_parent *parent);
Kirti Wankhede7b969532016-11-17 02:16:13 +053057
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 */