aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/char/vmlogrdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/char/vmlogrdr.c')
-rw-r--r--drivers/s390/char/vmlogrdr.c284
1 files changed, 129 insertions, 155 deletions
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index 6cb23040954b..8432a76b961e 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -3,7 +3,7 @@
3 * character device driver for reading z/VM system service records 3 * character device driver for reading z/VM system service records
4 * 4 *
5 * 5 *
6 * Copyright (C) 2004 IBM Corporation 6 * Copyright 2004 IBM Corporation
7 * character device driver for reading z/VM system service records, 7 * character device driver for reading z/VM system service records,
8 * Version 1.0 8 * Version 1.0
9 * Author(s): Xenia Tkatschow <xenia@us.ibm.com> 9 * Author(s): Xenia Tkatschow <xenia@us.ibm.com>
@@ -21,7 +21,7 @@
21#include <asm/cpcmd.h> 21#include <asm/cpcmd.h>
22#include <asm/debug.h> 22#include <asm/debug.h>
23#include <asm/ebcdic.h> 23#include <asm/ebcdic.h>
24#include "../net/iucv.h" 24#include <net/iucv/iucv.h>
25#include <linux/kmod.h> 25#include <linux/kmod.h>
26#include <linux/cdev.h> 26#include <linux/cdev.h>
27#include <linux/device.h> 27#include <linux/device.h>
@@ -60,12 +60,11 @@ struct vmlogrdr_priv_t {
60 char system_service[8]; 60 char system_service[8];
61 char internal_name[8]; 61 char internal_name[8];
62 char recording_name[8]; 62 char recording_name[8];
63 u16 pathid; 63 struct iucv_path *path;
64 int connection_established; 64 int connection_established;
65 int iucv_path_severed; 65 int iucv_path_severed;
66 iucv_MessagePending local_interrupt_buffer; 66 struct iucv_message local_interrupt_buffer;
67 atomic_t receive_ready; 67 atomic_t receive_ready;
68 iucv_handle_t iucv_handle;
69 int minor_num; 68 int minor_num;
70 char * buffer; 69 char * buffer;
71 char * current_position; 70 char * current_position;
@@ -97,40 +96,21 @@ static struct file_operations vmlogrdr_fops = {
97}; 96};
98 97
99 98
100static u8 iucvMagic[16] = { 99static void vmlogrdr_iucv_path_complete(struct iucv_path *, u8 ipuser[16]);
101 0xF0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 100static void vmlogrdr_iucv_path_severed(struct iucv_path *, u8 ipuser[16]);
102 0xF0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 101static void vmlogrdr_iucv_message_pending(struct iucv_path *,
103}; 102 struct iucv_message *);
104 103
105 104
106static u8 mask[] = { 105static struct iucv_handler vmlogrdr_iucv_handler = {
107 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 106 .path_complete = vmlogrdr_iucv_path_complete,
108 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 107 .path_severed = vmlogrdr_iucv_path_severed,
109 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 108 .message_pending = vmlogrdr_iucv_message_pending,
110 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
111}; 109};
112 110
113 111
114static u8 iucv_host[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 112static DECLARE_WAIT_QUEUE_HEAD(conn_wait_queue);
115 113static DECLARE_WAIT_QUEUE_HEAD(read_wait_queue);
116
117static void
118vmlogrdr_iucv_ConnectionComplete(iucv_ConnectionComplete *eib, void *pgm_data);
119static void
120vmlogrdr_iucv_ConnectionSevered(iucv_ConnectionSevered *eib, void *pgm_data);
121static void
122vmlogrdr_iucv_MessagePending(iucv_MessagePending *eib, void *pgm_data);
123
124
125static iucv_interrupt_ops_t vmlogrdr_iucvops = {
126 .ConnectionComplete = vmlogrdr_iucv_ConnectionComplete,
127 .ConnectionSevered = vmlogrdr_iucv_ConnectionSevered,
128 .MessagePending = vmlogrdr_iucv_MessagePending,
129};
130
131
132DECLARE_WAIT_QUEUE_HEAD(conn_wait_queue);
133DECLARE_WAIT_QUEUE_HEAD(read_wait_queue);
134 114
135/* 115/*
136 * pointer to system service private structure 116 * pointer to system service private structure
@@ -177,28 +157,29 @@ static struct cdev *vmlogrdr_cdev = NULL;
177static int recording_class_AB; 157static int recording_class_AB;
178 158
179 159
180static void 160static void vmlogrdr_iucv_path_complete(struct iucv_path *path, u8 ipuser[16])
181vmlogrdr_iucv_ConnectionComplete (iucv_ConnectionComplete * eib,
182 void * pgm_data)
183{ 161{
184 struct vmlogrdr_priv_t * logptr = pgm_data; 162 struct vmlogrdr_priv_t * logptr = path->private;
163
185 spin_lock(&logptr->priv_lock); 164 spin_lock(&logptr->priv_lock);
186 logptr->connection_established = 1; 165 logptr->connection_established = 1;
187 spin_unlock(&logptr->priv_lock); 166 spin_unlock(&logptr->priv_lock);
188 wake_up(&conn_wait_queue); 167 wake_up(&conn_wait_queue);
189 return;
190} 168}
191 169
192 170
193static void 171static void vmlogrdr_iucv_path_severed(struct iucv_path *path, u8 ipuser[16])
194vmlogrdr_iucv_ConnectionSevered (iucv_ConnectionSevered * eib, void * pgm_data)
195{ 172{
196 u8 reason = (u8) eib->ipuser[8]; 173 struct vmlogrdr_priv_t * logptr = path->private;
197 struct vmlogrdr_priv_t * logptr = pgm_data; 174 u8 reason = (u8) ipuser[8];
198 175
199 printk (KERN_ERR "vmlogrdr: connection severed with" 176 printk (KERN_ERR "vmlogrdr: connection severed with"
200 " reason %i\n", reason); 177 " reason %i\n", reason);
201 178
179 iucv_path_sever(path, NULL);
180 kfree(path);
181 logptr->path = NULL;
182
202 spin_lock(&logptr->priv_lock); 183 spin_lock(&logptr->priv_lock);
203 logptr->connection_established = 0; 184 logptr->connection_established = 0;
204 logptr->iucv_path_severed = 1; 185 logptr->iucv_path_severed = 1;
@@ -210,10 +191,10 @@ vmlogrdr_iucv_ConnectionSevered (iucv_ConnectionSevered * eib, void * pgm_data)
210} 191}
211 192
212 193
213static void 194static void vmlogrdr_iucv_message_pending(struct iucv_path *path,
214vmlogrdr_iucv_MessagePending (iucv_MessagePending * eib, void * pgm_data) 195 struct iucv_message *msg)
215{ 196{
216 struct vmlogrdr_priv_t * logptr = pgm_data; 197 struct vmlogrdr_priv_t * logptr = path->private;
217 198
218 /* 199 /*
219 * This function is the bottom half so it should be quick. 200 * This function is the bottom half so it should be quick.
@@ -221,15 +202,15 @@ vmlogrdr_iucv_MessagePending (iucv_MessagePending * eib, void * pgm_data)
221 * the usage count 202 * the usage count
222 */ 203 */
223 spin_lock(&logptr->priv_lock); 204 spin_lock(&logptr->priv_lock);
224 memcpy(&(logptr->local_interrupt_buffer), eib, sizeof(*eib)); 205 memcpy(&logptr->local_interrupt_buffer, msg, sizeof(*msg));
225 atomic_inc(&logptr->receive_ready); 206 atomic_inc(&logptr->receive_ready);
226 spin_unlock(&logptr->priv_lock); 207 spin_unlock(&logptr->priv_lock);
227 wake_up_interruptible(&read_wait_queue); 208 wake_up_interruptible(&read_wait_queue);
228} 209}
229 210
230 211
231static int 212static int vmlogrdr_get_recording_class_AB(void)
232vmlogrdr_get_recording_class_AB(void) { 213{
233 char cp_command[]="QUERY COMMAND RECORDING "; 214 char cp_command[]="QUERY COMMAND RECORDING ";
234 char cp_response[80]; 215 char cp_response[80];
235 char *tail; 216 char *tail;
@@ -259,8 +240,9 @@ vmlogrdr_get_recording_class_AB(void) {
259} 240}
260 241
261 242
262static int 243static int vmlogrdr_recording(struct vmlogrdr_priv_t * logptr,
263vmlogrdr_recording(struct vmlogrdr_priv_t * logptr, int action, int purge) { 244 int action, int purge)
245{
264 246
265 char cp_command[80]; 247 char cp_command[80];
266 char cp_response[160]; 248 char cp_response[160];
@@ -318,8 +300,7 @@ vmlogrdr_recording(struct vmlogrdr_priv_t * logptr, int action, int purge) {
318} 300}
319 301
320 302
321static int 303static int vmlogrdr_open (struct inode *inode, struct file *filp)
322vmlogrdr_open (struct inode *inode, struct file *filp)
323{ 304{
324 int dev_num = 0; 305 int dev_num = 0;
325 struct vmlogrdr_priv_t * logptr = NULL; 306 struct vmlogrdr_priv_t * logptr = NULL;
@@ -329,10 +310,7 @@ vmlogrdr_open (struct inode *inode, struct file *filp)
329 dev_num = iminor(inode); 310 dev_num = iminor(inode);
330 if (dev_num > MAXMINOR) 311 if (dev_num > MAXMINOR)
331 return -ENODEV; 312 return -ENODEV;
332
333 logptr = &sys_ser[dev_num]; 313 logptr = &sys_ser[dev_num];
334 if (logptr == NULL)
335 return -ENODEV;
336 314
337 /* 315 /*
338 * only allow for blocking reads to be open 316 * only allow for blocking reads to be open
@@ -345,52 +323,38 @@ vmlogrdr_open (struct inode *inode, struct file *filp)
345 if (logptr->dev_in_use) { 323 if (logptr->dev_in_use) {
346 spin_unlock_bh(&logptr->priv_lock); 324 spin_unlock_bh(&logptr->priv_lock);
347 return -EBUSY; 325 return -EBUSY;
348 } else {
349 logptr->dev_in_use = 1;
350 spin_unlock_bh(&logptr->priv_lock);
351 } 326 }
352 327 logptr->dev_in_use = 1;
328 logptr->connection_established = 0;
329 logptr->iucv_path_severed = 0;
353 atomic_set(&logptr->receive_ready, 0); 330 atomic_set(&logptr->receive_ready, 0);
354 logptr->buffer_free = 1; 331 logptr->buffer_free = 1;
332 spin_unlock_bh(&logptr->priv_lock);
355 333
356 /* set the file options */ 334 /* set the file options */
357 filp->private_data = logptr; 335 filp->private_data = logptr;
358 filp->f_op = &vmlogrdr_fops; 336 filp->f_op = &vmlogrdr_fops;
359 337
360 /* start recording for this service*/ 338 /* start recording for this service*/
361 ret=0; 339 if (logptr->autorecording) {
362 if (logptr->autorecording)
363 ret = vmlogrdr_recording(logptr,1,logptr->autopurge); 340 ret = vmlogrdr_recording(logptr,1,logptr->autopurge);
364 if (ret) 341 if (ret)
365 printk (KERN_WARNING "vmlogrdr: failed to start " 342 printk (KERN_WARNING "vmlogrdr: failed to start "
366 "recording automatically\n"); 343 "recording automatically\n");
367
368 /* Register with iucv driver */
369 logptr->iucv_handle = iucv_register_program(iucvMagic,
370 logptr->system_service, mask, &vmlogrdr_iucvops,
371 logptr);
372
373 if (logptr->iucv_handle == NULL) {
374 printk (KERN_ERR "vmlogrdr: failed to register with"
375 "iucv driver\n");
376 goto not_registered;
377 } 344 }
378 345
379 /* create connection to the system service */ 346 /* create connection to the system service */
380 spin_lock_bh(&logptr->priv_lock); 347 logptr->path = iucv_path_alloc(10, 0, GFP_KERNEL);
381 logptr->connection_established = 0; 348 if (!logptr->path)
382 logptr->iucv_path_severed = 0; 349 goto out_dev;
383 spin_unlock_bh(&logptr->priv_lock); 350 connect_rc = iucv_path_connect(logptr->path, &vmlogrdr_iucv_handler,
384 351 logptr->system_service, NULL, NULL,
385 connect_rc = iucv_connect (&(logptr->pathid), 10, iucvMagic, 352 logptr);
386 logptr->system_service, iucv_host, 0,
387 NULL, NULL,
388 logptr->iucv_handle, NULL);
389 if (connect_rc) { 353 if (connect_rc) {
390 printk (KERN_ERR "vmlogrdr: iucv connection to %s " 354 printk (KERN_ERR "vmlogrdr: iucv connection to %s "
391 "failed with rc %i \n", logptr->system_service, 355 "failed with rc %i \n", logptr->system_service,
392 connect_rc); 356 connect_rc);
393 goto not_connected; 357 goto out_path;
394 } 358 }
395 359
396 /* We've issued the connect and now we must wait for a 360 /* We've issued the connect and now we must wait for a
@@ -399,35 +363,28 @@ vmlogrdr_open (struct inode *inode, struct file *filp)
399 */ 363 */
400 wait_event(conn_wait_queue, (logptr->connection_established) 364 wait_event(conn_wait_queue, (logptr->connection_established)
401 || (logptr->iucv_path_severed)); 365 || (logptr->iucv_path_severed));
402 if (logptr->iucv_path_severed) { 366 if (logptr->iucv_path_severed)
403 goto not_connected; 367 goto out_record;
404 }
405
406 return nonseekable_open(inode, filp); 368 return nonseekable_open(inode, filp);
407 369
408not_connected: 370out_record:
409 iucv_unregister_program(logptr->iucv_handle);
410 logptr->iucv_handle = NULL;
411not_registered:
412 if (logptr->autorecording) 371 if (logptr->autorecording)
413 vmlogrdr_recording(logptr,0,logptr->autopurge); 372 vmlogrdr_recording(logptr,0,logptr->autopurge);
373out_path:
374 kfree(logptr->path); /* kfree(NULL) is ok. */
375 logptr->path = NULL;
376out_dev:
414 logptr->dev_in_use = 0; 377 logptr->dev_in_use = 0;
415 return -EIO; 378 return -EIO;
416
417
418} 379}
419 380
420 381
421static int 382static int vmlogrdr_release (struct inode *inode, struct file *filp)
422vmlogrdr_release (struct inode *inode, struct file *filp)
423{ 383{
424 int ret; 384 int ret;
425 385
426 struct vmlogrdr_priv_t * logptr = filp->private_data; 386 struct vmlogrdr_priv_t * logptr = filp->private_data;
427 387
428 iucv_unregister_program(logptr->iucv_handle);
429 logptr->iucv_handle = NULL;
430
431 if (logptr->autorecording) { 388 if (logptr->autorecording) {
432 ret = vmlogrdr_recording(logptr,0,logptr->autopurge); 389 ret = vmlogrdr_recording(logptr,0,logptr->autopurge);
433 if (ret) 390 if (ret)
@@ -440,8 +397,8 @@ vmlogrdr_release (struct inode *inode, struct file *filp)
440} 397}
441 398
442 399
443static int 400static int vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv)
444vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv) { 401{
445 int rc, *temp; 402 int rc, *temp;
446 /* we need to keep track of two data sizes here: 403 /* we need to keep track of two data sizes here:
447 * The number of bytes we need to receive from iucv and 404 * The number of bytes we need to receive from iucv and
@@ -462,8 +419,7 @@ vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv) {
462 * We need to return the total length of the record 419 * We need to return the total length of the record
463 * + size of FENCE in the first 4 bytes of the buffer. 420 * + size of FENCE in the first 4 bytes of the buffer.
464 */ 421 */
465 iucv_data_count = 422 iucv_data_count = priv->local_interrupt_buffer.length;
466 priv->local_interrupt_buffer.ln1msg2.ipbfln1f;
467 user_data_count = sizeof(int); 423 user_data_count = sizeof(int);
468 temp = (int*)priv->buffer; 424 temp = (int*)priv->buffer;
469 *temp= iucv_data_count + sizeof(FENCE); 425 *temp= iucv_data_count + sizeof(FENCE);
@@ -475,14 +431,10 @@ vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv) {
475 */ 431 */
476 if (iucv_data_count > NET_BUFFER_SIZE) 432 if (iucv_data_count > NET_BUFFER_SIZE)
477 iucv_data_count = NET_BUFFER_SIZE; 433 iucv_data_count = NET_BUFFER_SIZE;
478 rc = iucv_receive(priv->pathid, 434 rc = iucv_message_receive(priv->path,
479 priv->local_interrupt_buffer.ipmsgid, 435 &priv->local_interrupt_buffer,
480 priv->local_interrupt_buffer.iptrgcls, 436 0, buffer, iucv_data_count,
481 buffer, 437 &priv->residual_length);
482 iucv_data_count,
483 NULL,
484 NULL,
485 &priv->residual_length);
486 spin_unlock_bh(&priv->priv_lock); 438 spin_unlock_bh(&priv->priv_lock);
487 /* An rc of 5 indicates that the record was bigger then 439 /* An rc of 5 indicates that the record was bigger then
488 * the buffer, which is OK for us. A 9 indicates that the 440 * the buffer, which is OK for us. A 9 indicates that the
@@ -514,8 +466,8 @@ vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv) {
514} 466}
515 467
516 468
517static ssize_t 469static ssize_t vmlogrdr_read(struct file *filp, char __user *data,
518vmlogrdr_read(struct file *filp, char __user *data, size_t count, loff_t * ppos) 470 size_t count, loff_t * ppos)
519{ 471{
520 int rc; 472 int rc;
521 struct vmlogrdr_priv_t * priv = filp->private_data; 473 struct vmlogrdr_priv_t * priv = filp->private_data;
@@ -547,8 +499,10 @@ vmlogrdr_read(struct file *filp, char __user *data, size_t count, loff_t * ppos)
547 return count; 499 return count;
548} 500}
549 501
550static ssize_t 502static ssize_t vmlogrdr_autopurge_store(struct device * dev,
551vmlogrdr_autopurge_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t count) { 503 struct device_attribute *attr,
504 const char * buf, size_t count)
505{
552 struct vmlogrdr_priv_t *priv = dev->driver_data; 506 struct vmlogrdr_priv_t *priv = dev->driver_data;
553 ssize_t ret = count; 507 ssize_t ret = count;
554 508
@@ -566,8 +520,10 @@ vmlogrdr_autopurge_store(struct device * dev, struct device_attribute *attr, con
566} 520}
567 521
568 522
569static ssize_t 523static ssize_t vmlogrdr_autopurge_show(struct device *dev,
570vmlogrdr_autopurge_show(struct device *dev, struct device_attribute *attr, char *buf) { 524 struct device_attribute *attr,
525 char *buf)
526{
571 struct vmlogrdr_priv_t *priv = dev->driver_data; 527 struct vmlogrdr_priv_t *priv = dev->driver_data;
572 return sprintf(buf, "%u\n", priv->autopurge); 528 return sprintf(buf, "%u\n", priv->autopurge);
573} 529}
@@ -577,8 +533,10 @@ static DEVICE_ATTR(autopurge, 0644, vmlogrdr_autopurge_show,
577 vmlogrdr_autopurge_store); 533 vmlogrdr_autopurge_store);
578 534
579 535
580static ssize_t 536static ssize_t vmlogrdr_purge_store(struct device * dev,
581vmlogrdr_purge_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t count) { 537 struct device_attribute *attr,
538 const char * buf, size_t count)
539{
582 540
583 char cp_command[80]; 541 char cp_command[80];
584 char cp_response[80]; 542 char cp_response[80];
@@ -618,9 +576,10 @@ vmlogrdr_purge_store(struct device * dev, struct device_attribute *attr, const c
618static DEVICE_ATTR(purge, 0200, NULL, vmlogrdr_purge_store); 576static DEVICE_ATTR(purge, 0200, NULL, vmlogrdr_purge_store);
619 577
620 578
621static ssize_t 579static ssize_t vmlogrdr_autorecording_store(struct device *dev,
622vmlogrdr_autorecording_store(struct device *dev, struct device_attribute *attr, const char *buf, 580 struct device_attribute *attr,
623 size_t count) { 581 const char *buf, size_t count)
582{
624 struct vmlogrdr_priv_t *priv = dev->driver_data; 583 struct vmlogrdr_priv_t *priv = dev->driver_data;
625 ssize_t ret = count; 584 ssize_t ret = count;
626 585
@@ -638,8 +597,10 @@ vmlogrdr_autorecording_store(struct device *dev, struct device_attribute *attr,
638} 597}
639 598
640 599
641static ssize_t 600static ssize_t vmlogrdr_autorecording_show(struct device *dev,
642vmlogrdr_autorecording_show(struct device *dev, struct device_attribute *attr, char *buf) { 601 struct device_attribute *attr,
602 char *buf)
603{
643 struct vmlogrdr_priv_t *priv = dev->driver_data; 604 struct vmlogrdr_priv_t *priv = dev->driver_data;
644 return sprintf(buf, "%u\n", priv->autorecording); 605 return sprintf(buf, "%u\n", priv->autorecording);
645} 606}
@@ -649,9 +610,10 @@ static DEVICE_ATTR(autorecording, 0644, vmlogrdr_autorecording_show,
649 vmlogrdr_autorecording_store); 610 vmlogrdr_autorecording_store);
650 611
651 612
652static ssize_t 613static ssize_t vmlogrdr_recording_store(struct device * dev,
653vmlogrdr_recording_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t count) { 614 struct device_attribute *attr,
654 615 const char * buf, size_t count)
616{
655 struct vmlogrdr_priv_t *priv = dev->driver_data; 617 struct vmlogrdr_priv_t *priv = dev->driver_data;
656 ssize_t ret; 618 ssize_t ret;
657 619
@@ -676,8 +638,9 @@ vmlogrdr_recording_store(struct device * dev, struct device_attribute *attr, con
676static DEVICE_ATTR(recording, 0200, NULL, vmlogrdr_recording_store); 638static DEVICE_ATTR(recording, 0200, NULL, vmlogrdr_recording_store);
677 639
678 640
679static ssize_t 641static ssize_t vmlogrdr_recording_status_show(struct device_driver *driver,
680vmlogrdr_recording_status_show(struct device_driver *driver, char *buf) { 642 char *buf)
643{
681 644
682 char cp_command[] = "QUERY RECORDING "; 645 char cp_command[] = "QUERY RECORDING ";
683 int len; 646 int len;
@@ -710,52 +673,63 @@ static struct device_driver vmlogrdr_driver = {
710}; 673};
711 674
712 675
713static int 676static int vmlogrdr_register_driver(void)
714vmlogrdr_register_driver(void) { 677{
715 int ret; 678 int ret;
716 679
680 /* Register with iucv driver */
681 ret = iucv_register(&vmlogrdr_iucv_handler, 1);
682 if (ret) {
683 printk (KERN_ERR "vmlogrdr: failed to register with"
684 "iucv driver\n");
685 goto out;
686 }
687
717 ret = driver_register(&vmlogrdr_driver); 688 ret = driver_register(&vmlogrdr_driver);
718 if (ret) { 689 if (ret) {
719 printk(KERN_ERR "vmlogrdr: failed to register driver.\n"); 690 printk(KERN_ERR "vmlogrdr: failed to register driver.\n");
720 return ret; 691 goto out_iucv;
721 } 692 }
722 693
723 ret = driver_create_file(&vmlogrdr_driver, 694 ret = driver_create_file(&vmlogrdr_driver,
724 &driver_attr_recording_status); 695 &driver_attr_recording_status);
725 if (ret) { 696 if (ret) {
726 printk(KERN_ERR "vmlogrdr: failed to add driver attribute.\n"); 697 printk(KERN_ERR "vmlogrdr: failed to add driver attribute.\n");
727 goto unregdriver; 698 goto out_driver;
728 } 699 }
729 700
730 vmlogrdr_class = class_create(THIS_MODULE, "vmlogrdr"); 701 vmlogrdr_class = class_create(THIS_MODULE, "vmlogrdr");
731 if (IS_ERR(vmlogrdr_class)) { 702 if (IS_ERR(vmlogrdr_class)) {
732 printk(KERN_ERR "vmlogrdr: failed to create class.\n"); 703 printk(KERN_ERR "vmlogrdr: failed to create class.\n");
733 ret=PTR_ERR(vmlogrdr_class); 704 ret = PTR_ERR(vmlogrdr_class);
734 vmlogrdr_class=NULL; 705 vmlogrdr_class = NULL;
735 goto unregattr; 706 goto out_attr;
736 } 707 }
737 return 0; 708 return 0;
738 709
739unregattr: 710out_attr:
740 driver_remove_file(&vmlogrdr_driver, &driver_attr_recording_status); 711 driver_remove_file(&vmlogrdr_driver, &driver_attr_recording_status);
741unregdriver: 712out_driver:
742 driver_unregister(&vmlogrdr_driver); 713 driver_unregister(&vmlogrdr_driver);
714out_iucv:
715 iucv_unregister(&vmlogrdr_iucv_handler, 1);
716out:
743 return ret; 717 return ret;
744} 718}
745 719
746 720
747static void 721static void vmlogrdr_unregister_driver(void)
748vmlogrdr_unregister_driver(void) { 722{
749 class_destroy(vmlogrdr_class); 723 class_destroy(vmlogrdr_class);
750 vmlogrdr_class = NULL; 724 vmlogrdr_class = NULL;
751 driver_remove_file(&vmlogrdr_driver, &driver_attr_recording_status); 725 driver_remove_file(&vmlogrdr_driver, &driver_attr_recording_status);
752 driver_unregister(&vmlogrdr_driver); 726 driver_unregister(&vmlogrdr_driver);
753 return; 727 iucv_unregister(&vmlogrdr_iucv_handler, 1);
754} 728}
755 729
756 730
757static int 731static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
758vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) { 732{
759 struct device *dev; 733 struct device *dev;
760 int ret; 734 int ret;
761 735
@@ -804,9 +778,10 @@ vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) {
804} 778}
805 779
806 780
807static int 781static int vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv)
808vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv ) { 782{
809 class_device_destroy(vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num)); 783 class_device_destroy(vmlogrdr_class,
784 MKDEV(vmlogrdr_major, priv->minor_num));
810 if (priv->device != NULL) { 785 if (priv->device != NULL) {
811 sysfs_remove_group(&priv->device->kobj, &vmlogrdr_attr_group); 786 sysfs_remove_group(&priv->device->kobj, &vmlogrdr_attr_group);
812 device_unregister(priv->device); 787 device_unregister(priv->device);
@@ -816,8 +791,8 @@ vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv ) {
816} 791}
817 792
818 793
819static int 794static int vmlogrdr_register_cdev(dev_t dev)
820vmlogrdr_register_cdev(dev_t dev) { 795{
821 int rc = 0; 796 int rc = 0;
822 vmlogrdr_cdev = cdev_alloc(); 797 vmlogrdr_cdev = cdev_alloc();
823 if (!vmlogrdr_cdev) { 798 if (!vmlogrdr_cdev) {
@@ -837,9 +812,10 @@ vmlogrdr_register_cdev(dev_t dev) {
837} 812}
838 813
839 814
840static void 815static void vmlogrdr_cleanup(void)
841vmlogrdr_cleanup(void) { 816{
842 int i; 817 int i;
818
843 if (vmlogrdr_cdev) { 819 if (vmlogrdr_cdev) {
844 cdev_del(vmlogrdr_cdev); 820 cdev_del(vmlogrdr_cdev);
845 vmlogrdr_cdev=NULL; 821 vmlogrdr_cdev=NULL;
@@ -856,8 +832,7 @@ vmlogrdr_cleanup(void) {
856} 832}
857 833
858 834
859static int 835static int vmlogrdr_init(void)
860vmlogrdr_init(void)
861{ 836{
862 int rc; 837 int rc;
863 int i; 838 int i;
@@ -907,8 +882,7 @@ cleanup:
907} 882}
908 883
909 884
910static void 885static void vmlogrdr_exit(void)
911vmlogrdr_exit(void)
912{ 886{
913 vmlogrdr_cleanup(); 887 vmlogrdr_cleanup();
914 printk (KERN_INFO "vmlogrdr: driver unloaded\n"); 888 printk (KERN_INFO "vmlogrdr: driver unloaded\n");