blob: aa995d91cd1da451e2915ad29031f0141e171a5d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef S390_CCWGROUP_H
3#define S390_CCWGROUP_H
4
5struct ccw_device;
6struct ccw_driver;
7
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +02008/**
9 * struct ccwgroup_device - ccw group device
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020010 * @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
Julian Wiedmann17c0b862021-05-05 10:28:21 +020014 * @ungroup_work: used to ungroup the ccwgroup device
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
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020038 * @driver: embedded driver structure
Julian Wiedmannf9a5d702017-09-14 09:52:32 +020039 * @ccw_driver: supported ccw_driver (optional)
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020040 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070041struct ccwgroup_driver {
Sebastian Ottf2962da2012-05-15 17:49:12 +020042 int (*setup) (struct ccwgroup_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 void (*remove) (struct ccwgroup_device *);
44 int (*set_online) (struct ccwgroup_device *);
45 int (*set_offline) (struct ccwgroup_device *);
Cornelia Huck01bc8ad2008-02-05 16:50:36 +010046 void (*shutdown)(struct ccwgroup_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +020048 struct device_driver driver;
Julian Wiedmannf9a5d702017-09-14 09:52:32 +020049 struct ccw_driver *ccw_driver;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050};
51
52extern int ccwgroup_driver_register (struct ccwgroup_driver *cdriver);
53extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver);
Sebastian Ott9814fdf2012-05-15 18:03:46 +020054int ccwgroup_create_dev(struct device *root, struct ccwgroup_driver *gdrv,
55 int num_devices, const char *buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Sebastian Ott683c3dc2012-11-22 15:56:39 +010057extern int ccwgroup_set_online(struct ccwgroup_device *gdev);
Alexandra Winterd2b59bd2021-09-21 16:52:17 +020058int ccwgroup_set_offline(struct ccwgroup_device *gdev, bool call_gdrv);
Sebastian Ott683c3dc2012-11-22 15:56:39 +010059
Linus Torvalds1da177e2005-04-16 15:20:36 -070060extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
61extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev);
62
63#define to_ccwgroupdev(x) container_of((x), struct ccwgroup_device, dev)
64#define to_ccwgroupdrv(x) container_of((x), struct ccwgroup_driver, driver)
Sebastian Otta166c362017-02-15 11:45:07 +010065
66#if IS_ENABLED(CONFIG_CCWGROUP)
67bool dev_is_ccwgroup(struct device *dev);
68#else /* CONFIG_CCWGROUP */
69static inline bool dev_is_ccwgroup(struct device *dev)
70{
71 return false;
72}
73#endif /* CONFIG_CCWGROUP */
74
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#endif