ccwgroup.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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: used to ungroup the ccwgroup device
  13. */
  14. struct ccwgroup_device {
  15. enum {
  16. CCWGROUP_OFFLINE,
  17. CCWGROUP_ONLINE,
  18. } state;
  19. /* private: */
  20. atomic_t onoff;
  21. struct mutex reg_mutex;
  22. /* public: */
  23. unsigned int count;
  24. struct device dev;
  25. struct work_struct ungroup_work;
  26. struct ccw_device *cdev[];
  27. };
  28. /**
  29. * struct ccwgroup_driver - driver for ccw group devices
  30. * @setup: function called during device creation to setup the device
  31. * @remove: function called on remove
  32. * @set_online: function called when device is set online
  33. * @set_offline: function called when device is set offline
  34. * @shutdown: function called when device is shut down
  35. * @driver: embedded driver structure
  36. * @ccw_driver: supported ccw_driver (optional)
  37. */
  38. struct ccwgroup_driver {
  39. int (*setup) (struct ccwgroup_device *);
  40. void (*remove) (struct ccwgroup_device *);
  41. int (*set_online) (struct ccwgroup_device *);
  42. int (*set_offline) (struct ccwgroup_device *);
  43. void (*shutdown)(struct ccwgroup_device *);
  44. struct device_driver driver;
  45. struct ccw_driver *ccw_driver;
  46. };
  47. extern int ccwgroup_driver_register (struct ccwgroup_driver *cdriver);
  48. extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver);
  49. int ccwgroup_create_dev(struct device *root, struct ccwgroup_driver *gdrv,
  50. int num_devices, const char *buf);
  51. extern int ccwgroup_set_online(struct ccwgroup_device *gdev);
  52. int ccwgroup_set_offline(struct ccwgroup_device *gdev, bool call_gdrv);
  53. extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
  54. extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev);
  55. #define to_ccwgroupdev(x) container_of((x), struct ccwgroup_device, dev)
  56. #define to_ccwgroupdrv(x) container_of((x), struct ccwgroup_driver, driver)
  57. #if IS_ENABLED(CONFIG_CCWGROUP)
  58. bool dev_is_ccwgroup(struct device *dev);
  59. #else /* CONFIG_CCWGROUP */
  60. static inline bool dev_is_ccwgroup(struct device *dev)
  61. {
  62. return false;
  63. }
  64. #endif /* CONFIG_CCWGROUP */
  65. #endif