From 8d8706e2f86d28814c1b40a116ffdeca35e4c949 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 11 Jan 2006 12:17:49 -0800 Subject: [PATCH] lindent rio drivers Run all rio files through indent -kr -i8 -bri0 -l255, as requested by Alan. rioboot.c and rioinit.c were skipped due to worrisome lindent warnings. Cc: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/rio/riotty.c | 1224 ++++++++++++++++++++++----------------------- 1 file changed, 590 insertions(+), 634 deletions(-) (limited to 'drivers/char/rio/riotty.c') diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c index 78a321afdf4f..5894a25b0113 100644 --- a/drivers/char/rio/riotty.c +++ b/drivers/char/rio/riotty.c @@ -90,21 +90,19 @@ static char *_riotty_c_sccs_ = "@(#)riotty.c 1.3"; #include "sam.h" #if 0 -static void ttyseth_pv(struct Port *, struct ttystatics *, - struct termios *sg, int); +static void ttyseth_pv(struct Port *, struct ttystatics *, struct termios *sg, int); #endif static void RIOClearUp(struct Port *PortP); -int RIOShortCommand(struct rio_info *p, struct Port *PortP, - int command, int len, int arg); +int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg); #if 0 static int RIOCookMode(struct ttystatics *); #endif -extern int conv_vb[]; /* now defined in ttymgr.c */ -extern int conv_bv[]; /* now defined in ttymgr.c */ - +extern int conv_vb[]; /* now defined in ttymgr.c */ +extern int conv_bv[]; /* now defined in ttymgr.c */ + /* ** 16.09.1998 ARG - Fix to build riotty.k.o for Modular Kernel Support ** @@ -117,27 +115,25 @@ extern int conv_bv[]; /* now defined in ttymgr.c */ #endif #ifdef NEED_THIS2 -static struct old_sgttyb -default_sg = -{ - B19200, B19200, /* input and output speed */ - 'H' - '@', /* erase char */ - -1, /* 2nd erase char */ - 'U' - '@', /* kill char */ - ECHO | CRMOD, /* mode */ - 'C' - '@', /* interrupt character */ - '\\' - '@', /* quit char */ - 'Q' - '@', /* start char */ - 'S' - '@', /* stop char */ - 'D' - '@', /* EOF */ - -1, /* brk */ - (LCRTBS | LCRTERA | LCRTKIL | LCTLECH), /* local mode word */ - 'Z' - '@', /* process stop */ - 'Y' - '@', /* delayed stop */ - 'R' - '@', /* reprint line */ - 'O' - '@', /* flush output */ - 'W' - '@', /* word erase */ - 'V' - '@' /* literal next char */ +static struct old_sgttyb default_sg = { + B19200, B19200, /* input and output speed */ + 'H' - '@', /* erase char */ + -1, /* 2nd erase char */ + 'U' - '@', /* kill char */ + ECHO | CRMOD, /* mode */ + 'C' - '@', /* interrupt character */ + '\\' - '@', /* quit char */ + 'Q' - '@', /* start char */ + 'S' - '@', /* stop char */ + 'D' - '@', /* EOF */ + -1, /* brk */ + (LCRTBS | LCRTERA | LCRTKIL | LCTLECH), /* local mode word */ + 'Z' - '@', /* process stop */ + 'Y' - '@', /* delayed stop */ + 'R' - '@', /* reprint line */ + 'O' - '@', /* flush output */ + 'W' - '@', /* word erase */ + 'V' - '@' /* literal next char */ }; #endif @@ -145,62 +141,59 @@ default_sg = extern struct rio_info *p; -int -riotopen(struct tty_struct * tty, struct file * filp) +int riotopen(struct tty_struct *tty, struct file *filp) { register uint SysPort; int Modem; int repeat_this = 250; - struct Port *PortP; /* pointer to the port structure */ + struct Port *PortP; /* pointer to the port structure */ unsigned long flags; int retval = 0; - func_enter (); + func_enter(); /* Make sure driver_data is NULL in case the rio isn't booted jet. Else gs_close is going to oops. - */ + */ tty->driver_data = NULL; - + SysPort = rio_minor(tty); - Modem = rio_ismodem(tty); + Modem = rio_ismodem(tty); - if ( p->RIOFailed ) { - rio_dprintk (RIO_DEBUG_TTY, "System initialisation failed\n"); + if (p->RIOFailed) { + rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n"); pseterr(ENXIO); - func_exit (); + func_exit(); return -ENXIO; } - rio_dprintk (RIO_DEBUG_TTY, "port open SysPort %d (%s) (mapped:%d)\n", - SysPort, Modem ? "Modem" : "tty", - p->RIOPortp[SysPort]->Mapped); + rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (%s) (mapped:%d)\n", SysPort, Modem ? "Modem" : "tty", p->RIOPortp[SysPort]->Mapped); /* - ** Validate that we have received a legitimate request. - ** Currently, just check that we are opening a port on - ** a host card that actually exists, and that the port - ** has been mapped onto a host. - */ + ** Validate that we have received a legitimate request. + ** Currently, just check that we are opening a port on + ** a host card that actually exists, and that the port + ** has been mapped onto a host. + */ if (SysPort >= RIO_PORTS) { /* out of range ? */ - rio_dprintk (RIO_DEBUG_TTY, "Illegal port number %d\n",SysPort); + rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort); pseterr(ENXIO); func_exit(); return -ENXIO; } /* - ** Grab pointer to the port stucture - */ + ** Grab pointer to the port stucture + */ PortP = p->RIOPortp[SysPort]; /* Get control struc */ - rio_dprintk (RIO_DEBUG_TTY, "PortP: %p\n", PortP); - if ( !PortP->Mapped ) { /* we aren't mapped yet! */ + rio_dprintk(RIO_DEBUG_TTY, "PortP: %p\n", PortP); + if (!PortP->Mapped) { /* we aren't mapped yet! */ /* - ** The system doesn't know which RTA this port - ** corresponds to. - */ - rio_dprintk (RIO_DEBUG_TTY, "port not mapped into system\n"); - func_exit (); + ** The system doesn't know which RTA this port + ** corresponds to. + */ + rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n"); + func_exit(); pseterr(ENXIO); return -ENXIO; } @@ -210,132 +203,131 @@ riotopen(struct tty_struct * tty, struct file * filp) PortP->gs.tty = tty; PortP->gs.count++; - rio_dprintk (RIO_DEBUG_TTY, "%d bytes in tx buffer\n", - PortP->gs.xmit_cnt); + rio_dprintk(RIO_DEBUG_TTY, "%d bytes in tx buffer\n", PortP->gs.xmit_cnt); - retval = gs_init_port (&PortP->gs); + retval = gs_init_port(&PortP->gs); if (retval) { PortP->gs.count--; return -ENXIO; } /* - ** If the host hasn't been booted yet, then - ** fail - */ - if ( (PortP->HostP->Flags & RUN_STATE) != RC_RUNNING ) { - rio_dprintk (RIO_DEBUG_TTY, "Host not running\n"); + ** If the host hasn't been booted yet, then + ** fail + */ + if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) { + rio_dprintk(RIO_DEBUG_TTY, "Host not running\n"); pseterr(ENXIO); - func_exit (); + func_exit(); return -ENXIO; } /* - ** If the RTA has not booted yet and the user has choosen to block - ** until the RTA is present then we must spin here waiting for - ** the RTA to boot. - */ + ** If the RTA has not booted yet and the user has choosen to block + ** until the RTA is present then we must spin here waiting for + ** the RTA to boot. + */ #if 0 if (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) { if (PortP->WaitUntilBooted) { - rio_dprintk (RIO_DEBUG_TTY, "Waiting for RTA to boot\n"); + rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot\n"); do { if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { - rio_dprintk (RIO_DEBUG_TTY, "RTA EINTR in delay \n"); - func_exit (); + rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n"); + func_exit(); return -EINTR; } - if (repeat_this -- <= 0) { - rio_dprintk (RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n"); - RIOPreemptiveCmd(p, PortP, FCLOSE ); + if (repeat_this-- <= 0) { + rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n"); + RIOPreemptiveCmd(p, PortP, FCLOSE); pseterr(EINTR); - func_exit (); + func_exit(); return -EIO; } - } while(!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)); - rio_dprintk (RIO_DEBUG_TTY, "RTA has been booted\n"); + } while (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)); + rio_dprintk(RIO_DEBUG_TTY, "RTA has been booted\n"); } else { - rio_dprintk (RIO_DEBUG_TTY, "RTA never booted\n"); + rio_dprintk(RIO_DEBUG_TTY, "RTA never booted\n"); pseterr(ENXIO); - func_exit (); + func_exit(); return 0; } } #else /* I find the above code a bit hairy. I find the below code - easier to read and shorter. Now, if it works too that would + easier to read and shorter. Now, if it works too that would be great... -- REW - */ - rio_dprintk (RIO_DEBUG_TTY, "Checking if RTA has booted... \n"); + */ + rio_dprintk(RIO_DEBUG_TTY, "Checking if RTA has booted... \n"); while (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) { - if (!PortP->WaitUntilBooted) { - rio_dprintk (RIO_DEBUG_TTY, "RTA never booted\n"); - func_exit (); - return -ENXIO; - } - - /* Under Linux you'd normally use a wait instead of this - busy-waiting. I'll stick with the old implementation for - now. --REW - */ - if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { - rio_dprintk (RIO_DEBUG_TTY, "RTA_wait_for_boot: EINTR in delay \n"); - func_exit (); - return -EINTR; - } - if (repeat_this -- <= 0) { - rio_dprintk (RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n"); - func_exit (); - return -EIO; - } + if (!PortP->WaitUntilBooted) { + rio_dprintk(RIO_DEBUG_TTY, "RTA never booted\n"); + func_exit(); + return -ENXIO; + } + + /* Under Linux you'd normally use a wait instead of this + busy-waiting. I'll stick with the old implementation for + now. --REW + */ + if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { + rio_dprintk(RIO_DEBUG_TTY, "RTA_wait_for_boot: EINTR in delay \n"); + func_exit(); + return -EINTR; + } + if (repeat_this-- <= 0) { + rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n"); + func_exit(); + return -EIO; + } } - rio_dprintk (RIO_DEBUG_TTY, "RTA has been booted\n"); + rio_dprintk(RIO_DEBUG_TTY, "RTA has been booted\n"); #endif #if 0 - tp = PortP->TtyP; /* get tty struct */ + tp = PortP->TtyP; /* get tty struct */ #endif rio_spin_lock_irqsave(&PortP->portSem, flags); - if ( p->RIOHalted ) { + if (p->RIOHalted) { goto bombout; } #if 0 retval = gs_init_port(&PortP->gs); - if (retval){ - func_exit (); + if (retval) { + func_exit(); return retval; } #endif /* - ** If the port is in the final throws of being closed, - ** we should wait here (politely), waiting - ** for it to finish, so that it doesn't close us! - */ - while ( (PortP->State & RIO_CLOSING) && !p->RIOHalted ) { - rio_dprintk (RIO_DEBUG_TTY, "Waiting for RIO_CLOSING to go away\n"); - if (repeat_this -- <= 0) { - rio_dprintk (RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); - RIOPreemptiveCmd(p, PortP, FCLOSE ); + ** If the port is in the final throws of being closed, + ** we should wait here (politely), waiting + ** for it to finish, so that it doesn't close us! + */ + while ((PortP->State & RIO_CLOSING) && !p->RIOHalted) { + rio_dprintk(RIO_DEBUG_TTY, "Waiting for RIO_CLOSING to go away\n"); + if (repeat_this-- <= 0) { + rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); + RIOPreemptiveCmd(p, PortP, FCLOSE); retval = -EINTR; goto bombout; } rio_spin_unlock_irqrestore(&PortP->portSem, flags); if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { - rio_spin_lock_irqsave(&PortP->portSem, flags); + rio_spin_lock_irqsave(&PortP->portSem, flags); retval = -EINTR; goto bombout; } - rio_spin_lock_irqsave(&PortP->portSem, flags); + rio_spin_lock_irqsave(&PortP->portSem, flags); } - if ( !PortP->Mapped ) { - rio_dprintk (RIO_DEBUG_TTY, "Port unmapped while closing!\n"); + if (!PortP->Mapped) { + rio_dprintk(RIO_DEBUG_TTY, "Port unmapped while closing!\n"); rio_spin_unlock_irqrestore(&PortP->portSem, flags); retval = -ENXIO; - func_exit (); + func_exit(); return retval; } - if ( p->RIOHalted ) { + if (p->RIOHalted) { goto bombout; } @@ -346,16 +338,16 @@ riotopen(struct tty_struct * tty, struct file * filp) */ /* Uh? Suppose I turn these on and then another process opens the port again? The flags get cleared! Not good. -- REW */ - if ( !(PortP->State & (RIO_LOPEN | RIO_MOPEN)) ) { - PortP->Config &= ~(RIO_CTSFLOW|RIO_RTSFLOW); + if (!(PortP->State & (RIO_LOPEN | RIO_MOPEN))) { + PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW); } if (!(PortP->firstOpen)) { /* First time ? */ - rio_dprintk (RIO_DEBUG_TTY, "First open for this port\n"); - + rio_dprintk(RIO_DEBUG_TTY, "First open for this port\n"); + PortP->firstOpen++; - PortP->CookMode = 0; /* XXX RIOCookMode(tp); */ + PortP->CookMode = 0; /* XXX RIOCookMode(tp); */ PortP->InUse = NOT_INUSE; /* Tentative fix for bug PR27. Didn't work. */ @@ -363,26 +355,26 @@ riotopen(struct tty_struct * tty, struct file * filp) rio_spin_unlock_irqrestore(&PortP->portSem, flags); #ifdef NEED_THIS - ttyseth(PortP, tp, (struct old_sgttyb *)&default_sg); + ttyseth(PortP, tp, (struct old_sgttyb *) &default_sg); #endif /* Someone explain to me why this delay/config is - here. If I read the docs correctly the "open" - command piggybacks the parameters immediately. + here. If I read the docs correctly the "open" + command piggybacks the parameters immediately. -- REW */ - RIOParam(PortP,OPEN,Modem,OK_TO_SLEEP); /* Open the port */ + RIOParam(PortP, OPEN, Modem, OK_TO_SLEEP); /* Open the port */ #if 0 /* This delay of 1 second was annoying. I removed it. -- REW */ - RIODelay(PortP, HUNDRED_MS*10); - RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); /* Config the port */ + RIODelay(PortP, HUNDRED_MS * 10); + RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP); /* Config the port */ #endif rio_spin_lock_irqsave(&PortP->portSem, flags); /* - ** wait for the port to be not closed. - */ - while ( !(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted ) { - rio_dprintk (RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n",PortP->PortState); + ** wait for the port to be not closed. + */ + while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) { + rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState); /* ** 15.10.1998 ARG - ESIL 0759 ** (Part) fix for port being trashed when opened whilst RTA "disconnected" @@ -399,115 +391,109 @@ riotopen(struct tty_struct * tty, struct file * filp) */ rio_spin_unlock_irqrestore(&PortP->portSem, flags); if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { - rio_dprintk (RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n"); - RIOPreemptiveCmd(p, PortP, FCLOSE ); - func_exit (); + rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n"); + RIOPreemptiveCmd(p, PortP, FCLOSE); + func_exit(); return -EINTR; } rio_spin_lock_irqsave(&PortP->portSem, flags); } - if ( p->RIOHalted ) { - retval = -EIO; -bombout: - /* RIOClearUp( PortP ); */ + if (p->RIOHalted) { + retval = -EIO; + bombout: + /* RIOClearUp( PortP ); */ rio_spin_unlock_irqrestore(&PortP->portSem, flags); return retval; } - rio_dprintk (RIO_DEBUG_TTY, "PORT_ISOPEN found\n"); + rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n"); } - -#ifdef MODEM_SUPPORT +#ifdef MODEM_SUPPORT if (Modem) { - rio_dprintk (RIO_DEBUG_TTY, "Modem - test for carrier\n"); + rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n"); /* - ** ACTION - ** insert test for carrier here. -- ??? - ** I already see that test here. What's the deal? -- REW - */ - if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) - { - rio_dprintk (RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort); + ** ACTION + ** insert test for carrier here. -- ??? + ** I already see that test here. What's the deal? -- REW + */ + if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) { + rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort); /* - tp->tm.c_state |= CARR_ON; - wakeup((caddr_t) &tp->tm.c_canq); - */ + tp->tm.c_state |= CARR_ON; + wakeup((caddr_t) &tp->tm.c_canq); + */ PortP->State |= RIO_CARR_ON; - wake_up_interruptible (&PortP->gs.open_wait); - } - else /* no carrier - wait for DCD */ - { - /* - while (!(PortP->gs.tty->termios->c_state & CARR_ON) && - !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted ) - */ - while (!(PortP->State & RIO_CARR_ON) && - !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted ) { - - rio_dprintk (RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n",SysPort); + wake_up_interruptible(&PortP->gs.open_wait); + } else { /* no carrier - wait for DCD */ + + /* + while (!(PortP->gs.tty->termios->c_state & CARR_ON) && + !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted ) + */ + while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) { + + rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort); /* - PortP->gs.tty->termios->c_state |= WOPEN; - */ + PortP->gs.tty->termios->c_state |= WOPEN; + */ PortP->State |= RIO_WOPEN; rio_spin_unlock_irqrestore(&PortP->portSem, flags); - if (RIODelay (PortP, HUNDRED_MS) == RIO_FAIL) + if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) #if 0 - if ( sleep((caddr_t)&tp->tm.c_canqo, TTIPRI|PCATCH)) + if (sleep((caddr_t) & tp->tm.c_canqo, TTIPRI | PCATCH)) #endif - { - /* - ** ACTION: verify that this is a good thing - ** to do here. -- ??? - ** I think it's OK. -- REW - */ - rio_dprintk (RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", - SysPort); - RIOPreemptiveCmd( p, PortP, FCLOSE ); - /* - tp->tm.c_state &= ~WOPEN; - */ - PortP->State &= ~RIO_WOPEN; - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - func_exit (); - return -EINTR; - } + { + /* + ** ACTION: verify that this is a good thing + ** to do here. -- ??? + ** I think it's OK. -- REW + */ + rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort); + RIOPreemptiveCmd(p, PortP, FCLOSE); + /* + tp->tm.c_state &= ~WOPEN; + */ + PortP->State &= ~RIO_WOPEN; + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + func_exit(); + return -EINTR; + } } PortP->State &= ~RIO_WOPEN; } - if ( p->RIOHalted ) + if (p->RIOHalted) goto bombout; - rio_dprintk (RIO_DEBUG_TTY, "Setting RIO_MOPEN\n"); + rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n"); PortP->State |= RIO_MOPEN; - } - else + } else #endif { /* - ** ACTION - ** Direct line open - force carrier (will probably mean - ** that sleeping Modem line fubar) - */ + ** ACTION + ** Direct line open - force carrier (will probably mean + ** that sleeping Modem line fubar) + */ PortP->State |= RIO_LOPEN; } - if ( p->RIOHalted ) { + if (p->RIOHalted) { goto bombout; } - rio_dprintk (RIO_DEBUG_TTY, "high level open done\n"); + rio_dprintk(RIO_DEBUG_TTY, "high level open done\n"); #ifdef STATS PortP->Stat.OpenCnt++; #endif /* - ** Count opens for port statistics reporting - */ + ** Count opens for port statistics reporting + */ if (PortP->statsGather) PortP->opens++; rio_spin_unlock_irqrestore(&PortP->portSem, flags); - rio_dprintk (RIO_DEBUG_TTY, "Returning from open\n"); - func_exit (); + rio_dprintk(RIO_DEBUG_TTY, "Returning from open\n"); + func_exit(); return 0; } @@ -516,36 +502,35 @@ bombout: ** The operating system thinks that this is last close for the device. ** As there are two interfaces to the port (Modem and tty), we need to ** check that both are closed before we close the device. -*/ -int -riotclose(void *ptr) +*/ +int riotclose(void *ptr) { #if 0 register uint SysPort = dev; - struct ttystatics *tp; /* pointer to our ttystruct */ + struct ttystatics *tp; /* pointer to our ttystruct */ #endif struct Port *PortP = ptr; /* pointer to the port structure */ int deleted = 0; - int try = -1; /* Disable the timeouts by setting them to -1 */ - int repeat_this = -1; /* Congrats to those having 15 years of - uptime! (You get to break the driver.) */ + int try = -1; /* Disable the timeouts by setting them to -1 */ + int repeat_this = -1; /* Congrats to those having 15 years of + uptime! (You get to break the driver.) */ unsigned long end_time; - struct tty_struct * tty; + struct tty_struct *tty; unsigned long flags; int Modem; int rv = 0; - - rio_dprintk (RIO_DEBUG_TTY, "port close SysPort %d\n",PortP->PortNum); + + rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum); /* PortP = p->RIOPortp[SysPort]; */ - rio_dprintk (RIO_DEBUG_TTY, "Port is at address 0x%x\n",(int)PortP); - /* tp = PortP->TtyP;*/ /* Get tty */ + rio_dprintk(RIO_DEBUG_TTY, "Port is at address 0x%x\n", (int) PortP); + /* tp = PortP->TtyP; *//* Get tty */ tty = PortP->gs.tty; - rio_dprintk (RIO_DEBUG_TTY, "TTY is at address 0x%x\n",(int)tty); + rio_dprintk(RIO_DEBUG_TTY, "TTY is at address 0x%x\n", (int) tty); - if (PortP->gs.closing_wait) + if (PortP->gs.closing_wait) end_time = jiffies + PortP->gs.closing_wait; - else + else end_time = jiffies + MAX_SCHEDULE_TIMEOUT; Modem = rio_ismodem(tty); @@ -553,48 +538,48 @@ riotclose(void *ptr) /* What F.CKING cache? Even then, a higly idle multiprocessor, system with large caches this won't work . Better find out when this doesn't work asap, and fix the cause. -- REW */ - - RIODelay(PortP, HUNDRED_MS*10); /* To flush the cache */ + + RIODelay(PortP, HUNDRED_MS * 10); /* To flush the cache */ #endif rio_spin_lock_irqsave(&PortP->portSem, flags); /* - ** Setting this flag will make any process trying to open - ** this port block until we are complete closing it. - */ + ** Setting this flag will make any process trying to open + ** this port block until we are complete closing it. + */ PortP->State |= RIO_CLOSING; - if ( (PortP->State & RIO_DELETED) ) { - rio_dprintk (RIO_DEBUG_TTY, "Close on deleted RTA\n"); + if ((PortP->State & RIO_DELETED)) { + rio_dprintk(RIO_DEBUG_TTY, "Close on deleted RTA\n"); deleted = 1; } - - if ( p->RIOHalted ) { - RIOClearUp( PortP ); + + if (p->RIOHalted) { + RIOClearUp(PortP); rv = -EIO; goto close_end; } - rio_dprintk (RIO_DEBUG_TTY, "Clear bits\n"); + rio_dprintk(RIO_DEBUG_TTY, "Clear bits\n"); /* - ** clear the open bits for this device - */ + ** clear the open bits for this device + */ PortP->State &= (Modem ? ~RIO_MOPEN : ~RIO_LOPEN); PortP->State &= ~RIO_CARR_ON; PortP->ModemState &= ~MSVR1_CD; /* - ** If the device was open as both a Modem and a tty line - ** then we need to wimp out here, as the port has not really - ** been finally closed (gee, whizz!) The test here uses the - ** bit for the OTHER mode of operation, to see if THAT is - ** still active! - */ - if ( (PortP->State & (RIO_LOPEN|RIO_MOPEN)) ) { + ** If the device was open as both a Modem and a tty line + ** then we need to wimp out here, as the port has not really + ** been finally closed (gee, whizz!) The test here uses the + ** bit for the OTHER mode of operation, to see if THAT is + ** still active! + */ + if ((PortP->State & (RIO_LOPEN | RIO_MOPEN))) { /* - ** The port is still open for the other task - - ** return, pretending that we are still active. - */ - rio_dprintk (RIO_DEBUG_TTY, "Channel %d still open !\n",PortP->PortNum); + ** The port is still open for the other task - + ** return, pretending that we are still active. + */ + rio_dprintk(RIO_DEBUG_TTY, "Channel %d still open !\n", PortP->PortNum); PortP->State &= ~RIO_CLOSING; if (PortP->firstOpen) PortP->firstOpen--; @@ -602,48 +587,47 @@ riotclose(void *ptr) return -EIO; } - rio_dprintk (RIO_DEBUG_TTY, "Closing down - everything must go!\n"); + rio_dprintk(RIO_DEBUG_TTY, "Closing down - everything must go!\n"); PortP->State &= ~RIO_DYNOROD; /* - ** This is where we wait for the port - ** to drain down before closing. Bye-bye.... - ** (We never meant to do this) - */ - rio_dprintk (RIO_DEBUG_TTY, "Timeout 1 starts\n"); + ** This is where we wait for the port + ** to drain down before closing. Bye-bye.... + ** (We never meant to do this) + */ + rio_dprintk(RIO_DEBUG_TTY, "Timeout 1 starts\n"); if (!deleted) - while ( (PortP->InUse != NOT_INUSE) && !p->RIOHalted && - (PortP->TxBufferIn != PortP->TxBufferOut) ) { - cprintf("Need to flush the ttyport\n"); - if (repeat_this -- <= 0) { - rv = -EINTR; - rio_dprintk (RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); - RIOPreemptiveCmd(p, PortP, FCLOSE); - goto close_end; - } - rio_dprintk (RIO_DEBUG_TTY, "Calling timeout to flush in closing\n"); - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - if (RIODelay_ni(PortP, HUNDRED_MS*10) == RIO_FAIL) { - rio_dprintk (RIO_DEBUG_TTY, "RTA EINTR in delay \n"); - rv = -EINTR; + while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) { + cprintf("Need to flush the ttyport\n"); + if (repeat_this-- <= 0) { + rv = -EINTR; + rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); + RIOPreemptiveCmd(p, PortP, FCLOSE); + goto close_end; + } + rio_dprintk(RIO_DEBUG_TTY, "Calling timeout to flush in closing\n"); + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + if (RIODelay_ni(PortP, HUNDRED_MS * 10) == RIO_FAIL) { + rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n"); + rv = -EINTR; + rio_spin_lock_irqsave(&PortP->portSem, flags); + goto close_end; + } rio_spin_lock_irqsave(&PortP->portSem, flags); - goto close_end; } - rio_spin_lock_irqsave(&PortP->portSem, flags); - } PortP->TxBufferIn = PortP->TxBufferOut = 0; repeat_this = 0xff; PortP->InUse = 0; - if ( (PortP->State & (RIO_LOPEN|RIO_MOPEN)) ) { + if ((PortP->State & (RIO_LOPEN | RIO_MOPEN))) { /* - ** The port has been re-opened for the other task - - ** return, pretending that we are still active. - */ - rio_dprintk (RIO_DEBUG_TTY, "Channel %d re-open!\n", PortP->PortNum); + ** The port has been re-opened for the other task - + ** return, pretending that we are still active. + */ + rio_dprintk(RIO_DEBUG_TTY, "Channel %d re-open!\n", PortP->PortNum); PortP->State &= ~RIO_CLOSING; rio_spin_unlock_irqrestore(&PortP->portSem, flags); if (PortP->firstOpen) @@ -651,8 +635,8 @@ riotclose(void *ptr) return -EIO; } - if ( p->RIOHalted ) { - RIOClearUp( PortP ); + if (p->RIOHalted) { + RIOClearUp(PortP); goto close_end; } @@ -665,57 +649,56 @@ riotclose(void *ptr) } if (!deleted) - while (try && (PortP->PortState & PORT_ISOPEN)) { - try--; - if (time_after (jiffies, end_time)) { - rio_dprintk (RIO_DEBUG_TTY, "Run out of tries - force the bugger shut!\n" ); - RIOPreemptiveCmd(p, PortP,FCLOSE); - break; - } - rio_dprintk (RIO_DEBUG_TTY, "Close: PortState:ISOPEN is %d\n", - PortP->PortState & PORT_ISOPEN); + while (try && (PortP->PortState & PORT_ISOPEN)) { + try--; + if (time_after(jiffies, end_time)) { + rio_dprintk(RIO_DEBUG_TTY, "Run out of tries - force the bugger shut!\n"); + RIOPreemptiveCmd(p, PortP, FCLOSE); + break; + } + rio_dprintk(RIO_DEBUG_TTY, "Close: PortState:ISOPEN is %d\n", PortP->PortState & PORT_ISOPEN); - if ( p->RIOHalted ) { - RIOClearUp( PortP ); - goto close_end; - } - if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { - rio_dprintk (RIO_DEBUG_TTY, "RTA EINTR in delay \n"); - RIOPreemptiveCmd(p, PortP,FCLOSE); - break; + if (p->RIOHalted) { + RIOClearUp(PortP); + goto close_end; + } + if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { + rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n"); + RIOPreemptiveCmd(p, PortP, FCLOSE); + break; + } } - } rio_spin_lock_irqsave(&PortP->portSem, flags); - rio_dprintk (RIO_DEBUG_TTY, "Close: try was %d on completion\n", try ); - + rio_dprintk(RIO_DEBUG_TTY, "Close: try was %d on completion\n", try); + /* RIOPreemptiveCmd(p, PortP, FCLOSE); */ /* ** 15.10.1998 ARG - ESIL 0761 part fix ** RIO has it's own CTSFLOW and RTSFLOW flags in 'Config' in the port structure,** we need to make sure that the flags are clear when the port is opened. */ - PortP->Config &= ~(RIO_CTSFLOW|RIO_RTSFLOW); + PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW); #ifdef STATS PortP->Stat.CloseCnt++; #endif /* - ** Count opens for port statistics reporting - */ + ** Count opens for port statistics reporting + */ if (PortP->statsGather) PortP->closes++; -close_end: + close_end: /* XXX: Why would a "DELETED" flag be reset here? I'd have thought that a "deleted" flag means that the port was permanently gone, but here we can make it reappear by it being in close during the "deletion". - */ - PortP->State &= ~(RIO_CLOSING|RIO_DELETED); + */ + PortP->State &= ~(RIO_CLOSING | RIO_DELETED); if (PortP->firstOpen) PortP->firstOpen--; rio_spin_unlock_irqrestore(&PortP->portSem, flags); - rio_dprintk (RIO_DEBUG_TTY, "Return from close\n"); + rio_dprintk(RIO_DEBUG_TTY, "Return from close\n"); return rv; } @@ -728,52 +711,50 @@ close_end: ** COOK_MEDIUM if the card can do all the processing necessary. */ #if 0 -static int -RIOCookMode(struct ttystatics *tp) +static int RIOCookMode(struct ttystatics *tp) { /* - ** We can't handle tm.c_mstate != 0 on SCO - ** We can't handle mapping - ** We can't handle non-ttwrite line disc. - ** We can't handle lflag XCASE - ** We can handle oflag OPOST & (OCRNL, ONLCR, TAB3) - */ + ** We can't handle tm.c_mstate != 0 on SCO + ** We can't handle mapping + ** We can't handle non-ttwrite line disc. + ** We can't handle lflag XCASE + ** We can handle oflag OPOST & (OCRNL, ONLCR, TAB3) + */ #ifdef CHECK - CheckTtyP( tp ); + CheckTtyP(tp); #endif if (!(tp->tm.c_oflag & OPOST)) /* No post processing */ return COOK_RAW; /* Raw mode o/p */ - if ( tp->tm.c_lflag & XCASE ) + if (tp->tm.c_lflag & XCASE) return COOK_WELL; /* Use line disc */ - if (tp->tm.c_oflag & ~(OPOST | ONLCR | OCRNL | TAB3 ) ) + if (tp->tm.c_oflag & ~(OPOST | ONLCR | OCRNL | TAB3)) return COOK_WELL; /* Use line disc for strange modes */ - if ( tp->tm.c_oflag == OPOST ) /* If only OPOST is set, do RAW */ + if (tp->tm.c_oflag == OPOST) /* If only OPOST is set, do RAW */ return COOK_RAW; /* - ** So, we need to output process! - */ + ** So, we need to output process! + */ return COOK_MEDIUM; } #endif -static void -RIOClearUp(PortP) +static void RIOClearUp(PortP) struct Port *PortP; { - rio_dprintk (RIO_DEBUG_TTY, "RIOHalted set\n"); - PortP->Config = 0; /* Direct semaphore */ + rio_dprintk(RIO_DEBUG_TTY, "RIOHalted set\n"); + PortP->Config = 0; /* Direct semaphore */ PortP->PortState = 0; PortP->firstOpen = 0; PortP->FlushCmdBodge = 0; PortP->ModemState = PortP->CookMode = 0; PortP->Mapped = 0; PortP->WflushFlag = 0; - PortP->MagicFlags = 0; + PortP->MagicFlags = 0; PortP->RxDataStart = 0; PortP->TxBufferIn = 0; PortP->TxBufferOut = 0; @@ -788,33 +769,31 @@ struct Port *PortP; ** Other values of len aren't allowed, and will cause ** a panic. */ -int RIOShortCommand(struct rio_info *p, struct Port *PortP, - int command, int len, int arg) +int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg) { PKT *PacketP; - int retries = 20; /* at 10 per second -> 2 seconds */ + int retries = 20; /* at 10 per second -> 2 seconds */ unsigned long flags; - rio_dprintk (RIO_DEBUG_TTY, "entering shortcommand.\n"); + rio_dprintk(RIO_DEBUG_TTY, "entering shortcommand.\n"); #ifdef CHECK - CheckPortP( PortP ); - if ( len < 1 || len > 2 ) - cprintf(("STUPID LENGTH %d\n",len)); + CheckPortP(PortP); + if (len < 1 || len > 2) + cprintf(("STUPID LENGTH %d\n", len)); #endif - if ( PortP->State & RIO_DELETED ) { - rio_dprintk (RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n"); + if (PortP->State & RIO_DELETED) { + rio_dprintk(RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n"); return RIO_FAIL; } rio_spin_lock_irqsave(&PortP->portSem, flags); /* - ** If the port is in use for pre-emptive command, then wait for it to - ** be free again. - */ - while ( (PortP->InUse != NOT_INUSE) && !p->RIOHalted ) { - rio_dprintk (RIO_DEBUG_TTY, "Waiting for not in use (%d)\n", - retries); + ** If the port is in use for pre-emptive command, then wait for it to + ** be free again. + */ + while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted) { + rio_dprintk(RIO_DEBUG_TTY, "Waiting for not in use (%d)\n", retries); rio_spin_unlock_irqrestore(&PortP->portSem, flags); if (retries-- <= 0) { return RIO_FAIL; @@ -824,47 +803,47 @@ int RIOShortCommand(struct rio_info *p, struct Port *PortP, } rio_spin_lock_irqsave(&PortP->portSem, flags); } - if ( PortP->State & RIO_DELETED ) { - rio_dprintk (RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n"); + if (PortP->State & RIO_DELETED) { + rio_dprintk(RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n"); rio_spin_unlock_irqrestore(&PortP->portSem, flags); return RIO_FAIL; } - while ( !can_add_transmit(&PacketP,PortP) && !p->RIOHalted ) { - rio_dprintk (RIO_DEBUG_TTY, "Waiting to add short command to queue (%d)\n", retries); + while (!can_add_transmit(&PacketP, PortP) && !p->RIOHalted) { + rio_dprintk(RIO_DEBUG_TTY, "Waiting to add short command to queue (%d)\n", retries); rio_spin_unlock_irqrestore(&PortP->portSem, flags); if (retries-- <= 0) { - rio_dprintk (RIO_DEBUG_TTY, "out of tries. Failing\n"); + rio_dprintk(RIO_DEBUG_TTY, "out of tries. Failing\n"); return RIO_FAIL; } - if ( RIODelay_ni(PortP, HUNDRED_MS)==RIO_FAIL ) { + if (RIODelay_ni(PortP, HUNDRED_MS) == RIO_FAIL) { return RIO_FAIL; } rio_spin_lock_irqsave(&PortP->portSem, flags); } - if ( p->RIOHalted ) { + if (p->RIOHalted) { rio_spin_unlock_irqrestore(&PortP->portSem, flags); return RIO_FAIL; } /* - ** set the command byte and the argument byte - */ - WBYTE(PacketP->data[0] , command); + ** set the command byte and the argument byte + */ + WBYTE(PacketP->data[0], command); - if ( len==2 ) - WBYTE(PacketP->data[1] , arg); + if (len == 2) + WBYTE(PacketP->data[1], arg); /* - ** set the length of the packet and set the command bit. - */ - WBYTE(PacketP->len , PKT_CMD_BIT | len); + ** set the length of the packet and set the command bit. + */ + WBYTE(PacketP->len, PKT_CMD_BIT | len); add_transmit(PortP); /* - ** Count characters transmitted for port statistics reporting - */ + ** Count characters transmitted for port statistics reporting + */ if (PortP->statsGather) PortP->txchars += len; @@ -878,28 +857,26 @@ int RIOShortCommand(struct rio_info *p, struct Port *PortP, ** This is an ioctl interface. This is the twentieth century. You know what ** its all about. */ -int -riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg) +int riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg) { - register struct Port *PortP; - register struct ttystatics *tp; - int current; - int ParamSemIncremented = 0; - int old_oflag, old_cflag, old_iflag, changed, oldcook; - int i; - unsigned char sio_regs[5]; /* Here be magic */ - short vpix_cflag; - short divisor; - int baud; - 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", - SysPort, cmd, arg, Modem?"Modem":"tty") ; - - if ( SysPort >= RIO_PORTS ) { - rio_dprintk (RIO_DEBUG_TTY, "Bad port number %d\n", SysPort); + register struct Port *PortP; + register struct ttystatics *tp; + int current; + int ParamSemIncremented = 0; + int old_oflag, old_cflag, old_iflag, changed, oldcook; + int i; + unsigned char sio_regs[5]; /* Here be magic */ + short vpix_cflag; + short divisor; + int baud; + 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", SysPort, cmd, arg, Modem ? "Modem" : "tty"); + + if (SysPort >= RIO_PORTS) { + rio_dprintk(RIO_DEBUG_TTY, "Bad port number %d\n", SysPort); return -ENXIO; } @@ -912,205 +889,195 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg) PortP->Stat.IoctlCnt++; #endif - if ( PortP->State & RIO_DELETED ) { + if (PortP->State & RIO_DELETED) { rio_spin_unlock_irqrestore(&PortP->portSem, flags); return -EIO; } - if ( p->RIOHalted ) { - RIOClearUp( PortP ); + if (p->RIOHalted) { + RIOClearUp(PortP); rio_spin_unlock_irqrestore(&PortP->portSem, flags); return -EIO; } /* - ** Count ioctls for port statistics reporting - */ + ** Count ioctls for port statistics reporting + */ if (PortP->statsGather) PortP->ioctls++; /* - ** Specialix RIO Ioctl calls - */ + ** Specialix RIO Ioctl calls + */ switch (cmd) { - case TCRIOTRIAD: - if ( arg ) - PortP->State |= RIO_TRIAD_MODE; - else - PortP->State &= ~RIO_TRIAD_MODE; - /* - ** Normally, when istrip is set on a port, a config is - ** sent to the RTA instructing the CD1400 to do the - ** stripping. In TRIAD mode, the interrupt receive routine - ** must do the stripping instead, since it has to detect - ** an 8 bit function key sequence. If istrip is set with - ** TRIAD mode on(off), and 8 bit data is being read by - ** the port, the user then turns TRIAD mode off(on), the RTA - ** must be reconfigured (not) to do the stripping. - ** Hence we call RIOParam here. - */ - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); - return 0; + case TCRIOTRIAD: + if (arg) + PortP->State |= RIO_TRIAD_MODE; + else + PortP->State &= ~RIO_TRIAD_MODE; + /* + ** Normally, when istrip is set on a port, a config is + ** sent to the RTA instructing the CD1400 to do the + ** stripping. In TRIAD mode, the interrupt receive routine + ** must do the stripping instead, since it has to detect + ** an 8 bit function key sequence. If istrip is set with + ** TRIAD mode on(off), and 8 bit data is being read by + ** the port, the user then turns TRIAD mode off(on), the RTA + ** must be reconfigured (not) to do the stripping. + ** Hence we call RIOParam here. + */ + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP); + return 0; - case TCRIOTSTATE: - rio_dprintk (RIO_DEBUG_TTY, "tbusy/tstop monitoring %sabled\n", - arg ? "en" : "dis"); - /* MonitorTstate = 0 ;*/ - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP); - return 0; + case TCRIOTSTATE: + rio_dprintk(RIO_DEBUG_TTY, "tbusy/tstop monitoring %sabled\n", arg ? "en" : "dis"); + /* MonitorTstate = 0 ; */ + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP); + return 0; - case TCRIOSTATE: /* current state of Modem input pins */ - rio_dprintk (RIO_DEBUG_TTY, "TCRIOSTATE\n"); - if (RIOPreemptiveCmd(p, PortP, MGET) == RIO_FAIL) - rio_dprintk (RIO_DEBUG_TTY, "TCRIOSTATE command failed\n"); - PortP->State |= RIO_BUSY; - current = PortP->ModemState; - if ( copyout((caddr_t)¤t, (int)arg, - sizeof(current))==COPYFAIL ) { - rio_dprintk (RIO_DEBUG_TTY, "Copyout failed\n"); - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - pseterr(EFAULT); - } + case TCRIOSTATE: /* current state of Modem input pins */ + rio_dprintk(RIO_DEBUG_TTY, "TCRIOSTATE\n"); + if (RIOPreemptiveCmd(p, PortP, MGET) == RIO_FAIL) + rio_dprintk(RIO_DEBUG_TTY, "TCRIOSTATE command failed\n"); + PortP->State |= RIO_BUSY; + current = PortP->ModemState; + if (copyout((caddr_t) & current, (int) arg, sizeof(current)) == COPYFAIL) { + rio_dprintk(RIO_DEBUG_TTY, "Copyout failed\n"); rio_spin_unlock_irqrestore(&PortP->portSem, flags); - return 0; + pseterr(EFAULT); + } + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + return 0; - case TCRIOMBIS: /* Set modem lines */ - case TCRIOMBIC: /* Clear modem lines */ - rio_dprintk (RIO_DEBUG_TTY, "TCRIOMBIS/TCRIOMBIC\n"); - if (cmd == TCRIOMBIS) { - uint state; - state = (uint)arg; - PortP->ModemState |= (ushort)state; - PortP->ModemLines = (ulong) arg; - if (RIOPreemptiveCmd(p, PortP, MBIS) == RIO_FAIL) - rio_dprintk (RIO_DEBUG_TTY, - "TCRIOMBIS command failed\n"); - } - else { - uint state; - - state = (uint)arg; - PortP->ModemState &= ~(ushort)state; - PortP->ModemLines = (ulong) arg; - if (RIOPreemptiveCmd(p, PortP, MBIC) == RIO_FAIL) - rio_dprintk (RIO_DEBUG_TTY, "TCRIOMBIC command failed\n"); - } - PortP->State |= RIO_BUSY; - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - return 0; + case TCRIOMBIS: /* Set modem lines */ + case TCRIOMBIC: /* Clear modem lines */ + rio_dprintk(RIO_DEBUG_TTY, "TCRIOMBIS/TCRIOMBIC\n"); + if (cmd == TCRIOMBIS) { + uint state; + state = (uint) arg; + PortP->ModemState |= (ushort) state; + PortP->ModemLines = (ulong) arg; + if (RIOPreemptiveCmd(p, PortP, MBIS) == RIO_FAIL) + rio_dprintk(RIO_DEBUG_TTY, "TCRIOMBIS command failed\n"); + } else { + uint state; - case TCRIOXPON: /* set Xprint ON string */ - rio_dprintk (RIO_DEBUG_TTY, "TCRIOXPON\n"); - if ( copyin((int)arg, (caddr_t)PortP->Xprint.XpOn, - MAX_XP_CTRL_LEN)==COPYFAIL ) { - rio_dprintk (RIO_DEBUG_TTY, "Copyin failed\n"); - PortP->Xprint.XpOn[0] = '\0'; - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - pseterr(EFAULT); - } - PortP->Xprint.XpOn[MAX_XP_CTRL_LEN-1] = '\0'; - PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn)+ - strlen(PortP->Xprint.XpOff); - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - return 0; + state = (uint) arg; + PortP->ModemState &= ~(ushort) state; + PortP->ModemLines = (ulong) arg; + if (RIOPreemptiveCmd(p, PortP, MBIC) == RIO_FAIL) + rio_dprintk(RIO_DEBUG_TTY, "TCRIOMBIC command failed\n"); + } + PortP->State |= RIO_BUSY; + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + return 0; - case TCRIOXPOFF: /* set Xprint OFF string */ - rio_dprintk (RIO_DEBUG_TTY, "TCRIOXPOFF\n"); - if ( copyin( (int)arg, (caddr_t)PortP->Xprint.XpOff, - MAX_XP_CTRL_LEN)==COPYFAIL ) { - rio_dprintk (RIO_DEBUG_TTY, "Copyin failed\n"); - PortP->Xprint.XpOff[0] = '\0'; - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - pseterr(EFAULT); - } - PortP->Xprint.XpOff[MAX_XP_CTRL_LEN-1] = '\0'; - PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn)+ - strlen(PortP->Xprint.XpOff); + case TCRIOXPON: /* set Xprint ON string */ + rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPON\n"); + if (copyin((int) arg, (caddr_t) PortP->Xprint.XpOn, MAX_XP_CTRL_LEN) == COPYFAIL) { + rio_dprintk(RIO_DEBUG_TTY, "Copyin failed\n"); + PortP->Xprint.XpOn[0] = '\0'; rio_spin_unlock_irqrestore(&PortP->portSem, flags); - return 0; + pseterr(EFAULT); + } + PortP->Xprint.XpOn[MAX_XP_CTRL_LEN - 1] = '\0'; + PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn) + strlen(PortP->Xprint.XpOff); + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + return 0; - case TCRIOXPCPS: /* set Xprint CPS string */ - rio_dprintk (RIO_DEBUG_TTY, "TCRIOXPCPS\n"); - if ( (uint)arg > p->RIOConf.MaxXpCps || - (uint)arg < p->RIOConf.MinXpCps ) { - rio_dprintk (RIO_DEBUG_TTY, "%d CPS out of range\n",arg); - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - pseterr(EINVAL); - return 0; - } - PortP->Xprint.XpCps = (uint)arg; + case TCRIOXPOFF: /* set Xprint OFF string */ + rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPOFF\n"); + if (copyin((int) arg, (caddr_t) PortP->Xprint.XpOff, MAX_XP_CTRL_LEN) == COPYFAIL) { + rio_dprintk(RIO_DEBUG_TTY, "Copyin failed\n"); + PortP->Xprint.XpOff[0] = '\0'; rio_spin_unlock_irqrestore(&PortP->portSem, flags); - return 0; + pseterr(EFAULT); + } + PortP->Xprint.XpOff[MAX_XP_CTRL_LEN - 1] = '\0'; + PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn) + strlen(PortP->Xprint.XpOff); + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + return 0; - case TCRIOXPRINT: - rio_dprintk (RIO_DEBUG_TTY, "TCRIOXPRINT\n"); - if ( copyout((caddr_t)&PortP->Xprint, (int)arg, - sizeof(struct Xprint))==COPYFAIL ) { - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - pseterr(EFAULT); - } + case TCRIOXPCPS: /* set Xprint CPS string */ + rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPCPS\n"); + if ((uint) arg > p->RIOConf.MaxXpCps || (uint) arg < p->RIOConf.MinXpCps) { + rio_dprintk(RIO_DEBUG_TTY, "%d CPS out of range\n", arg); rio_spin_unlock_irqrestore(&PortP->portSem, flags); + pseterr(EINVAL); return 0; + } + PortP->Xprint.XpCps = (uint) arg; + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + return 0; - case TCRIOIXANYON: - rio_dprintk (RIO_DEBUG_TTY, "TCRIOIXANYON\n"); - PortP->Config |= RIO_IXANY; + case TCRIOXPRINT: + rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPRINT\n"); + if (copyout((caddr_t) & PortP->Xprint, (int) arg, sizeof(struct Xprint)) == COPYFAIL) { rio_spin_unlock_irqrestore(&PortP->portSem, flags); - return 0; + pseterr(EFAULT); + } + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + return 0; - case TCRIOIXANYOFF: - rio_dprintk (RIO_DEBUG_TTY, "TCRIOIXANYOFF\n"); - PortP->Config &= ~RIO_IXANY; - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - return 0; + case TCRIOIXANYON: + rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXANYON\n"); + PortP->Config |= RIO_IXANY; + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + return 0; - case TCRIOIXONON: - rio_dprintk (RIO_DEBUG_TTY, "TCRIOIXONON\n"); - PortP->Config |= RIO_IXON; - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - return 0; + case TCRIOIXANYOFF: + rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXANYOFF\n"); + PortP->Config &= ~RIO_IXANY; + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + return 0; - case TCRIOIXONOFF: - rio_dprintk (RIO_DEBUG_TTY, "TCRIOIXONOFF\n"); - PortP->Config &= ~RIO_IXON; - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - return 0; + case TCRIOIXONON: + rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXONON\n"); + PortP->Config |= RIO_IXON; + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + return 0; + + case TCRIOIXONOFF: + rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXONOFF\n"); + PortP->Config &= ~RIO_IXON; + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + return 0; /* ** 15.10.1998 ARG - ESIL 0761 part fix ** Added support for CTS and RTS flow control ioctls : */ - case TCRIOCTSFLOWEN: - rio_dprintk (RIO_DEBUG_TTY, "TCRIOCTSFLOWEN\n"); - PortP->Config |= RIO_CTSFLOW; - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); - return 0; + case TCRIOCTSFLOWEN: + rio_dprintk(RIO_DEBUG_TTY, "TCRIOCTSFLOWEN\n"); + PortP->Config |= RIO_CTSFLOW; + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP); + return 0; - case TCRIOCTSFLOWDIS: - rio_dprintk (RIO_DEBUG_TTY, "TCRIOCTSFLOWDIS\n"); - PortP->Config &= ~RIO_CTSFLOW; - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); - return 0; + case TCRIOCTSFLOWDIS: + rio_dprintk(RIO_DEBUG_TTY, "TCRIOCTSFLOWDIS\n"); + PortP->Config &= ~RIO_CTSFLOW; + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP); + return 0; - case TCRIORTSFLOWEN: - rio_dprintk (RIO_DEBUG_TTY, "TCRIORTSFLOWEN\n"); - PortP->Config |= RIO_RTSFLOW; - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); - return 0; + case TCRIORTSFLOWEN: + rio_dprintk(RIO_DEBUG_TTY, "TCRIORTSFLOWEN\n"); + PortP->Config |= RIO_RTSFLOW; + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP); + return 0; - case TCRIORTSFLOWDIS: - rio_dprintk (RIO_DEBUG_TTY, "TCRIORTSFLOWDIS\n"); - PortP->Config &= ~RIO_RTSFLOW; - rio_spin_unlock_irqrestore(&PortP->portSem, flags); - RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); - return 0; + case TCRIORTSFLOWDIS: + rio_dprintk(RIO_DEBUG_TTY, "TCRIORTSFLOWDIS\n"); + PortP->Config &= ~RIO_RTSFLOW; + rio_spin_unlock_irqrestore(&PortP->portSem, flags); + RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP); + return 0; /* end ESIL 0761 part fix */ @@ -1119,35 +1086,35 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg) /* Lynx IOCTLS */ switch (cmd) { - case TIOCSETP: - case TIOCSETN: - case OTIOCSETP: - case OTIOCSETN: - ioctl_processed++; - ttyseth(PortP, tp, (struct old_sgttyb *)arg); - break; - case TCSETA: - case TCSETAW: - case TCSETAF: - ioctl_processed++; - rio_dprintk (RIO_DEBUG_TTY, "NON POSIX ioctl\n"); - ttyseth_pv(PortP, tp, (struct termios *)arg, 0); - break; - case TCSETAP: /* posix tcsetattr() */ - case TCSETAWP: /* posix tcsetattr() */ - case TCSETAFP: /* posix tcsetattr() */ - rio_dprintk (RIO_DEBUG_TTY, "NON POSIX SYSV ioctl\n"); - ttyseth_pv(PortP, tp, (struct termios *)arg, 1); - ioctl_processed++; - break; + case TIOCSETP: + case TIOCSETN: + case OTIOCSETP: + case OTIOCSETN: + ioctl_processed++; + ttyseth(PortP, tp, (struct old_sgttyb *) arg); + break; + case TCSETA: + case TCSETAW: + case TCSETAF: + ioctl_processed++; + rio_dprintk(RIO_DEBUG_TTY, "NON POSIX ioctl\n"); + ttyseth_pv(PortP, tp, (struct termios *) arg, 0); + break; + case TCSETAP: /* posix tcsetattr() */ + case TCSETAWP: /* posix tcsetattr() */ + case TCSETAFP: /* posix tcsetattr() */ + rio_dprintk(RIO_DEBUG_TTY, "NON POSIX SYSV ioctl\n"); + ttyseth_pv(PortP, tp, (struct termios *) arg, 1); + ioctl_processed++; + break; } /* - ** If its any of the commands that require the port to be in the - ** non-busy state wait until all output has drained - */ + ** If its any of the commands that require the port to be in the + ** non-busy state wait until all output has drained + */ if (!ioctl_processed) - switch(cmd) { + switch (cmd) { case TCSETAW: case TCSETAF: case TCSETA: @@ -1171,29 +1138,29 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg) #endif case TIOCSETD: case TIOCSETN: - rio_dprintk (RIO_DEBUG_TTY, "wait for non-BUSY, semaphore set\n"); + rio_dprintk(RIO_DEBUG_TTY, "wait for non-BUSY, semaphore set\n"); /* - ** Wait for drain here, at least as far as the double buffer - ** being empty. - */ + ** Wait for drain here, at least as far as the double buffer + ** being empty. + */ /* XXX Does the above comment mean that this has still to be implemented? -- REW */ /* XXX Is the locking OK together with locking - in txenable? (Deadlock?) -- REW */ - - RIOTxEnable((char *)PortP); + in txenable? (Deadlock?) -- REW */ + + RIOTxEnable((char *) PortP); break; default: break; - } + } old_cflag = tp->tm.c_cflag; old_iflag = tp->tm.c_iflag; old_oflag = tp->tm.c_oflag; oldcook = PortP->CookMode; - if ( p->RIOHalted ) { - RIOClearUp( PortP ); + if (p->RIOHalted) { + RIOClearUp(PortP); rio_spin_unlock_irqrestore(&PortP->portSem, flags); pseterr(EIO); return 0; @@ -1202,10 +1169,10 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg) PortP->FlushCmdBodge = 0; /* - ** If the port is locked, and it is reconfigured, we want - ** to restore the state of the tty structure so the change is NOT - ** made. - */ + ** If the port is locked, and it is reconfigured, we want + ** to restore the state of the tty structure so the change is NOT + ** made. + */ if (PortP->Lock) { tp->tm.c_iflag = PortP->StoredTty.iflag; tp->tm.c_oflag = PortP->StoredTty.oflag; @@ -1214,13 +1181,12 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg) tp->tm.c_line = PortP->StoredTty.line; for (i = 0; i < NCC + 1; i++) tp->tm.c_cc[i] = PortP->StoredTty.cc[i]; - } - else { + } else { /* - ** If the port is set to store the parameters, and it is - ** reconfigured, we want to save the current tty struct so it - ** may be restored on the next open. - */ + ** If the port is set to store the parameters, and it is + ** reconfigured, we want to save the current tty struct so it + ** may be restored on the next open. + */ if (PortP->Store) { PortP->StoredTty.iflag = tp->tm.c_iflag; PortP->StoredTty.oflag = tp->tm.c_oflag; @@ -1232,44 +1198,41 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg) } } - changed = (tp->tm.c_cflag != old_cflag) || - (tp->tm.c_iflag != old_iflag) || - (tp->tm.c_oflag != old_oflag); + changed = (tp->tm.c_cflag != old_cflag) || (tp->tm.c_iflag != old_iflag) || (tp->tm.c_oflag != old_oflag); PortP->CookMode = RIOCookMode(tp); /* Set new cooking mode */ - rio_dprintk (RIO_DEBUG_TTY, "RIOIoctl changed %d newcook %d oldcook %d\n", - changed,PortP->CookMode,oldcook); + rio_dprintk(RIO_DEBUG_TTY, "RIOIoctl changed %d newcook %d oldcook %d\n", changed, PortP->CookMode, oldcook); #ifdef MODEM_SUPPORT /* - ** kludge to force CARR_ON if CLOCAL set - */ - if ((tp->tm.c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) { + ** kludge to force CARR_ON if CLOCAL set + */ + if ((tp->tm.c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) { tp->tm.c_state |= CARR_ON; - wakeup ((caddr_t)&tp->tm.c_canq); + wakeup((caddr_t) & tp->tm.c_canq); } #endif - if ( p->RIOHalted ) { - RIOClearUp( PortP ); + if (p->RIOHalted) { + RIOClearUp(PortP); rio_spin_unlock_irqrestore(&PortP->portSem, flags); pseterr(EIO); return 0; } /* - ** Re-configure if modes or cooking have changed - */ + ** Re-configure if modes or cooking have changed + */ if (changed || oldcook != PortP->CookMode || (ioctl_processed)) { rio_spin_unlock_irqrestore(&PortP->portSem, flags); - rio_dprintk (RIO_DEBUG_TTY, "Ioctl changing the PORT settings\n"); - RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); + rio_dprintk(RIO_DEBUG_TTY, "Ioctl changing the PORT settings\n"); + RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP); rio_spin_lock_irqsave(&PortP->portSem, flags); } if (p->RIOHalted) { rio_spin_unlock_irqrestore(&PortP->portSem, flags); - RIOClearUp( PortP ); + RIOClearUp(PortP); pseterr(EIO); return 0; } @@ -1280,36 +1243,32 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg) /* ttyseth -- set hardware dependent tty settings */ -void -ttyseth(PortP, s, sg) -struct Port * PortP; -struct ttystatics * s; +void ttyseth(PortP, s, sg) +struct Port *PortP; +struct ttystatics *s; struct old_sgttyb *sg; { - struct old_sgttyb * tsg; + struct old_sgttyb *tsg; struct termios *tp = &s->tm; tsg = &s->sg; - if (sg->sg_flags & (EVENP|ODDP)) { + if (sg->sg_flags & (EVENP | ODDP)) { tp->c_cflag &= PARENB; if (sg->sg_flags & EVENP) { if (sg->sg_flags & ODDP) { tp->c_cflag &= V_CS7; tp->c_cflag &= ~PARENB; - } - else { + } else { tp->c_cflag &= V_CS7; tp->c_cflag &= PARENB; tp->c_cflag &= PARODD; } - } - else if (sg->sg_flags & ODDP) { + } else if (sg->sg_flags & ODDP) { tp->c_cflag &= V_CS7; tp->c_cflag &= PARENB; tp->c_cflag &= PARODD; - } - else { + } else { tp->c_cflag &= V_CS7; tp->c_cflag &= PARENB; } @@ -1320,16 +1279,16 @@ struct old_sgttyb *sg; * I will have to use separate sets of flags to store them in the * Port structure. */ - if ( !sg->sg_ospeed ) + if (!sg->sg_ospeed) sg->sg_ospeed = sg->sg_ispeed; else sg->sg_ispeed = sg->sg_ospeed; - if (sg->sg_ispeed > V_EXTB ) + if (sg->sg_ispeed > V_EXTB) sg->sg_ispeed = V_EXTB; if (sg->sg_ispeed < V_B0) sg->sg_ispeed = V_B0; *tsg = *sg; - tp->c_cflag = (tp->c_cflag & ~V_CBAUD) | conv_bv[(int)sg->sg_ispeed]; + tp->c_cflag = (tp->c_cflag & ~V_CBAUD) | conv_bv[(int) sg->sg_ispeed]; } /* @@ -1338,36 +1297,33 @@ struct old_sgttyb *sg; sysv = 0 => (POSIX): struct termios *sg sysv != 0 => (System V): struct termio *sg */ -static void -ttyseth_pv(PortP, s, sg, sysv) +static void ttyseth_pv(PortP, s, sg, sysv) struct Port *PortP; struct ttystatics *s; struct termios *sg; int sysv; { - int speed; - unsigned char csize; - unsigned char cread; - unsigned int lcr_flags; - int ps; - - if (sysv) { - /* sg points to a System V termio structure */ - csize = ((struct termio *)sg)->c_cflag & CSIZE; - cread = ((struct termio *)sg)->c_cflag & CREAD; - speed = conv_vb[((struct termio *)sg)->c_cflag & V_CBAUD]; - } - else { - /* sg points to a POSIX termios structure */ - csize = sg->c_cflag & CSIZE; - cread = sg->c_cflag & CREAD; - speed = conv_vb[sg->c_cflag & V_CBAUD]; - } - if (s->sg.sg_ispeed != speed || s->sg.sg_ospeed != speed) { - s->sg.sg_ispeed = speed; - s->sg.sg_ospeed = speed; - s->tm.c_cflag = (s->tm.c_cflag & ~V_CBAUD) | - conv_bv[(int)s->sg.sg_ispeed]; - } + int speed; + unsigned char csize; + unsigned char cread; + unsigned int lcr_flags; + int ps; + + if (sysv) { + /* sg points to a System V termio structure */ + csize = ((struct termio *) sg)->c_cflag & CSIZE; + cread = ((struct termio *) sg)->c_cflag & CREAD; + speed = conv_vb[((struct termio *) sg)->c_cflag & V_CBAUD]; + } else { + /* sg points to a POSIX termios structure */ + csize = sg->c_cflag & CSIZE; + cread = sg->c_cflag & CREAD; + speed = conv_vb[sg->c_cflag & V_CBAUD]; + } + if (s->sg.sg_ispeed != speed || s->sg.sg_ospeed != speed) { + s->sg.sg_ispeed = speed; + s->sg.sg_ospeed = speed; + s->tm.c_cflag = (s->tm.c_cflag & ~V_CBAUD) | conv_bv[(int) s->sg.sg_ispeed]; + } } #endif -- cgit v1.2.3-55-g7522