mdev_private.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #ifndef MDEV_PRIVATE_H
  13. #define MDEV_PRIVATE_H
  14. int mdev_bus_register(void);
  15. void mdev_bus_unregister(void);
  16. struct 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. };
  24. struct mdev_device {
  25. struct device dev;
  26. struct mdev_parent *parent;
  27. uuid_le uuid;
  28. void *driver_data;
  29. struct kref ref;
  30. struct list_head next;
  31. struct kobject *type_kobj;
  32. bool active;
  33. };
  34. #define to_mdev_device(dev) container_of(dev, struct mdev_device, dev)
  35. #define dev_is_mdev(d) ((d)->bus == &mdev_bus_type)
  36. struct mdev_type {
  37. struct kobject kobj;
  38. struct kobject *devices_kobj;
  39. struct mdev_parent *parent;
  40. struct list_head next;
  41. struct attribute_group *group;
  42. };
  43. #define to_mdev_type_attr(_attr) \
  44. container_of(_attr, struct mdev_type_attribute, attr)
  45. #define to_mdev_type(_kobj) \
  46. container_of(_kobj, struct mdev_type, kobj)
  47. int parent_create_sysfs_files(struct mdev_parent *parent);
  48. void parent_remove_sysfs_files(struct mdev_parent *parent);
  49. int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type);
  50. void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type);
  51. int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid);
  52. int mdev_device_remove(struct device *dev, bool force_remove);
  53. #endif /* MDEV_PRIVATE_H */