Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef S390_CCWGROUP_H |
| 2 | #define S390_CCWGROUP_H |
| 3 | |
| 4 | struct ccw_device; |
| 5 | struct ccw_driver; |
| 6 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 7 | /** |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | struct ccwgroup_device { |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 16 | unsigned long creator_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | enum { |
| 18 | CCWGROUP_OFFLINE, |
| 19 | CCWGROUP_ONLINE, |
| 20 | } state; |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 21 | /* private: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | atomic_t onoff; |
Cornelia Huck | d76123e | 2007-04-27 16:01:37 +0200 | [diff] [blame] | 23 | struct mutex reg_mutex; |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 24 | /* public: */ |
| 25 | unsigned int count; |
| 26 | struct device dev; |
| 27 | struct ccw_device *cdev[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | }; |
| 29 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 30 | /** |
| 31 | * struct ccwgroup_driver - driver for ccw group devices |
Sebastian Ott | f2962da | 2012-05-15 17:49:12 +0200 | [diff] [blame] | 32 | * @setup: function called during device creation to setup the device |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 33 | * @remove: function called on remove |
| 34 | * @set_online: function called when device is set online |
| 35 | * @set_offline: function called when device is set offline |
Cornelia Huck | 01bc8ad | 2008-02-05 16:50:36 +0100 | [diff] [blame] | 36 | * @shutdown: function called when device is shut down |
Sebastian Ott | 7e597a2 | 2009-06-16 10:30:21 +0200 | [diff] [blame] | 37 | * @prepare: prepare for pm state transition |
| 38 | * @complete: undo work done in @prepare |
| 39 | * @freeze: callback for freezing during hibernation snapshotting |
| 40 | * @thaw: undo work done in @freeze |
| 41 | * @restore: callback for restoring after hibernation |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 42 | * @driver: embedded driver structure |
| 43 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | struct ccwgroup_driver { |
Sebastian Ott | f2962da | 2012-05-15 17:49:12 +0200 | [diff] [blame] | 45 | int (*setup) (struct ccwgroup_device *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | void (*remove) (struct ccwgroup_device *); |
| 47 | int (*set_online) (struct ccwgroup_device *); |
| 48 | int (*set_offline) (struct ccwgroup_device *); |
Cornelia Huck | 01bc8ad | 2008-02-05 16:50:36 +0100 | [diff] [blame] | 49 | void (*shutdown)(struct ccwgroup_device *); |
Sebastian Ott | 7e597a2 | 2009-06-16 10:30:21 +0200 | [diff] [blame] | 50 | int (*prepare) (struct ccwgroup_device *); |
| 51 | void (*complete) (struct ccwgroup_device *); |
| 52 | int (*freeze)(struct ccwgroup_device *); |
| 53 | int (*thaw) (struct ccwgroup_device *); |
| 54 | int (*restore)(struct ccwgroup_device *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 56 | struct device_driver driver; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | extern int ccwgroup_driver_register (struct ccwgroup_driver *cdriver); |
| 60 | extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver); |
Sebastian Ott | 9814fdf | 2012-05-15 18:03:46 +0200 | [diff] [blame] | 61 | int ccwgroup_create_dev(struct device *root, struct ccwgroup_driver *gdrv, |
| 62 | int num_devices, const char *buf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev); |
| 65 | extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev); |
| 66 | |
| 67 | #define to_ccwgroupdev(x) container_of((x), struct ccwgroup_device, dev) |
| 68 | #define to_ccwgroupdrv(x) container_of((x), struct ccwgroup_driver, driver) |
| 69 | #endif |