xref: /linux/arch/s390/include/asm/ccwgroup.h (revision 0526b56cbc3c489642bd6a5fe4b718dea7ef0ee8)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef S390_CCWGROUP_H
3 #define S390_CCWGROUP_H
4 
5 struct ccw_device;
6 struct ccw_driver;
7 
8 /**
9  * struct ccwgroup_device - ccw group device
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
14  * @ungroup_work: used to ungroup the ccwgroup device
15  */
16 struct ccwgroup_device {
17 	enum {
18 		CCWGROUP_OFFLINE,
19 		CCWGROUP_ONLINE,
20 	} state;
21 /* private: */
22 	atomic_t onoff;
23 	struct mutex reg_mutex;
24 /* public: */
25 	unsigned int count;
26 	struct device	dev;
27 	struct work_struct ungroup_work;
28 	struct ccw_device *cdev[];
29 };
30 
31 /**
32  * struct ccwgroup_driver - driver for ccw group devices
33  * @setup: function called during device creation to setup the device
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
37  * @shutdown: function called when device is shut down
38  * @driver: embedded driver structure
39  * @ccw_driver: supported ccw_driver (optional)
40  */
41 struct ccwgroup_driver {
42 	int (*setup) (struct ccwgroup_device *);
43 	void (*remove) (struct ccwgroup_device *);
44 	int (*set_online) (struct ccwgroup_device *);
45 	int (*set_offline) (struct ccwgroup_device *);
46 	void (*shutdown)(struct ccwgroup_device *);
47 
48 	struct device_driver driver;
49 	struct ccw_driver *ccw_driver;
50 };
51 
52 extern int  ccwgroup_driver_register   (struct ccwgroup_driver *cdriver);
53 extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver);
54 int ccwgroup_create_dev(struct device *root, struct ccwgroup_driver *gdrv,
55 			int num_devices, const char *buf);
56 
57 extern int ccwgroup_set_online(struct ccwgroup_device *gdev);
58 int ccwgroup_set_offline(struct ccwgroup_device *gdev, bool call_gdrv);
59 
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)
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 
75 #endif
76