blob: 057ce0ca6377dc3b28b775c3c1ca1797a8cbbf2c [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
Randy Dunlap0d234a22014-04-14 10:41:29 -070013 * @ungroup_work: work to be done when a ccwgroup notifier has action
14 * type %BUS_NOTIFY_UNBIND_DRIVER
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020015 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070016struct ccwgroup_device {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 enum {
18 CCWGROUP_OFFLINE,
19 CCWGROUP_ONLINE,
20 } state;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020021/* private: */
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 atomic_t onoff;
Cornelia Huckd76123e2007-04-27 16:01:37 +020023 struct mutex reg_mutex;
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020024/* public: */
25 unsigned int count;
26 struct device dev;
Tejun Heo0b60f9e2014-02-03 14:03:04 -050027 struct work_struct ungroup_work;
Christian Borntraeger0c8c77d2014-04-23 20:58:45 +020028 struct ccw_device *cdev[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -070029};
30
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020031/**
32 * struct ccwgroup_driver - driver for ccw group devices
Sebastian Ottf2962da2012-05-15 17:49:12 +020033 * @setup: function called during device creation to setup the device
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020034 * @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 Huck01bc8ad2008-02-05 16:50:36 +010037 * @shutdown: function called when device is shut down
Sebastian Ott7e597a22009-06-16 10:30:21 +020038 * @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
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020043 * @driver: embedded driver structure
44 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070045struct ccwgroup_driver {
Sebastian Ottf2962da2012-05-15 17:49:12 +020046 int (*setup) (struct ccwgroup_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 void (*remove) (struct ccwgroup_device *);
48 int (*set_online) (struct ccwgroup_device *);
49 int (*set_offline) (struct ccwgroup_device *);
Cornelia Huck01bc8ad2008-02-05 16:50:36 +010050 void (*shutdown)(struct ccwgroup_device *);
Sebastian Ott7e597a22009-06-16 10:30:21 +020051 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 *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020057 struct device_driver driver;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058};
59
60extern int ccwgroup_driver_register (struct ccwgroup_driver *cdriver);
61extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver);
Sebastian Ott9814fdf2012-05-15 18:03:46 +020062int ccwgroup_create_dev(struct device *root, struct ccwgroup_driver *gdrv,
63 int num_devices, const char *buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Sebastian Ott683c3dc2012-11-22 15:56:39 +010065extern int ccwgroup_set_online(struct ccwgroup_device *gdev);
66extern int ccwgroup_set_offline(struct ccwgroup_device *gdev);
67
Linus Torvalds1da177e2005-04-16 15:20:36 -070068extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
69extern 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