xref: /openbmc/linux/arch/s390/include/asm/ccwgroup.h (revision 547840bd)
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: work to be done when a ccwgroup notifier has action
15  *	type %BUS_NOTIFY_UNBIND_DRIVER
16  */
17 struct ccwgroup_device {
18 	enum {
19 		CCWGROUP_OFFLINE,
20 		CCWGROUP_ONLINE,
21 	} state;
22 /* private: */
23 	atomic_t onoff;
24 	struct mutex reg_mutex;
25 /* public: */
26 	unsigned int count;
27 	struct device	dev;
28 	struct work_struct ungroup_work;
29 	struct ccw_device *cdev[0];
30 };
31 
32 /**
33  * struct ccwgroup_driver - driver for ccw group devices
34  * @setup: function called during device creation to setup the device
35  * @remove: function called on remove
36  * @set_online: function called when device is set online
37  * @set_offline: function called when device is set offline
38  * @shutdown: function called when device is shut down
39  * @driver: embedded driver structure
40  * @ccw_driver: supported ccw_driver (optional)
41  */
42 struct ccwgroup_driver {
43 	int (*setup) (struct ccwgroup_device *);
44 	void (*remove) (struct ccwgroup_device *);
45 	int (*set_online) (struct ccwgroup_device *);
46 	int (*set_offline) (struct ccwgroup_device *);
47 	void (*shutdown)(struct ccwgroup_device *);
48 
49 	struct device_driver driver;
50 	struct ccw_driver *ccw_driver;
51 };
52 
53 extern int  ccwgroup_driver_register   (struct ccwgroup_driver *cdriver);
54 extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver);
55 int ccwgroup_create_dev(struct device *root, struct ccwgroup_driver *gdrv,
56 			int num_devices, const char *buf);
57 struct ccwgroup_device *get_ccwgroupdev_by_busid(struct ccwgroup_driver *gdrv,
58 						 char *bus_id);
59 
60 extern int ccwgroup_set_online(struct ccwgroup_device *gdev);
61 extern int ccwgroup_set_offline(struct ccwgroup_device *gdev);
62 
63 extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
64 extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev);
65 
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 
69 #if IS_ENABLED(CONFIG_CCWGROUP)
70 bool dev_is_ccwgroup(struct device *dev);
71 #else /* CONFIG_CCWGROUP */
72 static inline bool dev_is_ccwgroup(struct device *dev)
73 {
74 	return false;
75 }
76 #endif /* CONFIG_CCWGROUP */
77 
78 #endif
79