]> git.hungrycats.org Git - linux/commitdiff
[PATCH] tty cleanups (9/12)
authorAlexander Viro <viro@www.linux.org.uk>
Wed, 23 Apr 2003 11:19:27 +0000 (04:19 -0700)
committerChristoph Hellwig <hch@lst.de>
Wed, 23 Apr 2003 11:19:27 +0000 (04:19 -0700)
* drivers/char/rio/* supports up to 4 boards, each with up to 128
lines.  It used to share termios for 1st/3rd and 2nd/4th boards,  Fixed.
* cleanups and kdev_t removals - we pass tty instead of tty->device
in a couple of helper functions and instead of comparisons on major(tty->device)
we check where does tty->driver point to.

drivers/char/rio/func.h
drivers/char/rio/rio_linux.c
drivers/char/rio/riotty.c

index 7118ffa2522c48c8440c3934ae17ad368c37e8a5..1e15d1cf0a102bbf7995d9f7827f4b4888e5ccbf 100644 (file)
@@ -139,7 +139,7 @@ int RIORemoveFromSavedTable(struct rio_info *, struct Map *);
 int riotopen(struct tty_struct * tty, struct file * filp);
 int riotclose(void  *ptr);
 int RIOCookMode(struct ttystatics *);
-int riotioctl(struct rio_info *, dev_t, register int, register caddr_t); 
+int riotioctl(struct rio_info *, struct tty_struct *, register int, register caddr_t); 
 void ttyseth(struct Port *, struct ttystatics *, struct old_sgttyb *sg);
 
 /* riotable.c */
@@ -166,8 +166,8 @@ struct rio_info * rio_info_store( int cmd, struct rio_info * p);
 #endif
 
 extern int    rio_pcicopy(char *src, char *dst, int n);
-extern int rio_minor (kdev_t device);
-extern int rio_ismodem (kdev_t device);
+extern int rio_minor (struct tty_struct *tty);
+extern int rio_ismodem (struct tty_struct *tty);
 extern void rio_udelay (int usecs);
 
 extern void rio_start_card_running (struct Host * HostP);
index b17f34eeb3caa419b390534227ae7504e458c155..ea909fd9f678782551b60843ae6a6e40cab86f67 100644 (file)
@@ -293,7 +293,7 @@ struct miscdevice rio_fw_device = {
 /* This doesn't work. Who's paranoid around here? Not me! */
 
 static inline int rio_paranoia_check(struct rio_port const * port,
-                                   kdev_t device, const char *routine)
+                                   char *name, const char *routine)
 {
 
   static const char *badmagic =
@@ -302,11 +302,11 @@ static inline int rio_paranoia_check(struct rio_port const * port,
     KERN_ERR "rio: Warning: null rio port for device %s in %s\n";
  
   if (!port) {
-    printk (badinfo, cdevname(device), routine);
+    printk (badinfo, name, routine);
     return 1;
   }
   if (port->magic != RIO_MAGIC) {
-    printk (badmagic, cdevname(device), routine);
+    printk (badmagic, name, routine);
     return 1;
   }
 
@@ -372,18 +372,15 @@ int RIODelay_ni (struct Port *PortP, int njiffies)
 }
 
 
-int rio_minor (kdev_t device)
+int rio_minor(struct tty_struct *tty)
 {
-  return minor (device) + 
-    256 * ((major (device) == RIO_NORMAL_MAJOR1) ||
-          (major (device) == RIO_CALLOUT_MAJOR1));
+       return tty->index + (tty->driver->termios - rio_termios);
 }
 
 
-int rio_ismodem (kdev_t device)
+int rio_ismodem(struct tty_struct *tty)
 {
-  return (major (device) == RIO_NORMAL_MAJOR0) ||
-         (major (device) == RIO_NORMAL_MAJOR1);
+       return tty->driver == &rio_driver || tty->driver == &rio_driver2;
 }
 
 
@@ -423,7 +420,7 @@ static int rio_set_real_termios (void *ptr)
 
   tty = ((struct Port *)ptr)->gs.tty;
 
-  modem = (major(tty->device) == RIO_NORMAL_MAJOR0) || (major(tty->device) == RIO_NORMAL_MAJOR1);
+  modem = rio_ismodem(tty);
 
   rv = RIOParam( (struct Port *) ptr, CONFIG, modem, 1);
 
@@ -942,7 +939,9 @@ static int rio_init_drivers(void)
   rio_driver.hangup = gs_hangup;
 
   rio_driver2 = rio_driver;
-  rio_driver.major = RIO_NORMAL_MAJOR1;
+  rio_driver2.major = RIO_NORMAL_MAJOR1;
+  rio_driver2.termios += 256;
+  rio_driver2.termios_locked += 256;
 
   rio_callout_driver = rio_driver;
   rio_callout_driver.name = "cusr";
@@ -951,6 +950,8 @@ static int rio_init_drivers(void)
 
   rio_callout_driver2 = rio_callout_driver;
   rio_callout_driver2.major = RIO_CALLOUT_MAJOR1;
+  rio_callout_driver2.termios += 256;
+  rio_callout_driver2.termios_locked += 256;
 
   rio_dprintk (RIO_DEBUG_INIT, "set_termios = %p\n", gs_set_termios);
 
index 8d3482da81d573ffdb760dffcede54be5f1fa1f9..4e4a268231d151cde452b8fc0208f1eb0070b692 100644 (file)
@@ -159,8 +159,8 @@ riotopen(struct tty_struct * tty, struct file * filp)
        */
        tty->driver_data = NULL;
         
-       SysPort = rio_minor (tty->device);
-       Modem   = rio_ismodem (tty->device);
+       SysPort = rio_minor(tty);
+       Modem   = rio_ismodem(tty);
 
        if ( p->RIOFailed ) {
                rio_dprintk (RIO_DEBUG_TTY, "System initialisation failed\n");
@@ -549,7 +549,7 @@ riotclose(void  *ptr)
        else 
                end_time = jiffies + MAX_SCHEDULE_TIMEOUT;
 
-       Modem = rio_ismodem(tty->device);
+       Modem = rio_ismodem(tty);
 #if 0
        /* What F.CKING cache? Even then, a higly idle multiprocessor,
           system with large caches this won't work . Better find out when 
@@ -882,11 +882,7 @@ int RIOShortCommand(struct rio_info *p, struct Port *PortP,
 ** its all about.
 */
 int
-riotioctl(p, dev, cmd, arg)
-struct rio_info *              p;
-dev_t dev;
-register int cmd;
-register caddr_t arg;
+riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
 {
        register struct         Port *PortP;
        register struct         ttystatics *tp;
@@ -898,8 +894,8 @@ register caddr_t arg;
        short                           vpix_cflag;
        short                           divisor;
        int                                     baud;
-       uint                            SysPort = dev;
-       int                                     Modem = rio_ismodem(dev);
+       uint                            SysPort = rio_minor(tty);
+       int                             Modem = rio_ismodem(tty);
        int                                     ioctl_processed;
 
        rio_dprintk (RIO_DEBUG_TTY, "port ioctl SysPort %d command 0x%x argument 0x%x %s\n",