Merge tag 'linux-watchdog-5.2-rc1' of git://www.linux-watchdog.org/linux-watchdog
[linux-2.6-block.git] / drivers / vfio / mdev / mdev_private.h
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
16 int  mdev_bus_register(void);
17 void mdev_bus_unregister(void);
18
19 struct mdev_parent {
20         struct device *dev;
21         const struct mdev_parent_ops *ops;
22         struct kref ref;
23         struct list_head next;
24         struct kset *mdev_types_kset;
25         struct list_head type_list;
26 };
27
28 struct mdev_device {
29         struct device dev;
30         struct mdev_parent *parent;
31         guid_t uuid;
32         void *driver_data;
33         struct list_head next;
34         struct kobject *type_kobj;
35         bool active;
36 };
37
38 #define to_mdev_device(dev)     container_of(dev, struct mdev_device, dev)
39 #define dev_is_mdev(d)          ((d)->bus == &mdev_bus_type)
40
41 struct mdev_type {
42         struct kobject kobj;
43         struct kobject *devices_kobj;
44         struct mdev_parent *parent;
45         struct list_head next;
46         struct attribute_group *group;
47 };
48
49 #define to_mdev_type_attr(_attr)        \
50         container_of(_attr, struct mdev_type_attribute, attr)
51 #define to_mdev_type(_kobj)             \
52         container_of(_kobj, struct mdev_type, kobj)
53
54 int  parent_create_sysfs_files(struct mdev_parent *parent);
55 void parent_remove_sysfs_files(struct mdev_parent *parent);
56
57 int  mdev_create_sysfs_files(struct device *dev, struct mdev_type *type);
58 void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type);
59
60 int  mdev_device_create(struct kobject *kobj,
61                         struct device *dev, const guid_t *uuid);
62 int  mdev_device_remove(struct device *dev, bool force_remove);
63
64 #endif /* MDEV_PRIVATE_H */