blob: f2ea2c56a7e18866d2775513df1e2f3f48d5b0e7 [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
9 * @creator_id: unique number of the driver
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070015struct ccwgroup_device {
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020016 unsigned long creator_id;
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;
27 struct ccw_device *cdev[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -070028};
29
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020030/**
31 * struct ccwgroup_driver - driver for ccw group devices
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020032 * @max_slaves: maximum number of slave devices
33 * @driver_id: unique id
34 * @probe: function called on probe
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
Cornelia Huck01bc8ad2008-02-05 16:50:36 +010038 * @shutdown: function called when device is shut down
Sebastian Ott7e597a22009-06-16 10:30:21 +020039 * @prepare: prepare for pm state transition
40 * @complete: undo work done in @prepare
41 * @freeze: callback for freezing during hibernation snapshotting
42 * @thaw: undo work done in @freeze
43 * @restore: callback for restoring after hibernation
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020044 * @driver: embedded driver structure
45 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070046struct ccwgroup_driver {
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 int max_slaves;
48 unsigned long driver_id;
49
50 int (*probe) (struct ccwgroup_device *);
51 void (*remove) (struct ccwgroup_device *);
52 int (*set_online) (struct ccwgroup_device *);
53 int (*set_offline) (struct ccwgroup_device *);
Cornelia Huck01bc8ad2008-02-05 16:50:36 +010054 void (*shutdown)(struct ccwgroup_device *);
Sebastian Ott7e597a22009-06-16 10:30:21 +020055 int (*prepare) (struct ccwgroup_device *);
56 void (*complete) (struct ccwgroup_device *);
57 int (*freeze)(struct ccwgroup_device *);
58 int (*thaw) (struct ccwgroup_device *);
59 int (*restore)(struct ccwgroup_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020061 struct device_driver driver;
Linus Torvalds1da177e2005-04-16 15:20:36 -070062};
63
64extern int ccwgroup_driver_register (struct ccwgroup_driver *cdriver);
65extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver);
Ursula Braun022b6602008-04-24 10:15:20 +020066int ccwgroup_create_from_string(struct device *root, unsigned int creator_id,
67 struct ccw_driver *cdrv, int num_devices,
68 const char *buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
71extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev);
72
73#define to_ccwgroupdev(x) container_of((x), struct ccwgroup_device, dev)
74#define to_ccwgroupdrv(x) container_of((x), struct ccwgroup_driver, driver)
75#endif