parisc: remove klist iterators
[safe/jmp/linux-2.6] / drivers / s390 / char / vmlogrdr.c
index d364e0b..d8a2289 100644 (file)
  *                Stefan Weinhuber <wein@de.ibm.com>
  *
  */
+
+#define KMSG_COMPONENT "vmlogrdr"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/kmod.h>
 #include <linux/cdev.h>
 #include <linux/device.h>
+#include <linux/smp_lock.h>
 #include <linux/string.h>
 
-
-
 MODULE_AUTHOR
        ("(C) 2004 IBM Corporation by Xenia Tkatschow (xenia@us.ibm.com)\n"
         "                            Stefan Weinhuber (wein@de.ibm.com)");
@@ -173,8 +176,7 @@ static void vmlogrdr_iucv_path_severed(struct iucv_path *path, u8 ipuser[16])
        struct vmlogrdr_priv_t * logptr = path->private;
        u8 reason = (u8) ipuser[8];
 
-       printk (KERN_ERR "vmlogrdr: connection severed with"
-               " reason %i\n", reason);
+       pr_err("vmlogrdr: connection severed with reason %i\n", reason);
 
        iucv_path_sever(path, NULL);
        kfree(path);
@@ -216,9 +218,7 @@ static int vmlogrdr_get_recording_class_AB(void)
        char *tail;
        int len,i;
 
-       printk (KERN_DEBUG "vmlogrdr: query command: %s\n", cp_command);
        cpcmd(cp_command, cp_response, sizeof(cp_response), NULL);
-       printk (KERN_DEBUG "vmlogrdr: response: %s", cp_response);
        len = strnlen(cp_response,sizeof(cp_response));
        // now the parsing
        tail=strnchr(cp_response,len,'=');
@@ -268,11 +268,7 @@ static int vmlogrdr_recording(struct vmlogrdr_priv_t * logptr,
                         logptr->recording_name,
                         qid_string);
 
-               printk (KERN_DEBUG "vmlogrdr: recording command: %s\n",
-                       cp_command);
                cpcmd(cp_command, cp_response, sizeof(cp_response), NULL);
-               printk (KERN_DEBUG "vmlogrdr: recording response: %s",
-                       cp_response);
        }
 
        memset(cp_command, 0x00, sizeof(cp_command));
@@ -282,10 +278,7 @@ static int vmlogrdr_recording(struct vmlogrdr_priv_t * logptr,
                onoff,
                qid_string);
 
-       printk (KERN_DEBUG "vmlogrdr: recording command: %s\n", cp_command);
        cpcmd(cp_command, cp_response, sizeof(cp_response), NULL);
-       printk (KERN_DEBUG "vmlogrdr: recording response: %s",
-               cp_response);
        /* The recording command will usually answer with 'Command complete'
         * on success, but when the specific service was never connected
         * before then there might be an additional informational message
@@ -319,9 +312,11 @@ static int vmlogrdr_open (struct inode *inode, struct file *filp)
                return -ENOSYS;
 
        /* Besure this device hasn't already been opened */
+       lock_kernel();
        spin_lock_bh(&logptr->priv_lock);
        if (logptr->dev_in_use) {
                spin_unlock_bh(&logptr->priv_lock);
+               unlock_kernel();
                return -EBUSY;
        }
        logptr->dev_in_use = 1;
@@ -339,8 +334,8 @@ static int vmlogrdr_open (struct inode *inode, struct file *filp)
        if (logptr->autorecording) {
                ret = vmlogrdr_recording(logptr,1,logptr->autopurge);
                if (ret)
-                       printk (KERN_WARNING "vmlogrdr: failed to start "
-                               "recording automatically\n");
+                       pr_warning("vmlogrdr: failed to start "
+                                  "recording automatically\n");
        }
 
        /* create connection to the system service */
@@ -351,9 +346,9 @@ static int vmlogrdr_open (struct inode *inode, struct file *filp)
                                       logptr->system_service, NULL, NULL,
                                       logptr);
        if (connect_rc) {
-               printk (KERN_ERR "vmlogrdr: iucv connection to %s "
-                       "failed with rc %i \n", logptr->system_service,
-                       connect_rc);
+               pr_err("vmlogrdr: iucv connection to %s "
+                      "failed with rc %i \n",
+                      logptr->system_service, connect_rc);
                goto out_path;
        }
 
@@ -365,7 +360,9 @@ static int vmlogrdr_open (struct inode *inode, struct file *filp)
                   || (logptr->iucv_path_severed));
        if (logptr->iucv_path_severed)
                goto out_record;
-       return nonseekable_open(inode, filp);
+       ret = nonseekable_open(inode, filp);
+       unlock_kernel();
+       return ret;
 
 out_record:
        if (logptr->autorecording)
@@ -375,6 +372,7 @@ out_path:
        logptr->path = NULL;
 out_dev:
        logptr->dev_in_use = 0;
+       unlock_kernel();
        return -EIO;
 }
 
