diff options
Diffstat (limited to 'drivers/s390/char')
-rw-r--r-- | drivers/s390/char/monreader.c | 218 |
1 files changed, 101 insertions, 117 deletions
diff --git a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c index a138b1510093..3a1a958fb5f2 100644 --- a/drivers/s390/char/monreader.c +++ b/drivers/s390/char/monreader.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Character device driver for reading z/VM *MONITOR service records. | 4 | * Character device driver for reading z/VM *MONITOR service records. |
5 | * | 5 | * |
6 | * Copyright (C) 2004 IBM Corporation, IBM Deutschland Entwicklung GmbH. | 6 | * Copyright 2004 IBM Corporation, IBM Deutschland Entwicklung GmbH. |
7 | * | 7 | * |
8 | * Author: Gerald Schaefer <geraldsc@de.ibm.com> | 8 | * Author: Gerald Schaefer <geraldsc@de.ibm.com> |
9 | */ | 9 | */ |
@@ -22,7 +22,7 @@ | |||
22 | #include <asm/ebcdic.h> | 22 | #include <asm/ebcdic.h> |
23 | #include <asm/extmem.h> | 23 | #include <asm/extmem.h> |
24 | #include <linux/poll.h> | 24 | #include <linux/poll.h> |
25 | #include "../net/iucv.h" | 25 | #include <net/iucv/iucv.h> |
26 | 26 | ||
27 | 27 | ||
28 | //#define MON_DEBUG /* Debug messages on/off */ | 28 | //#define MON_DEBUG /* Debug messages on/off */ |
@@ -50,14 +50,13 @@ static char mon_dcss_name[9] = "MONDCSS\0"; | |||
50 | struct mon_msg { | 50 | struct mon_msg { |
51 | u32 pos; | 51 | u32 pos; |
52 | u32 mca_offset; | 52 | u32 mca_offset; |
53 | iucv_MessagePending local_eib; | 53 | struct iucv_message msg; |
54 | char msglim_reached; | 54 | char msglim_reached; |
55 | char replied_msglim; | 55 | char replied_msglim; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | struct mon_private { | 58 | struct mon_private { |
59 | u16 pathid; | 59 | struct iucv_path *path; |
60 | iucv_handle_t iucv_handle; | ||
61 | struct mon_msg *msg_array[MON_MSGLIM]; | 60 | struct mon_msg *msg_array[MON_MSGLIM]; |
62 | unsigned int write_index; | 61 | unsigned int write_index; |
63 | unsigned int read_index; | 62 | unsigned int read_index; |
@@ -75,8 +74,6 @@ static unsigned long mon_dcss_end; | |||
75 | static DECLARE_WAIT_QUEUE_HEAD(mon_read_wait_queue); | 74 | static DECLARE_WAIT_QUEUE_HEAD(mon_read_wait_queue); |
76 | static DECLARE_WAIT_QUEUE_HEAD(mon_conn_wait_queue); | 75 | static DECLARE_WAIT_QUEUE_HEAD(mon_conn_wait_queue); |
77 | 76 | ||
78 | static u8 iucv_host[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | ||
79 | |||
80 | static u8 user_data_connect[16] = { | 77 | static u8 user_data_connect[16] = { |
81 | /* Version code, must be 0x01 for shared mode */ | 78 | /* Version code, must be 0x01 for shared mode */ |
82 | 0x01, | 79 | 0x01, |
@@ -100,8 +97,7 @@ static u8 user_data_sever[16] = { | |||
100 | * Create the 8 bytes EBCDIC DCSS segment name from | 97 | * Create the 8 bytes EBCDIC DCSS segment name from |
101 | * an ASCII name, incl. padding | 98 | * an ASCII name, incl. padding |
102 | */ | 99 | */ |
103 | static inline void | 100 | static inline void dcss_mkname(char *ascii_name, char *ebcdic_name) |
104 | dcss_mkname(char *ascii_name, char *ebcdic_name) | ||
105 | { | 101 | { |
106 | int i; | 102 | int i; |
107 | 103 | ||
@@ -119,8 +115,7 @@ dcss_mkname(char *ascii_name, char *ebcdic_name) | |||
119 | * print appropriate error message for segment_load()/segment_type() | 115 | * print appropriate error message for segment_load()/segment_type() |
120 | * return code | 116 | * return code |
121 | */ | 117 | */ |
122 | static void | 118 | static void mon_segment_warn(int rc, char* seg_name) |
123 | mon_segment_warn(int rc, char* seg_name) | ||
124 | { | 119 | { |
125 | switch (rc) { | 120 | switch (rc) { |
126 | case -ENOENT: | 121 | case -ENOENT: |
@@ -166,44 +161,37 @@ mon_segment_warn(int rc, char* seg_name) | |||
166 | } | 161 | } |
167 | } | 162 | } |
168 | 163 | ||
169 | static inline unsigned long | 164 | static inline unsigned long mon_mca_start(struct mon_msg *monmsg) |
170 | mon_mca_start(struct mon_msg *monmsg) | ||
171 | { | 165 | { |
172 | return monmsg->local_eib.ln1msg1.iprmmsg1_u32; | 166 | return *(u32 *) &monmsg->msg.rmmsg; |
173 | } | 167 | } |
174 | 168 | ||
175 | static inline unsigned long | 169 | static inline unsigned long mon_mca_end(struct mon_msg *monmsg) |
176 | mon_mca_end(struct mon_msg *monmsg) | ||
177 | { | 170 | { |
178 | return monmsg->local_eib.ln1msg2.ipbfln1f; | 171 | return *(u32 *) &monmsg->msg.rmmsg[4]; |
179 | } | 172 | } |
180 | 173 | ||
181 | static inline u8 | 174 | static inline u8 mon_mca_type(struct mon_msg *monmsg, u8 index) |
182 | mon_mca_type(struct mon_msg *monmsg, u8 index) | ||
183 | { | 175 | { |
184 | return *((u8 *) mon_mca_start(monmsg) + monmsg->mca_offset + index); | 176 | return *((u8 *) mon_mca_start(monmsg) + monmsg->mca_offset + index); |
185 | } | 177 | } |
186 | 178 | ||
187 | static inline u32 | 179 | static inline u32 mon_mca_size(struct mon_msg *monmsg) |
188 | mon_mca_size(struct mon_msg *monmsg) | ||
189 | { | 180 | { |
190 | return mon_mca_end(monmsg) - mon_mca_start(monmsg) + 1; | 181 | return mon_mca_end(monmsg) - mon_mca_start(monmsg) + 1; |
191 | } | 182 | } |
192 | 183 | ||
193 | static inline u32 | 184 | static inline u32 mon_rec_start(struct mon_msg *monmsg) |
194 | mon_rec_start(struct mon_msg *monmsg) | ||
195 | { | 185 | { |
196 | return *((u32 *) (mon_mca_start(monmsg) + monmsg->mca_offset + 4)); | 186 | return *((u32 *) (mon_mca_start(monmsg) + monmsg->mca_offset + 4)); |
197 | } | 187 | } |
198 | 188 | ||
199 | static inline u32 | 189 | static inline u32 mon_rec_end(struct mon_msg *monmsg) |
200 | mon_rec_end(struct mon_msg *monmsg) | ||
201 | { | 190 | { |
202 | return *((u32 *) (mon_mca_start(monmsg) + monmsg->mca_offset + 8)); | 191 | return *((u32 *) (mon_mca_start(monmsg) + monmsg->mca_offset + 8)); |
203 | } | 192 | } |
204 | 193 | ||
205 | static inline int | 194 | static inline int mon_check_mca(struct mon_msg *monmsg) |
206 | mon_check_mca(struct mon_msg *monmsg) | ||
207 | { | 195 | { |
208 | if ((mon_rec_end(monmsg) <= mon_rec_start(monmsg)) || | 196 | if ((mon_rec_end(monmsg) <= mon_rec_start(monmsg)) || |
209 | (mon_rec_start(monmsg) < mon_dcss_start) || | 197 | (mon_rec_start(monmsg) < mon_dcss_start) || |
@@ -221,20 +209,17 @@ mon_check_mca(struct mon_msg *monmsg) | |||
221 | return 0; | 209 | return 0; |
222 | } | 210 | } |
223 | 211 | ||
224 | static inline int | 212 | static inline int mon_send_reply(struct mon_msg *monmsg, |
225 | mon_send_reply(struct mon_msg *monmsg, struct mon_private *monpriv) | 213 | struct mon_private *monpriv) |
226 | { | 214 | { |
227 | u8 prmmsg[8]; | ||
228 | int rc; | 215 | int rc; |
229 | 216 | ||
230 | P_DEBUG("read, REPLY: pathid = 0x%04X, msgid = 0x%08X, trgcls = " | 217 | P_DEBUG("read, REPLY: pathid = 0x%04X, msgid = 0x%08X, trgcls = " |
231 | "0x%08X\n\n", | 218 | "0x%08X\n\n", |
232 | monmsg->local_eib.ippathid, monmsg->local_eib.ipmsgid, | 219 | monpriv->path->pathid, monmsg->msg.id, monmsg->msg.class); |
233 | monmsg->local_eib.iptrgcls); | 220 | |
234 | rc = iucv_reply_prmmsg(monmsg->local_eib.ippathid, | 221 | rc = iucv_message_reply(monpriv->path, &monmsg->msg, |
235 | monmsg->local_eib.ipmsgid, | 222 | IUCV_IPRMDATA, NULL, 0); |
236 | monmsg->local_eib.iptrgcls, | ||
237 | 0, prmmsg); | ||
238 | atomic_dec(&monpriv->msglim_count); | 223 | atomic_dec(&monpriv->msglim_count); |
239 | if (likely(!monmsg->msglim_reached)) { | 224 | if (likely(!monmsg->msglim_reached)) { |
240 | monmsg->pos = 0; | 225 | monmsg->pos = 0; |
@@ -251,10 +236,19 @@ mon_send_reply(struct mon_msg *monmsg, struct mon_private *monpriv) | |||
251 | return 0; | 236 | return 0; |
252 | } | 237 | } |
253 | 238 | ||
254 | static inline struct mon_private * | 239 | static inline void mon_free_mem(struct mon_private *monpriv) |
255 | mon_alloc_mem(void) | 240 | { |
241 | int i; | ||
242 | |||
243 | for (i = 0; i < MON_MSGLIM; i++) | ||
244 | if (monpriv->msg_array[i]) | ||
245 | kfree(monpriv->msg_array[i]); | ||
246 | kfree(monpriv); | ||
247 | } | ||
248 | |||
249 | static inline struct mon_private *mon_alloc_mem(void) | ||
256 | { | 250 | { |
257 | int i,j; | 251 | int i; |
258 | struct mon_private *monpriv; | 252 | struct mon_private *monpriv; |
259 | 253 | ||
260 | monpriv = kzalloc(sizeof(struct mon_private), GFP_KERNEL); | 254 | monpriv = kzalloc(sizeof(struct mon_private), GFP_KERNEL); |
@@ -267,16 +261,15 @@ mon_alloc_mem(void) | |||
267 | GFP_KERNEL); | 261 | GFP_KERNEL); |
268 | if (!monpriv->msg_array[i]) { | 262 | if (!monpriv->msg_array[i]) { |
269 | P_ERROR("open, no memory for msg_array\n"); | 263 | P_ERROR("open, no memory for msg_array\n"); |
270 | for (j = 0; j < i; j++) | 264 | mon_free_mem(monpriv); |
271 | kfree(monpriv->msg_array[j]); | ||
272 | return NULL; | 265 | return NULL; |
273 | } | 266 | } |
274 | } | 267 | } |
275 | return monpriv; | 268 | return monpriv; |
276 | } | 269 | } |
277 | 270 | ||
278 | static inline void | 271 | static inline void mon_read_debug(struct mon_msg *monmsg, |
279 | mon_read_debug(struct mon_msg *monmsg, struct mon_private *monpriv) | 272 | struct mon_private *monpriv) |
280 | { | 273 | { |
281 | #ifdef MON_DEBUG | 274 | #ifdef MON_DEBUG |
282 | u8 msg_type[2], mca_type; | 275 | u8 msg_type[2], mca_type; |
@@ -284,7 +277,7 @@ mon_read_debug(struct mon_msg *monmsg, struct mon_private *monpriv) | |||
284 | 277 | ||
285 | records_len = mon_rec_end(monmsg) - mon_rec_start(monmsg) + 1; | 278 | records_len = mon_rec_end(monmsg) - mon_rec_start(monmsg) + 1; |
286 | 279 | ||
287 | memcpy(msg_type, &monmsg->local_eib.iptrgcls, 2); | 280 | memcpy(msg_type, &monmsg->msg.class, 2); |
288 | EBCASC(msg_type, 2); | 281 | EBCASC(msg_type, 2); |
289 | mca_type = mon_mca_type(monmsg, 0); | 282 | mca_type = mon_mca_type(monmsg, 0); |
290 | EBCASC(&mca_type, 1); | 283 | EBCASC(&mca_type, 1); |
@@ -292,8 +285,7 @@ mon_read_debug(struct mon_msg *monmsg, struct mon_private *monpriv) | |||
292 | P_DEBUG("read, mon_read_index = %i, mon_write_index = %i\n", | 285 | P_DEBUG("read, mon_read_index = %i, mon_write_index = %i\n", |
293 | monpriv->read_index, monpriv->write_index); | 286 | monpriv->read_index, monpriv->write_index); |
294 | P_DEBUG("read, pathid = 0x%04X, msgid = 0x%08X, trgcls = 0x%08X\n", | 287 | P_DEBUG("read, pathid = 0x%04X, msgid = 0x%08X, trgcls = 0x%08X\n", |
295 | monmsg->local_eib.ippathid, monmsg->local_eib.ipmsgid, | 288 | monpriv->path->pathid, monmsg->msg.id, monmsg->msg.class); |
296 | monmsg->local_eib.iptrgcls); | ||
297 | P_DEBUG("read, msg_type = '%c%c', mca_type = '%c' / 0x%X / 0x%X\n", | 289 | P_DEBUG("read, msg_type = '%c%c', mca_type = '%c' / 0x%X / 0x%X\n", |
298 | msg_type[0], msg_type[1], mca_type ? mca_type : 'X', | 290 | msg_type[0], msg_type[1], mca_type ? mca_type : 'X', |
299 | mon_mca_type(monmsg, 1), mon_mca_type(monmsg, 2)); | 291 | mon_mca_type(monmsg, 1), mon_mca_type(monmsg, 2)); |
@@ -306,8 +298,7 @@ mon_read_debug(struct mon_msg *monmsg, struct mon_private *monpriv) | |||
306 | #endif | 298 | #endif |
307 | } | 299 | } |
308 | 300 | ||
309 | static inline void | 301 | static inline void mon_next_mca(struct mon_msg *monmsg) |
310 | mon_next_mca(struct mon_msg *monmsg) | ||
311 | { | 302 | { |
312 | if (likely((mon_mca_size(monmsg) - monmsg->mca_offset) == 12)) | 303 | if (likely((mon_mca_size(monmsg) - monmsg->mca_offset) == 12)) |
313 | return; | 304 | return; |
@@ -316,8 +307,7 @@ mon_next_mca(struct mon_msg *monmsg) | |||
316 | monmsg->pos = 0; | 307 | monmsg->pos = 0; |
317 | } | 308 | } |
318 | 309 | ||
319 | static inline struct mon_msg * | 310 | static inline struct mon_msg *mon_next_message(struct mon_private *monpriv) |
320 | mon_next_message(struct mon_private *monpriv) | ||
321 | { | 311 | { |
322 | struct mon_msg *monmsg; | 312 | struct mon_msg *monmsg; |
323 | 313 | ||
@@ -342,39 +332,37 @@ mon_next_message(struct mon_private *monpriv) | |||
342 | /****************************************************************************** | 332 | /****************************************************************************** |
343 | * IUCV handler * | 333 | * IUCV handler * |
344 | *****************************************************************************/ | 334 | *****************************************************************************/ |
345 | static void | 335 | static void mon_iucv_path_complete(struct iucv_path *path, u8 ipuser[16]) |
346 | mon_iucv_ConnectionComplete(iucv_ConnectionComplete *eib, void *pgm_data) | ||
347 | { | 336 | { |
348 | struct mon_private *monpriv = (struct mon_private *) pgm_data; | 337 | struct mon_private *monpriv = path->private; |
349 | 338 | ||
350 | P_DEBUG("IUCV connection completed\n"); | 339 | P_DEBUG("IUCV connection completed\n"); |
351 | P_DEBUG("IUCV ACCEPT (from *MONITOR): Version = 0x%02X, Event = " | 340 | P_DEBUG("IUCV ACCEPT (from *MONITOR): Version = 0x%02X, Event = " |
352 | "0x%02X, Sample = 0x%02X\n", | 341 | "0x%02X, Sample = 0x%02X\n", |
353 | eib->ipuser[0], eib->ipuser[1], eib->ipuser[2]); | 342 | ipuser[0], ipuser[1], ipuser[2]); |
354 | atomic_set(&monpriv->iucv_connected, 1); | 343 | atomic_set(&monpriv->iucv_connected, 1); |
355 | wake_up(&mon_conn_wait_queue); | 344 | wake_up(&mon_conn_wait_queue); |
356 | } | 345 | } |
357 | 346 | ||
358 | static void | 347 | static void mon_iucv_path_severed(struct iucv_path *path, u8 ipuser[16]) |
359 | mon_iucv_ConnectionSevered(iucv_ConnectionSevered *eib, void *pgm_data) | ||
360 | { | 348 | { |
361 | struct mon_private *monpriv = (struct mon_private *) pgm_data; | 349 | struct mon_private *monpriv = path->private; |
362 | 350 | ||
363 | P_ERROR("IUCV connection severed with rc = 0x%X\n", | 351 | P_ERROR("IUCV connection severed with rc = 0x%X\n", ipuser[0]); |
364 | (u8) eib->ipuser[0]); | 352 | iucv_path_sever(path, NULL); |
365 | atomic_set(&monpriv->iucv_severed, 1); | 353 | atomic_set(&monpriv->iucv_severed, 1); |
366 | wake_up(&mon_conn_wait_queue); | 354 | wake_up(&mon_conn_wait_queue); |
367 | wake_up_interruptible(&mon_read_wait_queue); | 355 | wake_up_interruptible(&mon_read_wait_queue); |
368 | } | 356 | } |
369 | 357 | ||
370 | static void | 358 | static void mon_iucv_message_pending(struct iucv_path *path, |
371 | mon_iucv_MessagePending(iucv_MessagePending *eib, void *pgm_data) | 359 | struct iucv_message *msg) |
372 | { | 360 | { |
373 | struct mon_private *monpriv = (struct mon_private *) pgm_data; | 361 | struct mon_private *monpriv = path->private; |
374 | 362 | ||
375 | P_DEBUG("IUCV message pending\n"); | 363 | P_DEBUG("IUCV message pending\n"); |
376 | memcpy(&monpriv->msg_array[monpriv->write_index]->local_eib, eib, | 364 | memcpy(&monpriv->msg_array[monpriv->write_index]->msg, |
377 | sizeof(iucv_MessagePending)); | 365 | msg, sizeof(*msg)); |
378 | if (atomic_inc_return(&monpriv->msglim_count) == MON_MSGLIM) { | 366 | if (atomic_inc_return(&monpriv->msglim_count) == MON_MSGLIM) { |
379 | P_WARNING("IUCV message pending, message limit (%i) reached\n", | 367 | P_WARNING("IUCV message pending, message limit (%i) reached\n", |
380 | MON_MSGLIM); | 368 | MON_MSGLIM); |
@@ -385,54 +373,45 @@ mon_iucv_MessagePending(iucv_MessagePending *eib, void *pgm_data) | |||
385 | wake_up_interruptible(&mon_read_wait_queue); | 373 | wake_up_interruptible(&mon_read_wait_queue); |
386 | } | 374 | } |
387 | 375 | ||
388 | static iucv_interrupt_ops_t mon_iucvops = { | 376 | static struct iucv_handler monreader_iucv_handler = { |
389 | .ConnectionComplete = mon_iucv_ConnectionComplete, | 377 | .path_complete = mon_iucv_path_complete, |
390 | .ConnectionSevered = mon_iucv_ConnectionSevered, | 378 | .path_severed = mon_iucv_path_severed, |
391 | .MessagePending = mon_iucv_MessagePending, | 379 | .message_pending = mon_iucv_message_pending, |
392 | }; | 380 | }; |
393 | 381 | ||
394 | /****************************************************************************** | 382 | /****************************************************************************** |
395 | * file operations * | 383 | * file operations * |
396 | *****************************************************************************/ | 384 | *****************************************************************************/ |
397 | static int | 385 | static int mon_open(struct inode *inode, struct file *filp) |
398 | mon_open(struct inode *inode, struct file *filp) | ||
399 | { | 386 | { |
400 | int rc, i; | ||
401 | struct mon_private *monpriv; | 387 | struct mon_private *monpriv; |
388 | int rc; | ||
402 | 389 | ||
403 | /* | 390 | /* |
404 | * only one user allowed | 391 | * only one user allowed |
405 | */ | 392 | */ |
393 | rc = -EBUSY; | ||
406 | if (test_and_set_bit(MON_IN_USE, &mon_in_use)) | 394 | if (test_and_set_bit(MON_IN_USE, &mon_in_use)) |
407 | return -EBUSY; | 395 | goto out; |
408 | 396 | ||
397 | rc = -ENOMEM; | ||
409 | monpriv = mon_alloc_mem(); | 398 | monpriv = mon_alloc_mem(); |
410 | if (!monpriv) | 399 | if (!monpriv) |
411 | return -ENOMEM; | 400 | goto out_use; |
412 | 401 | ||
413 | /* | 402 | /* |
414 | * Register with IUCV and connect to *MONITOR service | 403 | * Connect to *MONITOR service |
415 | */ | 404 | */ |
416 | monpriv->iucv_handle = iucv_register_program("my_monreader ", | 405 | monpriv->path = iucv_path_alloc(MON_MSGLIM, IUCV_IPRMDATA, GFP_KERNEL); |
417 | MON_SERVICE, | 406 | if (!monpriv->path) |
418 | NULL, | 407 | goto out_priv; |
419 | &mon_iucvops, | 408 | rc = iucv_path_connect(monpriv->path, &monreader_iucv_handler, |
420 | monpriv); | 409 | MON_SERVICE, NULL, user_data_connect, monpriv); |
421 | if (!monpriv->iucv_handle) { | ||
422 | P_ERROR("failed to register with iucv driver\n"); | ||
423 | rc = -EIO; | ||
424 | goto out_error; | ||
425 | } | ||
426 | P_INFO("open, registered with IUCV\n"); | ||
427 | |||
428 | rc = iucv_connect(&monpriv->pathid, MON_MSGLIM, user_data_connect, | ||
429 | MON_SERVICE, iucv_host, IPRMDATA, NULL, NULL, | ||
430 | monpriv->iucv_handle, NULL); | ||
431 | if (rc) { | 410 | if (rc) { |
432 | P_ERROR("iucv connection to *MONITOR failed with " | 411 | P_ERROR("iucv connection to *MONITOR failed with " |
433 | "IPUSER SEVER code = %i\n", rc); | 412 | "IPUSER SEVER code = %i\n", rc); |
434 | rc = -EIO; | 413 | rc = -EIO; |
435 | goto out_unregister; | 414 | goto out_path; |
436 | } | 415 | } |
437 | /* | 416 | /* |
438 | * Wait for connection confirmation | 417 | * Wait for connection confirmation |
@@ -444,24 +423,23 @@ mon_open(struct inode *inode, struct file *filp) | |||
444 | atomic_set(&monpriv->iucv_severed, 0); | 423 | atomic_set(&monpriv->iucv_severed, 0); |
445 | atomic_set(&monpriv->iucv_connected, 0); | 424 | atomic_set(&monpriv->iucv_connected, 0); |
446 | rc = -EIO; | 425 | rc = -EIO; |
447 | goto out_unregister; | 426 | goto out_path; |
448 | } | 427 | } |
449 | P_INFO("open, established connection to *MONITOR service\n\n"); | 428 | P_INFO("open, established connection to *MONITOR service\n\n"); |
450 | filp->private_data = monpriv; | 429 | filp->private_data = monpriv; |
451 | return nonseekable_open(inode, filp); | 430 | return nonseekable_open(inode, filp); |
452 | 431 | ||
453 | out_unregister: | 432 | out_path: |
454 | iucv_unregister_program(monpriv->iucv_handle); | 433 | kfree(monpriv->path); |
455 | out_error: | 434 | out_priv: |
456 | for (i = 0; i < MON_MSGLIM; i++) | 435 | mon_free_mem(monpriv); |
457 | kfree(monpriv->msg_array[i]); | 436 | out_use: |
458 | kfree(monpriv); | ||
459 | clear_bit(MON_IN_USE, &mon_in_use); | 437 | clear_bit(MON_IN_USE, &mon_in_use); |
438 | out: | ||
460 | return rc; | 439 | return rc; |
461 | } | 440 | } |
462 | 441 | ||
463 | static int | 442 | static int mon_close(struct inode *inode, struct file *filp) |
464 | mon_close(struct inode *inode, struct file *filp) | ||
465 | { | 443 | { |
466 | int rc, i; | 444 | int rc, i; |
467 | struct mon_private *monpriv = filp->private_data; | 445 | struct mon_private *monpriv = filp->private_data; |
@@ -469,18 +447,12 @@ mon_close(struct inode *inode, struct file *filp) | |||
469 | /* | 447 | /* |
470 | * Close IUCV connection and unregister | 448 | * Close IUCV connection and unregister |
471 | */ | 449 | */ |
472 | rc = iucv_sever(monpriv->pathid, user_data_sever); | 450 | rc = iucv_path_sever(monpriv->path, user_data_sever); |
473 | if (rc) | 451 | if (rc) |
474 | P_ERROR("close, iucv_sever failed with rc = %i\n", rc); | 452 | P_ERROR("close, iucv_sever failed with rc = %i\n", rc); |
475 | else | 453 | else |
476 | P_INFO("close, terminated connection to *MONITOR service\n"); | 454 | P_INFO("close, terminated connection to *MONITOR service\n"); |
477 | 455 | ||
478 | rc = iucv_unregister_program(monpriv->iucv_handle); | ||
479 | if (rc) | ||
480 | P_ERROR("close, iucv_unregister failed with rc = %i\n", rc); | ||
481 | else | ||
482 | P_INFO("close, unregistered with IUCV\n"); | ||
483 | |||
484 | atomic_set(&monpriv->iucv_severed, 0); | 456 | atomic_set(&monpriv->iucv_severed, 0); |
485 | atomic_set(&monpriv->iucv_connected, 0); | 457 | atomic_set(&monpriv->iucv_connected, 0); |
486 | atomic_set(&monpriv->read_ready, 0); | 458 | atomic_set(&monpriv->read_ready, 0); |
@@ -495,8 +467,8 @@ mon_close(struct inode *inode, struct file *filp) | |||
495 | return 0; | 467 | return 0; |
496 | } | 468 | } |
497 | 469 | ||
498 | static ssize_t | 470 | static ssize_t mon_read(struct file *filp, char __user *data, |
499 | mon_read(struct file *filp, char __user *data, size_t count, loff_t *ppos) | 471 | size_t count, loff_t *ppos) |
500 | { | 472 | { |
501 | struct mon_private *monpriv = filp->private_data; | 473 | struct mon_private *monpriv = filp->private_data; |
502 | struct mon_msg *monmsg; | 474 | struct mon_msg *monmsg; |
@@ -563,8 +535,7 @@ out_copy: | |||
563 | return count; | 535 | return count; |
564 | } | 536 | } |
565 | 537 | ||
566 | static unsigned int | 538 | static unsigned int mon_poll(struct file *filp, struct poll_table_struct *p) |
567 | mon_poll(struct file *filp, struct poll_table_struct *p) | ||
568 | { | 539 | { |
569 | struct mon_private *monpriv = filp->private_data; | 540 | struct mon_private *monpriv = filp->private_data; |
570 | 541 | ||
@@ -593,8 +564,7 @@ static struct miscdevice mon_dev = { | |||
593 | /****************************************************************************** | 564 | /****************************************************************************** |
594 | * module init/exit * | 565 | * module init/exit * |
595 | *****************************************************************************/ | 566 | *****************************************************************************/ |
596 | static int __init | 567 | static int __init mon_init(void) |
597 | mon_init(void) | ||
598 | { | 568 | { |
599 | int rc; | 569 | int rc; |
600 | 570 | ||
@@ -603,22 +573,34 @@ mon_init(void) | |||
603 | return -ENODEV; | 573 | return -ENODEV; |
604 | } | 574 | } |
605 | 575 | ||
576 | /* | ||
577 | * Register with IUCV and connect to *MONITOR service | ||
578 | */ | ||
579 | rc = iucv_register(&monreader_iucv_handler, 1); | ||
580 | if (rc) { | ||
581 | P_ERROR("failed to register with iucv driver\n"); | ||
582 | return rc; | ||
583 | } | ||
584 | P_INFO("open, registered with IUCV\n"); | ||
585 | |||
606 | rc = segment_type(mon_dcss_name); | 586 | rc = segment_type(mon_dcss_name); |
607 | if (rc < 0) { | 587 | if (rc < 0) { |
608 | mon_segment_warn(rc, mon_dcss_name); | 588 | mon_segment_warn(rc, mon_dcss_name); |
609 | return rc; | 589 | goto out_iucv; |
610 | } | 590 | } |
611 | if (rc != SEG_TYPE_SC) { | 591 | if (rc != SEG_TYPE_SC) { |
612 | P_ERROR("segment %s has unsupported type, should be SC\n", | 592 | P_ERROR("segment %s has unsupported type, should be SC\n", |
613 | mon_dcss_name); | 593 | mon_dcss_name); |
614 | return -EINVAL; | 594 | rc = -EINVAL; |
595 | goto out_iucv; | ||
615 | } | 596 | } |
616 | 597 | ||
617 | rc = segment_load(mon_dcss_name, SEGMENT_SHARED, | 598 | rc = segment_load(mon_dcss_name, SEGMENT_SHARED, |
618 | &mon_dcss_start, &mon_dcss_end); | 599 | &mon_dcss_start, &mon_dcss_end); |
619 | if (rc < 0) { | 600 | if (rc < 0) { |
620 | mon_segment_warn(rc, mon_dcss_name); | 601 | mon_segment_warn(rc, mon_dcss_name); |
621 | return -EINVAL; | 602 | rc = -EINVAL; |
603 | goto out_iucv; | ||
622 | } | 604 | } |
623 | dcss_mkname(mon_dcss_name, &user_data_connect[8]); | 605 | dcss_mkname(mon_dcss_name, &user_data_connect[8]); |
624 | 606 | ||
@@ -634,14 +616,16 @@ mon_init(void) | |||
634 | 616 | ||
635 | out: | 617 | out: |
636 | segment_unload(mon_dcss_name); | 618 | segment_unload(mon_dcss_name); |
619 | out_iucv: | ||
620 | iucv_unregister(&monreader_iucv_handler, 1); | ||
637 | return rc; | 621 | return rc; |
638 | } | 622 | } |
639 | 623 | ||
640 | static void __exit | 624 | static void __exit mon_exit(void) |
641 | mon_exit(void) | ||
642 | { | 625 | { |
643 | segment_unload(mon_dcss_name); | 626 | segment_unload(mon_dcss_name); |
644 | WARN_ON(misc_deregister(&mon_dev) != 0); | 627 | WARN_ON(misc_deregister(&mon_dev) != 0); |
628 | iucv_unregister(&monreader_iucv_handler, 1); | ||
645 | return; | 629 | return; |
646 | } | 630 | } |
647 | 631 | ||