ccwgroup.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. extern int ccwgroup_set_online(struct ccwgroup_device *gdev);
  63. extern int ccwgroup_set_offline(struct ccwgroup_device *gdev);
  64. extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
  65. extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev);
  66. #define to_ccwgroupdev(x) container_of((x), struct ccwgroup_device, dev)
  67. #define to_ccwgroupdrv(x) container_of((x), struct ccwgroup_driver, driver)
  68. #if IS_ENABLED(CONFIG_CCWGROUP)
  69. bool dev_is_ccwgroup(struct device *dev);
  70. #else /* CONFIG_CCWGROUP */
  71. static inline bool dev_is_ccwgroup(struct device *dev)
  72. {
  73. return false;
  74. }
  75. #endif /* CONFIG_CCWGROUP */
  76. #endif