diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2013-01-08 09:31:11 -0500 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2013-02-14 09:55:02 -0500 |
commit | c95571e68086d36e8e3369597b03ec29c63abec9 (patch) | |
tree | 20cb4b0f1f9bbf49375ab6a6458668fd726f6841 /drivers/s390/char/raw3270.c | |
parent | 57985d7e1e48f16548aa6904264e21bca15af0fc (diff) |
s390/3270: introduce device notifier
Add a notifier to create / destroy the device nodes for the tty view
and the fullscreen view. Only device nodes for online devices are
created and the device names will follow the convention as outlined
in Documentation/devices.txt: 3270/tty<x> for the tty nodes,
3270/tub<x> for hte fullscreen nodes and 3270/tub for the fullscreen
control node.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/char/raw3270.c')
-rw-r--r-- | drivers/s390/char/raw3270.c | 76 |
1 files changed, 15 insertions, 61 deletions
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c index 9a6c140c5f07..72f69fda9d01 100644 --- a/drivers/s390/char/raw3270.c +++ b/drivers/s390/char/raw3270.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/device.h> | 28 | #include <linux/device.h> |
29 | #include <linux/mutex.h> | 29 | #include <linux/mutex.h> |
30 | 30 | ||
31 | static struct class *class3270; | 31 | struct class *class3270; |
32 | 32 | ||
33 | /* The main 3270 data structure. */ | 33 | /* The main 3270 data structure. */ |
34 | struct raw3270 { | 34 | struct raw3270 { |
@@ -46,8 +46,6 @@ struct raw3270 { | |||
46 | struct timer_list timer; /* Device timer. */ | 46 | struct timer_list timer; /* Device timer. */ |
47 | 47 | ||
48 | unsigned char *ascebc; /* ascii -> ebcdic table */ | 48 | unsigned char *ascebc; /* ascii -> ebcdic table */ |
49 | struct device *clttydev; /* 3270-class tty device ptr */ | ||
50 | struct device *cltubdev; /* 3270-class tub device ptr */ | ||
51 | 49 | ||
52 | struct raw3270_request init_request; | 50 | struct raw3270_request init_request; |
53 | unsigned char init_data[256]; | 51 | unsigned char init_data[256]; |
@@ -1072,10 +1070,6 @@ raw3270_delete_device(struct raw3270 *rp) | |||
1072 | 1070 | ||
1073 | /* Remove from device chain. */ | 1071 | /* Remove from device chain. */ |
1074 | mutex_lock(&raw3270_mutex); | 1072 | mutex_lock(&raw3270_mutex); |
1075 | if (rp->clttydev && !IS_ERR(rp->clttydev)) | ||
1076 | device_destroy(class3270, MKDEV(IBM_TTY3270_MAJOR, rp->minor)); | ||
1077 | if (rp->cltubdev && !IS_ERR(rp->cltubdev)) | ||
1078 | device_destroy(class3270, MKDEV(IBM_FS3270_MAJOR, rp->minor)); | ||
1079 | list_del_init(&rp->list); | 1073 | list_del_init(&rp->list); |
1080 | mutex_unlock(&raw3270_mutex); | 1074 | mutex_unlock(&raw3270_mutex); |
1081 | 1075 | ||
@@ -1139,75 +1133,34 @@ static struct attribute_group raw3270_attr_group = { | |||
1139 | 1133 | ||
1140 | static int raw3270_create_attributes(struct raw3270 *rp) | 1134 | static int raw3270_create_attributes(struct raw3270 *rp) |
1141 | { | 1135 | { |
1142 | int rc; | 1136 | return sysfs_create_group(&rp->cdev->dev.kobj, &raw3270_attr_group); |
1143 | |||
1144 | rc = sysfs_create_group(&rp->cdev->dev.kobj, &raw3270_attr_group); | ||
1145 | if (rc) | ||
1146 | goto out; | ||
1147 | |||
1148 | rp->clttydev = device_create(class3270, &rp->cdev->dev, | ||
1149 | MKDEV(IBM_TTY3270_MAJOR, rp->minor), NULL, | ||
1150 | "tty%s", dev_name(&rp->cdev->dev)); | ||
1151 | if (IS_ERR(rp->clttydev)) { | ||
1152 | rc = PTR_ERR(rp->clttydev); | ||
1153 | goto out_ttydev; | ||
1154 | } | ||
1155 | |||
1156 | rp->cltubdev = device_create(class3270, &rp->cdev->dev, | ||
1157 | MKDEV(IBM_FS3270_MAJOR, rp->minor), NULL, | ||
1158 | "tub%s", dev_name(&rp->cdev->dev)); | ||
1159 | if (!IS_ERR(rp->cltubdev)) | ||
1160 | goto out; | ||
1161 | |||
1162 | rc = PTR_ERR(rp->cltubdev); | ||
1163 | device_destroy(class3270, MKDEV(IBM_TTY3270_MAJOR, rp->minor)); | ||
1164 | |||
1165 | out_ttydev: | ||
1166 | sysfs_remove_group(&rp->cdev->dev.kobj, &raw3270_attr_group); | ||
1167 | out: | ||
1168 | return rc; | ||
1169 | } | 1137 | } |
1170 | 1138 | ||
1171 | /* | 1139 | /* |
1172 | * Notifier for device addition/removal | 1140 | * Notifier for device addition/removal |
1173 | */ | 1141 | */ |
1174 | struct raw3270_notifier { | ||
1175 | struct list_head list; | ||
1176 | void (*notifier)(int, int); | ||
1177 | }; | ||
1178 | |||
1179 | static LIST_HEAD(raw3270_notifier); | 1142 | static LIST_HEAD(raw3270_notifier); |
1180 | 1143 | ||
1181 | int raw3270_register_notifier(void (*notifier)(int, int)) | 1144 | int raw3270_register_notifier(struct raw3270_notifier *notifier) |
1182 | { | 1145 | { |
1183 | struct raw3270_notifier *np; | ||
1184 | struct raw3270 *rp; | 1146 | struct raw3270 *rp; |
1185 | 1147 | ||
1186 | np = kmalloc(sizeof(struct raw3270_notifier), GFP_KERNEL); | ||
1187 | if (!np) | ||
1188 | return -ENOMEM; | ||
1189 | np->notifier = notifier; | ||
1190 | mutex_lock(&raw3270_mutex); | 1148 | mutex_lock(&raw3270_mutex); |
1191 | list_add_tail(&np->list, &raw3270_notifier); | 1149 | list_add_tail(¬ifier->list, &raw3270_notifier); |
1192 | list_for_each_entry(rp, &raw3270_devices, list) { | 1150 | list_for_each_entry(rp, &raw3270_devices, list) |
1193 | get_device(&rp->cdev->dev); | 1151 | notifier->create(rp->minor); |
1194 | notifier(rp->minor, 1); | ||
1195 | } | ||
1196 | mutex_unlock(&raw3270_mutex); | 1152 | mutex_unlock(&raw3270_mutex); |
1197 | return 0; | 1153 | return 0; |
1198 | } | 1154 | } |
1199 | 1155 | ||
1200 | void raw3270_unregister_notifier(void (*notifier)(int, int)) | 1156 | void raw3270_unregister_notifier(struct raw3270_notifier *notifier) |
1201 | { | 1157 | { |
1202 | struct raw3270_notifier *np; | 1158 | struct raw3270 *rp; |
1203 | 1159 | ||
1204 | mutex_lock(&raw3270_mutex); | 1160 | mutex_lock(&raw3270_mutex); |
1205 | list_for_each_entry(np, &raw3270_notifier, list) | 1161 | list_for_each_entry(rp, &raw3270_devices, list) |
1206 | if (np->notifier == notifier) { | 1162 | notifier->destroy(rp->minor); |
1207 | list_del(&np->list); | 1163 | list_del(¬ifier->list); |
1208 | kfree(np); | ||
1209 | break; | ||
1210 | } | ||
1211 | mutex_unlock(&raw3270_mutex); | 1164 | mutex_unlock(&raw3270_mutex); |
1212 | } | 1165 | } |
1213 | 1166 | ||
@@ -1217,8 +1170,8 @@ void raw3270_unregister_notifier(void (*notifier)(int, int)) | |||
1217 | static int | 1170 | static int |
1218 | raw3270_set_online (struct ccw_device *cdev) | 1171 | raw3270_set_online (struct ccw_device *cdev) |
1219 | { | 1172 | { |
1220 | struct raw3270 *rp; | ||
1221 | struct raw3270_notifier *np; | 1173 | struct raw3270_notifier *np; |
1174 | struct raw3270 *rp; | ||
1222 | int rc; | 1175 | int rc; |
1223 | 1176 | ||
1224 | rp = raw3270_create_device(cdev); | 1177 | rp = raw3270_create_device(cdev); |
@@ -1239,7 +1192,7 @@ raw3270_set_online (struct ccw_device *cdev) | |||
1239 | set_bit(RAW3270_FLAGS_READY, &rp->flags); | 1192 | set_bit(RAW3270_FLAGS_READY, &rp->flags); |
1240 | mutex_lock(&raw3270_mutex); | 1193 | mutex_lock(&raw3270_mutex); |
1241 | list_for_each_entry(np, &raw3270_notifier, list) | 1194 | list_for_each_entry(np, &raw3270_notifier, list) |
1242 | np->notifier(rp->minor, 1); | 1195 | np->create(rp->minor); |
1243 | mutex_unlock(&raw3270_mutex); | 1196 | mutex_unlock(&raw3270_mutex); |
1244 | return 0; | 1197 | return 0; |
1245 | 1198 | ||
@@ -1290,7 +1243,7 @@ raw3270_remove (struct ccw_device *cdev) | |||
1290 | 1243 | ||
1291 | mutex_lock(&raw3270_mutex); | 1244 | mutex_lock(&raw3270_mutex); |
1292 | list_for_each_entry(np, &raw3270_notifier, list) | 1245 | list_for_each_entry(np, &raw3270_notifier, list) |
1293 | np->notifier(rp->minor, 0); | 1246 | np->destroy(rp->minor); |
1294 | mutex_unlock(&raw3270_mutex); | 1247 | mutex_unlock(&raw3270_mutex); |
1295 | 1248 | ||
1296 | /* Reset 3270 device. */ | 1249 | /* Reset 3270 device. */ |
@@ -1434,6 +1387,7 @@ MODULE_LICENSE("GPL"); | |||
1434 | module_init(raw3270_init); | 1387 | module_init(raw3270_init); |
1435 | module_exit(raw3270_exit); | 1388 | module_exit(raw3270_exit); |
1436 | 1389 | ||
1390 | EXPORT_SYMBOL(class3270); | ||
1437 | EXPORT_SYMBOL(raw3270_request_alloc); | 1391 | EXPORT_SYMBOL(raw3270_request_alloc); |
1438 | EXPORT_SYMBOL(raw3270_request_free); | 1392 | EXPORT_SYMBOL(raw3270_request_free); |
1439 | EXPORT_SYMBOL(raw3270_request_reset); | 1393 | EXPORT_SYMBOL(raw3270_request_reset); |