Commit b695aea2 authored by Alexander Viro's avatar Alexander Viro Committed by Christoph Hellwig

[PATCH] tty cleanups (9/12)

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