Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Kirti Wankhede | 7b96953 | 2016-11-17 02:16:13 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Mediated device interal definitions |
| 4 | * |
| 5 | * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. |
| 6 | * Author: Neo Jia <cjia@nvidia.com> |
| 7 | * Kirti Wankhede <kwankhede@nvidia.com> |
Kirti Wankhede | 7b96953 | 2016-11-17 02:16:13 +0530 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef MDEV_PRIVATE_H |
| 11 | #define MDEV_PRIVATE_H |
| 12 | |
| 13 | int mdev_bus_register(void); |
| 14 | void mdev_bus_unregister(void); |
| 15 | |
Alex Williamson | 9372e6fe | 2016-12-30 08:13:41 -0700 | [diff] [blame] | 16 | struct mdev_parent { |
| 17 | struct device *dev; |
| 18 | const struct mdev_parent_ops *ops; |
| 19 | struct kref ref; |
Alex Williamson | 9372e6fe | 2016-12-30 08:13:41 -0700 | [diff] [blame] | 20 | struct list_head next; |
| 21 | struct kset *mdev_types_kset; |
| 22 | struct list_head type_list; |
Parav Pandit | 5715c4dd | 2019-06-06 10:52:33 -0600 | [diff] [blame] | 23 | /* Synchronize device creation/removal with parent unregistration */ |
| 24 | struct rw_semaphore unreg_sem; |
Alex Williamson | 9372e6fe | 2016-12-30 08:13:41 -0700 | [diff] [blame] | 25 | }; |
| 26 | |
Alex Williamson | 99e3123 | 2016-12-30 08:13:44 -0700 | [diff] [blame] | 27 | struct mdev_device { |
| 28 | struct device dev; |
| 29 | struct mdev_parent *parent; |
Andy Shevchenko | 278bca7 | 2019-01-10 21:00:27 +0200 | [diff] [blame] | 30 | guid_t uuid; |
Alex Williamson | 99e3123 | 2016-12-30 08:13:44 -0700 | [diff] [blame] | 31 | void *driver_data; |
Alex Williamson | 99e3123 | 2016-12-30 08:13:44 -0700 | [diff] [blame] | 32 | struct list_head next; |
| 33 | struct kobject *type_kobj; |
Lu Baolu | 8ac1317 | 2019-04-12 12:13:24 +0800 | [diff] [blame] | 34 | struct device *iommu_device; |
Alex Williamson | 002fe99 | 2018-05-15 13:53:55 -0600 | [diff] [blame] | 35 | bool active; |
Alex Williamson | 99e3123 | 2016-12-30 08:13:44 -0700 | [diff] [blame] | 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 | |
Kirti Wankhede | 7b96953 | 2016-11-17 02:16:13 +0530 | [diff] [blame] | 41 | struct mdev_type { |
| 42 | struct kobject kobj; |
| 43 | struct kobject *devices_kobj; |
Alex Williamson | 4293055 | 2016-12-30 08:13:38 -0700 | [diff] [blame] | 44 | struct mdev_parent *parent; |
Kirti Wankhede | 7b96953 | 2016-11-17 02:16:13 +0530 | [diff] [blame] | 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 | |
Alex Williamson | 4293055 | 2016-12-30 08:13:38 -0700 | [diff] [blame] | 54 | int parent_create_sysfs_files(struct mdev_parent *parent); |
| 55 | void parent_remove_sysfs_files(struct mdev_parent *parent); |
Kirti Wankhede | 7b96953 | 2016-11-17 02:16:13 +0530 | [diff] [blame] | 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 | |
Andy Shevchenko | 278bca7 | 2019-01-10 21:00:27 +0200 | [diff] [blame] | 60 | int mdev_device_create(struct kobject *kobj, |
| 61 | struct device *dev, const guid_t *uuid); |
Parav Pandit | 522ecce | 2019-06-06 10:52:32 -0600 | [diff] [blame] | 62 | int mdev_device_remove(struct device *dev); |
Kirti Wankhede | 7b96953 | 2016-11-17 02:16:13 +0530 | [diff] [blame] | 63 | |
| 64 | #endif /* MDEV_PRIVATE_H */ |