ccwgroup.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef S390_CCWGROUP_H
  3. #define S390_CCWGROUP_H
  4. struct ccw_device;
  5. struct ccw_driver;
  6. /**
  7. * struct ccwgroup_device - ccw group device
  8. * @state: online/offline state
  9. * @count: number of attached slave devices
  10. * @dev: embedded device structure
  11. * @cdev: variable number of slave devices, allocated as needed
  12. * @ungroup_work: work to be done when a ccwgroup notifier has action
  13. * type %BUS_NOTIFY_UNBIND_DRIVER
  14. */
  15. struct ccwgroup_device {
  16. enum {
  17. CCWGROUP_OFFLINE,
  18. CCWGROUP_ONLINE,
  19. } state;
  20. /* private: */
  21. atomic_t onoff;
  22. struct mutex reg_mutex;
  23. /* public: */
  24. unsigned int count;
  25. struct device dev;
  26. struct work_struct ungroup_work;
  27. struct ccw_device *cdev[0];
  28. };
  29. /**
  30. * struct ccwgroup_driver - driver for ccw group devices
  31. * @setup: function called during device creation to setup the device
  32. * @remove: function called on remove
  33. * @set_online: function called when device is set online
  34. * @set_offline: function called when device is set offline
  35. * @shutdown: function called when device is shut down
  36. * @prepare: prepare for pm state transition
  37. * @complete: undo work done in @prepare
  38. * @freeze: callback for freezing during hibernation snapshotting
  39. * @thaw: undo work done in @freeze
  40. * @restore: callback for restoring after hibernation
  41. * @driver: embedded driver structure
  42. * @ccw_driver: supported ccw_driver (optional)
  43. */
  44. struct ccwgroup_driver {
  45. int (*setup) (struct ccwgroup_device *);
  46. void (*remove) (struct ccwgroup_device *);
  47. int (*set_online) (struct ccwgroup_device *);
  48. int (*set_offline) (struct ccwgroup_device *);
  49. void (*shutdown)(struct ccwgroup_device *);
  50. int (*prepare) (struct ccwgroup_device *);
  51. void (*complete) (struct ccwgroup_device *);
  52. int (*freeze)(struct ccwgroup_device *);
  53. int (*thaw) (struct ccwgroup_device *);
  54. int (*restore)(struct ccwgroup_device *);
  55. struct device_driver driver;
  56. struct ccw_driver *ccw_driver;
  57. };
  58. extern int ccwgroup_driver_register (struct ccwgroup_driver *cdriver);
  59. extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver);
  60. int ccwgroup_create_dev(struct device *root, struct ccwgroup_driver *gdrv,
  61. int num_devices, const char *buf);
  62. struct ccwgroup_device *get_ccwgroupdev_by_busid(struct ccwgroup_driver *gdrv,
  63. char *bus_id);
  64. extern int ccwgroup_set_online(struct ccwgroup_device *gdev);
  65. extern int ccwgroup_set_offline(struct ccwgroup_device *gdev);
  66. extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
  67. extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev);
  68. #define to_ccwgroupdev(x) container_of((x), struct ccwgroup_device, dev)
  69. #define to_ccwgroupdrv(x) container_of((x), struct ccwgroup_driver, driver)
  70. #if IS_ENABLED(CONFIG_CCWGROUP)
  71. bool dev_is_ccwgroup(struct device *dev);
  72. #else /* CONFIG_CCWGROUP */
  73. static inline bool dev_is_ccwgroup(struct device *dev)
  74. {
  75. return false;
  76. }
  77. #endif /* CONFIG_CCWGROUP */
  78. #endif