blob: 6e670f88d125d79fd2108575a6f6509e74985678 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef S390_CCWGROUP_H
2#define S390_CCWGROUP_H
3
4struct ccw_device;
5struct ccw_driver;
6
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +02007/**
8 * struct ccwgroup_device - ccw group device
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +02009 * @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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070014struct ccwgroup_device {
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 enum {
16 CCWGROUP_OFFLINE,
17 CCWGROUP_ONLINE,
18 } state;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020019/* private: */
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 atomic_t onoff;
Cornelia Huckd76123e2007-04-27 16:01:37 +020021 struct mutex reg_mutex;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020022/* public: */
23 unsigned int count;
24 struct device dev;
25 struct ccw_device *cdev[0];
Tejun Heo0b60f9e2014-02-03 14:03:04 -050026 struct work_struct ungroup_work;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027};
28
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020029/**
30 * struct ccwgroup_driver - driver for ccw group devices
Sebastian Ottf2962da2012-05-15 17:49:12 +020031 * @setup: function called during device creation to setup the device
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020032 * @remove: function called on remove
33 * @set_online: function called when device is set online
34 * @set_offline: function called when device is set offline
Cornelia Huck01bc8ad2008-02-05 16:50:36 +010035 * @shutdown: function called when device is shut down
Sebastian Ott7e597a22009-06-16 10:30:21 +020036 * @prepare: prepare for pm state transition
37 * @complete: undo work done in @prepare
38 * @freeze: callback for freezing during hibernation snapshotting
39 * @thaw: undo work done in @freeze
40 * @restore: callback for restoring after hibernation
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020041 * @driver: embedded driver structure
42 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070043struct ccwgroup_driver {
Sebastian Ottf2962da2012-05-15 17:49:12 +020044 int (*setup) (struct ccwgroup_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 void (*remove) (struct ccwgroup_device *);
46 int (*set_online) (struct ccwgroup_device *);
47 int (*set_offline) (struct ccwgroup_device *);
Cornelia Huck01bc8ad2008-02-05 16:50:36 +010048 void (*shutdown)(struct ccwgroup_device *);
Sebastian Ott7e597a22009-06-16 10:30:21 +020049 int (*prepare) (struct ccwgroup_device *);
50 void (*complete) (struct ccwgroup_device *);
51 int (*freeze)(struct ccwgroup_device *);
52 int (*thaw) (struct ccwgroup_device *);
53 int (*restore)(struct ccwgroup_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020055 struct device_driver driver;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056};
57
58extern int ccwgroup_driver_register (struct ccwgroup_driver *cdriver);
59extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver);
Sebastian Ott9814fdf2012-05-15 18:03:46 +020060int ccwgroup_create_dev(struct device *root, struct ccwgroup_driver *gdrv,
61 int num_devices, const char *buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Sebastian Ott683c3dc2012-11-22 15:56:39 +010063extern int ccwgroup_set_online(struct ccwgroup_device *gdev);
64extern int ccwgroup_set_offline(struct ccwgroup_device *gdev);
65
Linus Torvalds1da177e2005-04-16 15:20:36 -070066extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
67extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev);
68
69#define to_ccwgroupdev(x) container_of((x), struct ccwgroup_device, dev)
70#define to_ccwgroupdrv(x) container_of((x), struct ccwgroup_driver, driver)
71#endif