xref: /openbmc/linux/arch/s390/include/asm/ccwgroup.h (revision 8730046c)
1 #ifndef S390_CCWGROUP_H
2 #define S390_CCWGROUP_H
3 
4 struct ccw_device;
5 struct ccw_driver;
6 
7 /**
8  * struct ccwgroup_device - ccw group device
9  * @state: online/offline state
10  * @count: number of attached slave devices
11  * @dev: embedded device structure
12  * @cdev: variable number of slave devices, allocated as needed
13  * @ungroup_work: work to be done when a ccwgroup notifier has action
14  *	type %BUS_NOTIFY_UNBIND_DRIVER
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[0];
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  * @prepare: prepare for pm state transition
39  * @complete: undo work done in @prepare
40  * @freeze: callback for freezing during hibernation snapshotting
41  * @thaw: undo work done in @freeze
42  * @restore: callback for restoring after hibernation
43  * @driver: embedded driver structure
44  */
45 struct ccwgroup_driver {
46 	int (*setup) (struct ccwgroup_device *);
47 	void (*remove) (struct ccwgroup_device *);
48 	int (*set_online) (struct ccwgroup_device *);
49 	int (*set_offline) (struct ccwgroup_device *);
50 	void (*shutdown)(struct ccwgroup_device *);
51 	int (*prepare) (struct ccwgroup_device *);
52 	void (*complete) (struct ccwgroup_device *);
53 	int (*freeze)(struct ccwgroup_device *);
54 	int (*thaw) (struct ccwgroup_device *);
55 	int (*restore)(struct ccwgroup_device *);
56 
57 	struct device_driver driver;
58 };
59 
60 extern int  ccwgroup_driver_register   (struct ccwgroup_driver *cdriver);
61 extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver);
62 int ccwgroup_create_dev(struct device *root, struct ccwgroup_driver *gdrv,
63 			int num_devices, const char *buf);
64 
65 extern int ccwgroup_set_online(struct ccwgroup_device *gdev);
66 extern int ccwgroup_set_offline(struct ccwgroup_device *gdev);
67 
68 extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
69 extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev);
70 
71 #define to_ccwgroupdev(x) container_of((x), struct ccwgroup_device, dev)
72 #define to_ccwgroupdrv(x) container_of((x), struct ccwgroup_driver, driver)
73 #endif
74