@@ -391,8 +389,8 @@ static int vmlogrdr_release (struct inode *inode, struct file *filp)
        if (logptr->autorecording) {
                ret = vmlogrdr_recording(logptr,0,logptr->autopurge);
                if (ret)
-                       printk (KERN_WARNING "vmlogrdr: failed to stop "
-                               "recording automatically\n");
+                       pr_warning("vmlogrdr: failed to stop "
+                                  "recording automatically\n");
        }
        logptr->dev_in_use = 0;
 
@@ -429,7 +427,7 @@ static int vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv)
                        buffer = priv->buffer + sizeof(int);
                }
                /*
-                * If the record is bigger then our buffer, we receive only
+                * If the record is bigger than our buffer, we receive only
                 * a part of it. We can get the rest later.
                 */
                if (iucv_data_count > NET_BUFFER_SIZE)
@@ -439,7 +437,7 @@ static int vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv)
                                          0, buffer, iucv_data_count,
                                          &priv->residual_length);
                spin_unlock_bh(&priv->priv_lock);
-               /* An rc of 5 indicates that the record was bigger then
+               /* An rc of 5 indicates that the record was bigger than
                 * the buffer, which is OK for us. A 9 indicates that the
                 * record was purged befor we could receive it.
                 */
@@ -567,10 +565,7 @@ static ssize_t vmlogrdr_purge_store(struct device * dev,
                         "RECORDING %s PURGE ",
                         priv->recording_name);
 
-       printk (KERN_DEBUG "vmlogrdr: recording command: %s\n", cp_command);
        cpcmd(cp_command, cp_response, sizeof(cp_response), NULL);
-       printk (KERN_DEBUG "vmlogrdr: recording response: %s",
-               cp_response);
 
        return count;
 }
@@ -682,28 +677,20 @@ static int vmlogrdr_register_driver(void)
 
        /* Register with iucv driver */
        ret = iucv_register(&vmlogrdr_iucv_handler, 1);
-       if (ret) {
-               printk (KERN_ERR "vmlogrdr: failed to register with "
-                       "iucv driver\n");
+       if (ret)
                goto out;
-       }
 
        ret = driver_register(&vmlogrdr_driver);
-       if (ret) {
-               printk(KERN_ERR "vmlogrdr: failed to register driver.\n");
+       if (ret)
                goto out_iucv;
-       }
 
        ret = driver_create_file(&vmlogrdr_driver,
                                 &driver_attr_recording_status);
-       if (ret) {
-               printk(KERN_ERR "vmlogrdr: failed to add driver attribute.\n");
+       if (ret)
                goto out_driver;
-       }
 
        vmlogrdr_class = class_create(THIS_MODULE, "vmlogrdr");
        if (IS_ERR(vmlogrdr_class)) {
-               printk(KERN_ERR "vmlogrdr: failed to create class.\n");
                ret = PTR_ERR(vmlogrdr_class);
                vmlogrdr_class = NULL;
                goto out_attr;
@@ -738,8 +725,7 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
 
        dev = kzalloc(sizeof(struct device), GFP_KERNEL);
        if (dev) {
-               snprintf(dev->bus_id, BUS_ID_SIZE, "%s",
-                        priv->internal_name);
+               dev_set_name(dev, priv->internal_name);
                dev->bus = &iucv_bus;
                dev->parent = iucv_root;
                dev->driver = &vmlogrdr_driver;
@@ -765,7 +751,7 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
        priv->class_device = device_create(vmlogrdr_class, dev,
                                           MKDEV(vmlogrdr_major,
                                                 priv->minor_num),
-                                          "%s", dev->bus_id);
+                                          priv, "%s", dev_name(dev));
        if (IS_ERR(priv->class_device)) {
                ret = PTR_ERR(priv->class_device);
                priv->class_device=NULL;
@@ -773,7 +759,6 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
                device_unregister(dev);
                return ret;
        }
-       dev->driver_data = priv;
        priv->device = dev;
        return 0;
 }
@@ -839,8 +824,7 @@ static int __init vmlogrdr_init(void)
        dev_t dev;
 
        if (! MACHINE_IS_VM) {
-               printk (KERN_ERR "vmlogrdr: not running under VM, "
-                               "driver not loaded.\n");
+               pr_err("not running under VM, driver not loaded.\n");
                return -ENODEV;
        }
 
@@ -858,7 +842,7 @@ static int __init vmlogrdr_init(void)
        for (i=0; i < MAXMINOR; ++i ) {
                sys_ser[i].buffer = (char *) get_zeroed_page(GFP_KERNEL);
                if (!sys_ser[i].buffer) {
-                       rc = ENOMEM;
+                       rc = -ENOMEM;
                        break;
                }
                sys_ser[i].current_position = sys_ser[i].buffer;
@@ -872,12 +856,10 @@ static int __init vmlogrdr_init(void)
        rc = vmlogrdr_register_cdev(dev);
        if (rc)
                goto cleanup;
-       printk (KERN_INFO "vmlogrdr: driver loaded\n");
        return 0;
 
 cleanup:
        vmlogrdr_cleanup();
-       printk (KERN_ERR "vmlogrdr: driver not loaded.\n");
        return rc;
 }
 
@@ -885,7 +867,6 @@ cleanup:
 static void __exit vmlogrdr_exit(void)
 {
        vmlogrdr_cleanup();
-       printk (KERN_INFO "vmlogrdr: driver unloaded\n");
        return;
 }