Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef S390_CCWGROUP_H |
| 3 | #define S390_CCWGROUP_H |
| 4 | |
| 5 | struct ccw_device; |
| 6 | struct ccw_driver; |
| 7 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 8 | /** |
| 9 | * struct ccwgroup_device - ccw group device |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 10 | * @state: online/offline state |
| 11 | * @count: number of attached slave devices |
| 12 | * @dev: embedded device structure |
| 13 | * @cdev: variable number of slave devices, allocated as needed |
Julian Wiedmann | 17c0b86 | 2021-05-05 10:28:21 +0200 | [diff] [blame] | 14 | * @ungroup_work: used to ungroup the ccwgroup device |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 15 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | struct ccwgroup_device { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | enum { |
| 18 | CCWGROUP_OFFLINE, |
| 19 | CCWGROUP_ONLINE, |
| 20 | } state; |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 21 | /* private: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | atomic_t onoff; |
Cornelia Huck | d76123e | 2007-04-27 16:01:37 +0200 | [diff] [blame] | 23 | struct mutex reg_mutex; |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 24 | /* public: */ |
| 25 | unsigned int count; |
| 26 | struct device dev; |
Tejun Heo | 0b60f9e | 2014-02-03 14:03:04 -0500 | [diff] [blame] | 27 | struct work_struct ungroup_work; |
Christian Borntraeger | 0c8c77d | 2014-04-23 20:58:45 +0200 | [diff] [blame] | 28 | struct ccw_device *cdev[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | }; |
| 30 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 31 | /** |
| 32 | * struct ccwgroup_driver - driver for ccw group devices |
Sebastian Ott | f2962da | 2012-05-15 17:49:12 +0200 | [diff] [blame] | 33 | * @setup: function called during device creation to setup the device |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 34 | * @remove: function called on remove |
| 35 | * @set_online: function called when device is set online |
| 36 | * @set_offline: function called when device is set offline |
Cornelia Huck | 01bc8ad | 2008-02-05 16:50:36 +0100 | [diff] [blame] | 37 | * @shutdown: function called when device is shut down |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 38 | * @driver: embedded driver structure |
Julian Wiedmann | f9a5d70 | 2017-09-14 09:52:32 +0200 | [diff] [blame] | 39 | * @ccw_driver: supported ccw_driver (optional) |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 40 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | struct ccwgroup_driver { |
Sebastian Ott | f2962da | 2012-05-15 17:49:12 +0200 | [diff] [blame] | 42 | int (*setup) (struct ccwgroup_device *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | void (*remove) (struct ccwgroup_device *); |
| 44 | int (*set_online) (struct ccwgroup_device *); |
| 45 | int (*set_offline) (struct ccwgroup_device *); |
Cornelia Huck | 01bc8ad | 2008-02-05 16:50:36 +0100 | [diff] [blame] | 46 | void (*shutdown)(struct ccwgroup_device *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 48 | struct device_driver driver; |
Julian Wiedmann | f9a5d70 | 2017-09-14 09:52:32 +0200 | [diff] [blame] | 49 | struct ccw_driver *ccw_driver; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | extern int ccwgroup_driver_register (struct ccwgroup_driver *cdriver); |
| 53 | extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver); |
Sebastian Ott | 9814fdf | 2012-05-15 18:03:46 +0200 | [diff] [blame] | 54 | int ccwgroup_create_dev(struct device *root, struct ccwgroup_driver *gdrv, |
| 55 | int num_devices, const char *buf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
Sebastian Ott | 683c3dc | 2012-11-22 15:56:39 +0100 | [diff] [blame] | 57 | extern int ccwgroup_set_online(struct ccwgroup_device *gdev); |
Alexandra Winter | d2b59bd | 2021-09-21 16:52:17 +0200 | [diff] [blame] | 58 | int ccwgroup_set_offline(struct ccwgroup_device *gdev, bool call_gdrv); |
Sebastian Ott | 683c3dc | 2012-11-22 15:56:39 +0100 | [diff] [blame] | 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev); |
| 61 | extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev); |
| 62 | |
| 63 | #define to_ccwgroupdev(x) container_of((x), struct ccwgroup_device, dev) |
| 64 | #define to_ccwgroupdrv(x) container_of((x), struct ccwgroup_driver, driver) |
Sebastian Ott | a166c36 | 2017-02-15 11:45:07 +0100 | [diff] [blame] | 65 | |
| 66 | #if IS_ENABLED(CONFIG_CCWGROUP) |
| 67 | bool dev_is_ccwgroup(struct device *dev); |
| 68 | #else /* CONFIG_CCWGROUP */ |
| 69 | static inline bool dev_is_ccwgroup(struct device *dev) |
| 70 | { |
| 71 | return false; |
| 72 | } |
| 73 | #endif /* CONFIG_CCWGROUP */ |
| 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | #endif |