]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/s390/char/sclp_vt220.c
[S390] replace remaining __FUNCTION__ occurrences
[linux-2.6-omap-h63xx.git] / drivers / s390 / char / sclp_vt220.c
index 40cd21bc5cc4dc936191b3b68e1e9febc4c62710..ed507594e62ba0adf12fde30a1ecd23a91509180 100644 (file)
@@ -3,7 +3,7 @@
  *    SCLP VT220 terminal driver.
  *
  *  S390 version
- *    Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *    Copyright IBM Corp. 2003,2008
  *    Author(s): Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com>
  */
 
@@ -202,7 +202,7 @@ sclp_vt220_callback(struct sclp_req *request, void *data)
 static int
 __sclp_vt220_emit(struct sclp_vt220_request *request)
 {
-       if (!(sclp_vt220_register.sclp_send_mask & EVTYP_VT220MSG_MASK)) {
+       if (!(sclp_vt220_register.sclp_receive_mask & EVTYP_VT220MSG_MASK)) {
                request->sclp_req.status = SCLP_REQ_FAILED;
                return -EIO;
        }
@@ -367,7 +367,7 @@ sclp_vt220_timeout(unsigned long data)
        sclp_vt220_emit_current();
 }
 
-#define BUFFER_MAX_DELAY       HZ/2
+#define BUFFER_MAX_DELAY       HZ/20
 
 /* 
  * Internal implementation of the write function. Write COUNT bytes of data
@@ -383,7 +383,7 @@ sclp_vt220_timeout(unsigned long data)
  */
 static int
 __sclp_vt220_write(const unsigned char *buf, int count, int do_schedule,
-                  int convertlf)
+                  int convertlf, int may_schedule)
 {
        unsigned long flags;
        void *page;
@@ -398,9 +398,8 @@ __sclp_vt220_write(const unsigned char *buf, int count, int do_schedule,
                /* Create a sclp output buffer if none exists yet */
                if (sclp_vt220_current_request == NULL) {
                        while (list_empty(&sclp_vt220_empty)) {
-                               spin_unlock_irqrestore(&sclp_vt220_lock,
-                                                      flags);
-                               if (in_interrupt())
+                               spin_unlock_irqrestore(&sclp_vt220_lock, flags);
+                               if (in_interrupt() || !may_schedule)
                                        sclp_sync_wait();
                                else
                                        wait_event(sclp_vt220_waitq,
@@ -450,7 +449,7 @@ __sclp_vt220_write(const unsigned char *buf, int count, int do_schedule,
 static int
 sclp_vt220_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
-       return __sclp_vt220_write(buf, count, 1, 0);
+       return __sclp_vt220_write(buf, count, 1, 0, 1);
 }
 
 #define SCLP_VT220_SESSION_ENDED       0x01
@@ -529,7 +528,7 @@ sclp_vt220_close(struct tty_struct *tty, struct file *filp)
 static void
 sclp_vt220_put_char(struct tty_struct *tty, unsigned char ch)
 {
-       __sclp_vt220_write(&ch, 1, 0, 0);
+       __sclp_vt220_write(&ch, 1, 0, 0, 1);
 }
 
 /*
@@ -632,6 +631,9 @@ static void __init __sclp_vt220_cleanup(void)
                else
                        free_bootmem((unsigned long) page, PAGE_SIZE);
        }
+       if (!list_empty(&sclp_vt220_register.list))
+               sclp_unregister(&sclp_vt220_register);
+       sclp_vt220_initialized = 0;
 }
 
 static int __init __sclp_vt220_init(void)
@@ -639,6 +641,7 @@ static int __init __sclp_vt220_init(void)
        void *page;
        int i;
        int num_pages;
+       int rc;
 
        if (sclp_vt220_initialized)
                return 0;
@@ -667,7 +670,14 @@ static int __init __sclp_vt220_init(void)
                }
                list_add_tail((struct list_head *) page, &sclp_vt220_empty);
        }
-       return 0;
+       rc = sclp_register(&sclp_vt220_register);
+       if (rc) {
+               printk(KERN_ERR SCLP_VT220_PRINT_HEADER
+                      "could not register vt220 - "
+                      "sclp_register returned %d\n", rc);
+               __sclp_vt220_cleanup();
+       }
+       return rc;
 }
 
 static const struct tty_operations sclp_vt220_ops = {
@@ -688,22 +698,17 @@ static int __init sclp_vt220_tty_init(void)
 {
        struct tty_driver *driver;
        int rc;
+       int cleanup;
 
        /* Note: we're not testing for CONSOLE_IS_SCLP here to preserve
         * symmetry between VM and LPAR systems regarding ttyS1. */
        driver = alloc_tty_driver(1);
        if (!driver)
                return -ENOMEM;
+       cleanup = !sclp_vt220_initialized;
        rc = __sclp_vt220_init();
        if (rc)
                goto out_driver;
-       rc = sclp_register(&sclp_vt220_register);
-       if (rc) {
-               printk(KERN_ERR SCLP_VT220_PRINT_HEADER
-                      "could not register tty - "
-                      "sclp_register returned %d\n", rc);
-               goto out_init;
-       }
 
        driver->owner = THIS_MODULE;
        driver->driver_name = SCLP_VT220_DRIVER_NAME;
@@ -721,15 +726,14 @@ static int __init sclp_vt220_tty_init(void)
                printk(KERN_ERR SCLP_VT220_PRINT_HEADER
                       "could not register tty - "
                       "tty_register_driver returned %d\n", rc);
-               goto out_sclp;
+               goto out_init;
        }
        sclp_vt220_driver = driver;
        return 0;
 
-out_sclp:
-       sclp_unregister(&sclp_vt220_register);
 out_init:
-       __sclp_vt220_cleanup();
+       if (cleanup)
+               __sclp_vt220_cleanup();
 out_driver:
        put_tty_driver(driver);
        return rc;
@@ -741,7 +745,7 @@ __initcall(sclp_vt220_tty_init);
 static void
 sclp_vt220_con_write(struct console *con, const char *buf, unsigned int count)
 {
-       __sclp_vt220_write((const unsigned char *) buf, count, 1, 1);
+       __sclp_vt220_write((const unsigned char *) buf, count, 1, 1, 0);
 }
 
 static struct tty_driver *