]> git.hungrycats.org Git - linux/commitdiff
[IRDA]: Migrate TIOCMGET and TIOCMSET ioctls in IrCOMM to the new TTY API.
authorJean Tourrilhes <jt@bougret.hpl.hp.com>
Wed, 14 Jan 2004 16:24:32 +0000 (08:24 -0800)
committerDavid S. Miller <davem@nuts.ninka.net>
Wed, 14 Jan 2004 16:24:32 +0000 (08:24 -0800)
Patch from Russell King.

include/net/irda/ircomm_tty.h
net/irda/ircomm/ircomm_tty.c
net/irda/ircomm/ircomm_tty_ioctl.c

index b1f19269c0266b2b325035a464d2b6b9e8d307c4..d0e60ddf43a05f616c3091a587c980b21b40d61f 100644 (file)
@@ -122,6 +122,9 @@ void ircomm_tty_stop(struct tty_struct *tty);
 void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self);
 
 extern void ircomm_tty_change_speed(struct ircomm_tty_cb *self);
+extern int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file);
+extern int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file,
+                              unsigned int set, unsigned int clear);
 extern int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file, 
                            unsigned int cmd, unsigned long arg);
 extern void ircomm_tty_set_termios(struct tty_struct *tty, 
index 3dd5b294c58d93654cdb507a26fad6f3b5e58942..6b9ae8cd9062c5d66e36469f09ab8c9d0edc98b3 100644 (file)
@@ -86,7 +86,9 @@ static struct tty_operations ops = {
        .write_room      = ircomm_tty_write_room,
        .chars_in_buffer = ircomm_tty_chars_in_buffer,
        .flush_buffer    = ircomm_tty_flush_buffer,
-       .ioctl           = ircomm_tty_ioctl,
+       .ioctl           = ircomm_tty_ioctl,    /* ircomm_tty_ioctl.c */
+       .tiocmget        = ircomm_tty_tiocmget, /* ircomm_tty_ioctl.c */
+       .tiocmset        = ircomm_tty_tiocmset, /* ircomm_tty_ioctl.c */
        .throttle        = ircomm_tty_throttle,
        .unthrottle      = ircomm_tty_unthrottle,
        .send_xchar      = ircomm_tty_send_xchar,
index d1ce743b57710f5074b9a4b91ec967de8aedb471..cf5778686c105c3684265efda382249a17715b23 100644 (file)
@@ -190,81 +190,62 @@ void ircomm_tty_set_termios(struct tty_struct *tty,
 }
 
 /*
- * Function ircomm_tty_get_modem_info (self, value)
+ * Function ircomm_tty_tiocmget (tty, file)
  *
  *    
  *
  */
-static int ircomm_tty_get_modem_info(struct ircomm_tty_cb *self, 
-                                    unsigned int *value)
+int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
        unsigned int result;
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
+       if (tty->flags & (1 << TTY_IO_ERROR))
+               return -EIO;
+
        result =  ((self->settings.dte & IRCOMM_RTS) ? TIOCM_RTS : 0)
                | ((self->settings.dte & IRCOMM_DTR) ? TIOCM_DTR : 0)
                | ((self->settings.dce & IRCOMM_CD)  ? TIOCM_CAR : 0)
                | ((self->settings.dce & IRCOMM_RI)  ? TIOCM_RNG : 0)
                | ((self->settings.dce & IRCOMM_DSR) ? TIOCM_DSR : 0)
                | ((self->settings.dce & IRCOMM_CTS) ? TIOCM_CTS : 0);
-
-       return put_user(result, value);
+       return result;
 }
 
 /*
- * Function set_modem_info (driver, cmd, value)
+ * Function ircomm_tty_tiocmset (tty, file, set, clear)
  *
  *    
  *
  */
-static int ircomm_tty_set_modem_info(struct ircomm_tty_cb *self, 
-                                    unsigned int cmd, unsigned int *value)
+int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file,
+                       unsigned int set, unsigned int clear)
 { 
-       unsigned int arg;
-       __u8 old_rts, old_dtr;
+       struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
+       if (tty->flags & (1 << TTY_IO_ERROR))
+               return -EIO;
+
        ASSERT(self != NULL, return -1;);
        ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
 
-       if (get_user(arg, value))
-               return -EFAULT;
+       if (set & TIOCM_RTS)
+               self->settings.dte |= IRCOMM_RTS;
+       if (set & TIOCM_DTR)
+               self->settings.dte |= IRCOMM_DTR;
 
-       old_rts = self->settings.dte & IRCOMM_RTS;
-       old_dtr = self->settings.dte & IRCOMM_DTR;
+       if (clear & TIOCM_RTS)
+               self->settings.dte &= ~IRCOMM_RTS;
+       if (clear & TIOCM_DTR)
+               self->settings.dte &= ~IRCOMM_DTR;
 
-       switch (cmd) {
-       case TIOCMBIS: 
-               if (arg & TIOCM_RTS) 
-                       self->settings.dte |= IRCOMM_RTS;
-               if (arg & TIOCM_DTR)
-                       self->settings.dte |= IRCOMM_DTR;
-               break;
-               
-       case TIOCMBIC:
-               if (arg & TIOCM_RTS)
-                       self->settings.dte &= ~IRCOMM_RTS;
-               if (arg & TIOCM_DTR)
-                       self->settings.dte &= ~IRCOMM_DTR;
-               break;
-               
-       case TIOCMSET:
-               self->settings.dte = 
-                       ((self->settings.dte & ~(IRCOMM_RTS | IRCOMM_DTR))
-                        | ((arg & TIOCM_RTS) ? IRCOMM_RTS : 0)
-                        | ((arg & TIOCM_DTR) ? IRCOMM_DTR : 0));
-               break;
-               
-       default:
-               return -EINVAL;
-       }
-       
-       if ((self->settings.dte & IRCOMM_RTS) != old_rts)
+       if ((set|clear) & TIOCM_RTS)
                self->settings.dte |= IRCOMM_DELTA_RTS;
-
-       if ((self->settings.dte & IRCOMM_DTR) != old_dtr)
+       if ((set|clear) & TIOCM_DTR)
                self->settings.dte |= IRCOMM_DELTA_DTR;
 
        ircomm_param_request(self, IRCOMM_DTE, TRUE);
@@ -406,14 +387,6 @@ int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file,
        }
 
        switch (cmd) {
-       case TIOCMGET:
-               ret = ircomm_tty_get_modem_info(self, (unsigned int *) arg);
-               break;
-       case TIOCMBIS:
-       case TIOCMBIC:
-       case TIOCMSET:
-               ret = ircomm_tty_set_modem_info(self, cmd, (unsigned int *) arg);
-               break;
        case TIOCGSERIAL:
                ret = ircomm_tty_get_serial_info(self, (struct serial_struct *) arg);
                break;