vserver 2.0 rc7
[linux-2.6.git] / net / irda / ircomm / ircomm_tty.c
index f75949d..5d1e611 100644 (file)
@@ -116,7 +116,7 @@ static int __init ircomm_tty_init(void)
                return -ENOMEM;
        ircomm_tty = hashbin_new(HB_LOCK); 
        if (ircomm_tty == NULL) {
-               ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__);
+               IRDA_ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__);
                put_tty_driver(driver);
                return -ENOMEM;
        }
@@ -134,7 +134,8 @@ static int __init ircomm_tty_init(void)
        driver->flags           = TTY_DRIVER_REAL_RAW;
        tty_set_operations(driver, &ops);
        if (tty_register_driver(driver)) {
-               ERROR("%s(): Couldn't register serial driver\n", __FUNCTION__);
+               IRDA_ERROR("%s(): Couldn't register serial driver\n",
+                          __FUNCTION__);
                put_tty_driver(driver);
                return -1;
        }
@@ -145,8 +146,8 @@ static void __exit __ircomm_tty_cleanup(struct ircomm_tty_cb *self)
 {
        IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
        ircomm_tty_shutdown(self);
 
@@ -168,7 +169,8 @@ static void __exit ircomm_tty_cleanup(void)
 
        ret = tty_unregister_driver(driver);
         if (ret) {
-                ERROR("%s(), failed to unregister driver\n", __FUNCTION__);
+                IRDA_ERROR("%s(), failed to unregister driver\n",
+                          __FUNCTION__);
                return;
        }
 
@@ -189,8 +191,8 @@ static int ircomm_tty_startup(struct ircomm_tty_cb *self)
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
-       ASSERT(self != NULL, return -1;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
+       IRDA_ASSERT(self != NULL, return -1;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
 
        /* Check if already open */
        if (test_and_set_bit(ASYNC_B_INITIALIZED, &self->flags)) {
@@ -224,7 +226,7 @@ static int ircomm_tty_startup(struct ircomm_tty_cb *self)
        /* Connect IrCOMM link with remote device */
        ret = ircomm_tty_attach_cable(self);
        if (ret < 0) {
-               ERROR("%s(), error attaching cable!\n", __FUNCTION__);
+               IRDA_ERROR("%s(), error attaching cable!\n", __FUNCTION__);
                goto err;
        }
 
@@ -381,7 +383,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
                /* No, so make new instance */
                self = kmalloc(sizeof(struct ircomm_tty_cb), GFP_KERNEL);
                if (self == NULL) {
-                       ERROR("%s(), kmalloc failed!\n", __FUNCTION__);
+                       IRDA_ERROR("%s(), kmalloc failed!\n", __FUNCTION__);
                        return -ENOMEM;
                }
                memset(self, 0, sizeof(struct ircomm_tty_cb));
@@ -442,8 +444,8 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
                 */
 
                if (wait_event_interruptible(self->close_wait, !test_bit(ASYNC_B_CLOSING, &self->flags))) {
-                       WARNING("%s - got signal while blocking on ASYNC_CLOSING!\n",
-                               __FUNCTION__);
+                       IRDA_WARNING("%s - got signal while blocking on ASYNC_CLOSING!\n",
+                                    __FUNCTION__);
                        return -ERESTARTSYS;
                }
 
@@ -499,8 +501,8 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
        if (!tty)
                return;
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
        spin_lock_irqsave(&self->spinlock, flags);
 
@@ -526,8 +528,8 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
        }
 
        if (--self->open_count < 0) {
-               ERROR("%s(), bad serial port count for ttys%d: %d\n",
-                     __FUNCTION__, self->line, self->open_count);
+               IRDA_ERROR("%s(), bad serial port count for ttys%d: %d\n",
+                          __FUNCTION__, self->line, self->open_count);
                self->open_count = 0;
        }
        if (self->open_count) {
@@ -586,8 +588,8 @@ static void ircomm_tty_flush_buffer(struct tty_struct *tty)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
        /* 
         * Let do_softint() do this to avoid race condition with 
@@ -671,10 +673,9 @@ static void ircomm_tty_do_softint(void *private_)
  *    accepted for writing. This routine is mandatory.
  */
 static int ircomm_tty_write(struct tty_struct *tty,
-                           const unsigned char *ubuf, int count)
+                           const unsigned char *buf, int count)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
-       unsigned char *kbuf;            /* Buffer in kernel space */
        unsigned long flags;
        struct sk_buff *skb;
        int tailroom = 0;
@@ -684,8 +685,8 @@ static int ircomm_tty_write(struct tty_struct *tty,
        IRDA_DEBUG(2, "%s(), count=%d, hw_stopped=%d\n", __FUNCTION__ , count,
                   tty->hw_stopped);
 
-       ASSERT(self != NULL, return -1;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
+       IRDA_ASSERT(self != NULL, return -1;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
 
        /* We may receive packets from the TTY even before we have finished
         * our setup. Not cool.
@@ -714,9 +715,6 @@ static int ircomm_tty_write(struct tty_struct *tty,
        if (count < 1)
                return 0;
 
-       /* The buffer is already in kernel space */
-       kbuf = (unsigned char *) ubuf;
-
        /* Protect our manipulation of self->tx_skb and related */
        spin_lock_irqsave(&self->spinlock, flags);
 
@@ -779,7 +777,7 @@ static int ircomm_tty_write(struct tty_struct *tty,
                }
 
                /* Copy data */
-               memcpy(skb_put(skb,size), kbuf + len, size);
+               memcpy(skb_put(skb,size), buf + len, size);
 
                count -= size;
                len += size;
@@ -812,8 +810,8 @@ static int ircomm_tty_write_room(struct tty_struct *tty)
        unsigned long flags;
        int ret;
 
-       ASSERT(self != NULL, return -1;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
+       IRDA_ASSERT(self != NULL, return -1;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
 
 #ifdef IRCOMM_NO_TX_BEFORE_INIT
        /* max_header_size tells us if the channel is initialised or not. */
@@ -854,8 +852,8 @@ static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout)
        
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
        orig_jiffies = jiffies;
 
@@ -890,8 +888,8 @@ static void ircomm_tty_throttle(struct tty_struct *tty)
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
        /* Software flow control? */
        if (I_IXOFF(tty))
@@ -921,8 +919,8 @@ static void ircomm_tty_unthrottle(struct tty_struct *tty)
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
        /* Using software flow control? */
        if (I_IXOFF(tty)) {
@@ -951,8 +949,8 @@ static int ircomm_tty_chars_in_buffer(struct tty_struct *tty)
        unsigned long flags;
        int len = 0;
 
-       ASSERT(self != NULL, return -1;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
+       IRDA_ASSERT(self != NULL, return -1;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
 
        spin_lock_irqsave(&self->spinlock, flags);
 
@@ -968,8 +966,8 @@ static void ircomm_tty_shutdown(struct ircomm_tty_cb *self)
 {
        unsigned long flags;
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
        IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
 
@@ -1016,8 +1014,8 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
 
        IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
        if (!tty)
                return;
@@ -1069,8 +1067,8 @@ static void ircomm_tty_stop(struct tty_struct *tty)
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
        ircomm_flow_request(self->ircomm, FLOW_STOP);
 }
@@ -1089,8 +1087,8 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
 
        IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
        tty = self->tty;
 
@@ -1152,9 +1150,9 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
        
-       ASSERT(self != NULL, return -1;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
-       ASSERT(skb != NULL, return -1;);
+       IRDA_ASSERT(self != NULL, return -1;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
+       IRDA_ASSERT(skb != NULL, return -1;);
 
        if (!self->tty) {
                IRDA_DEBUG(0, "%s(), no tty!\n", __FUNCTION__ );
@@ -1202,9 +1200,9 @@ static int ircomm_tty_control_indication(void *instance, void *sap,
 
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
        
-       ASSERT(self != NULL, return -1;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
-       ASSERT(skb != NULL, return -1;);
+       IRDA_ASSERT(self != NULL, return -1;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
+       IRDA_ASSERT(skb != NULL, return -1;);
 
        clen = skb->data[0];
 
@@ -1229,8 +1227,8 @@ static void ircomm_tty_flow_indication(void *instance, void *sap,
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
        struct tty_struct *tty;
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
        tty = self->tty;