specialix: Tidy up coding style

Preparation for doing some real work on the driver. Do this first so we can
easily identify if the cleanups accidentally broke something

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Alan Cox 2008-07-22 11:17:05 +01:00 committed by Linus Torvalds
parent 01e1abb2c2
commit a72492bd8a
1 changed files with 361 additions and 302 deletions

View File

@ -77,7 +77,7 @@
#include <linux/module.h>
#include <asm/io.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/ioport.h>
@ -92,7 +92,7 @@
#include <linux/delay.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <asm/uaccess.h>
#include <linux/uaccess.h>
#include "specialix_io8.h"
#include "cd1865.h"
@ -201,10 +201,10 @@ static inline int sx_paranoia_check(struct specialix_port const * port,
char *name, const char *routine)
{
#ifdef SPECIALIX_PARANOIA_CHECK
static const char *badmagic =
KERN_ERR "sx: Warning: bad specialix port magic number for device %s in %s\n";
static const char *badinfo =
KERN_ERR "sx: Warning: null specialix port for device %s in %s\n";
static const char *badmagic = KERN_ERR
"sx: Warning: bad specialix port magic number for device %s in %s\n";
static const char *badinfo = KERN_ERR
"sx: Warning: null specialix port for device %s in %s\n";
if (!port) {
printk(badinfo, name, routine);
@ -240,14 +240,16 @@ static inline int port_No (struct specialix_port const * port)
/* Get pointer to board from pointer to port */
static inline struct specialix_board * port_Board(struct specialix_port const * port)
static inline struct specialix_board *port_Board(
struct specialix_port const *port)
{
return &sx_board[SX_BOARD(port - sx_port)];
}
/* Input Byte from CL CD186x register */
static inline unsigned char sx_in(struct specialix_board * bp, unsigned short reg)
static inline unsigned char sx_in(struct specialix_board *bp,
unsigned short reg)
{
bp->reg = reg | 0x80;
outb(reg | 0x80, bp->base + SX_ADDR_REG);
@ -266,7 +268,8 @@ static inline void sx_out(struct specialix_board * bp, unsigned short reg,
/* Input Byte from CL CD186x register */
static inline unsigned char sx_in_off(struct specialix_board * bp, unsigned short reg)
static inline unsigned char sx_in_off(struct specialix_board *bp,
unsigned short reg)
{
bp->reg = reg;
outb(reg, bp->base + SX_ADDR_REG);
@ -275,8 +278,8 @@ static inline unsigned char sx_in_off(struct specialix_board * bp, unsigned sho
/* Output Byte to CL CD186x register */
static inline void sx_out_off(struct specialix_board * bp, unsigned short reg,
unsigned char val)
static inline void sx_out_off(struct specialix_board *bp,
unsigned short reg, unsigned char val)
{
bp->reg = reg;
outb(reg, bp->base + SX_ADDR_REG);
@ -337,8 +340,8 @@ static inline int sx_request_io_range(struct specialix_board * bp)
static inline void sx_release_io_range(struct specialix_board *bp)
{
release_region(bp->base,
bp->flags&SX_BOARD_IS_PCI?SX_PCI_IO_SPACE:SX_IO_SPACE);
release_region(bp->base, bp->flags & SX_BOARD_IS_PCI ?
SX_PCI_IO_SPACE : SX_IO_SPACE);
}
@ -353,11 +356,20 @@ static int sx_set_irq ( struct specialix_board *bp)
return 1;
switch (bp->irq) {
/* In the same order as in the docs... */
case 15: virq = 0;break;
case 12: virq = 1;break;
case 11: virq = 2;break;
case 9: virq = 3;break;
default: printk (KERN_ERR "Speclialix: cannot set irq to %d.\n", bp->irq);
case 15:
virq = 0;
break;
case 12:
virq = 1;
break;
case 11:
virq = 2;
break;
case 9:
virq = 3;
break;
default:printk(KERN_ERR
"Speclialix: cannot set irq to %d.\n", bp->irq);
return 0;
}
spin_lock_irqsave(&bp->lock, flags);
@ -437,12 +449,11 @@ void missed_irq (unsigned long data)
spin_lock_irqsave(&bp->lock, flags);
irq = sx_in((struct specialix_board *)data, CD186x_SRSR) &
(SRSR_RREQint |
SRSR_TREQint |
SRSR_MREQint);
(SRSR_RREQint | SRSR_TREQint | SRSR_MREQint);
spin_unlock_irqrestore(&bp->lock, flags);
if (irq) {
printk (KERN_INFO "Missed interrupt... Calling int from timer. \n");
printk(KERN_INFO
"Missed interrupt... Calling int from timer. \n");
sx_interrupt(-1, bp);
}
mod_timer(&missed_irq_timer, jiffies + sx_poll);
@ -480,7 +491,8 @@ static int sx_probe(struct specialix_board *bp)
if ((val1 != 0x5a) || (val2 != 0xa5)) {
printk(KERN_INFO "sx%d: specialix IO8+ Board at 0x%03x not found.\n",
printk(KERN_INFO
"sx%d: specialix IO8+ Board at 0x%03x not found.\n",
board_No(bp), bp->base);
sx_release_io_range(bp);
func_exit();
@ -491,7 +503,8 @@ static int sx_probe(struct specialix_board *bp)
identification */
val1 = read_cross_byte(bp, CD186x_MSVR, MSVR_DSR);
val2 = read_cross_byte(bp, CD186x_MSVR, MSVR_RTS);
dprintk (SX_DEBUG_INIT, "sx%d: DSR lines are: %02x, rts lines are: %02x\n",
dprintk(SX_DEBUG_INIT,
"sx%d: DSR lines are: %02x, rts lines are: %02x\n",
board_No(bp), val1, val2);
/* They managed to switch the bit order between the docs and
@ -500,7 +513,8 @@ static int sx_probe(struct specialix_board *bp)
old card. */
val2 = (bp->flags & SX_BOARD_IS_PCI)?0x4d : 0xb2;
if (val1 != val2) {
printk(KERN_INFO "sx%d: specialix IO8+ ID %02x at 0x%03x not found (%02x).\n",
printk(KERN_INFO
"sx%d: specialix IO8+ ID %02x at 0x%03x not found (%02x).\n",
board_No(bp), val2, bp->base, val1);
sx_release_io_range(bp);
func_exit();
@ -531,21 +545,24 @@ static int sx_probe(struct specialix_board *bp)
/* Hmmm. This is dead code anyway. */
}
dprintk (SX_DEBUG_INIT "val1 = %02x, val2 = %02x, val3 = %02x.\n",
dprintk(SX_DEBUG_INIT
"val1 = %02x, val2 = %02x, val3 = %02x.\n",
val1, val2, val3);
}
#if 0
if (irqs <= 0) {
printk(KERN_ERR "sx%d: Can't find IRQ for specialix IO8+ board at 0x%03x.\n",
printk(KERN_ERR
"sx%d: Can't find IRQ for specialix IO8+ board at 0x%03x.\n",
board_No(bp), bp->base);
sx_release_io_range(bp);
func_exit();
return 1;
}
#endif
printk (KERN_INFO "Started with irq=%d, but now have irq=%d.\n", bp->irq, irqs);
printk(KERN_INFO "Started with irq=%d, but now have irq=%d.\n",
bp->irq, irqs);
if (irqs > 0)
bp->irq = irqs;
#endif
@ -570,11 +587,25 @@ static int sx_probe(struct specialix_board *bp)
*/
switch (sx_in_off(bp, CD186x_GFRCR)) {
case 0x82:chip = 1864;rev='A';break;
case 0x83:chip = 1865;rev='A';break;
case 0x84:chip = 1865;rev='B';break;
case 0x85:chip = 1865;rev='C';break; /* Does not exist at this time */
default:chip=-1;rev='x';
case 0x82:
chip = 1864;
rev = 'A';
break;
case 0x83:
chip = 1865;
rev = 'A';
break;
case 0x84:
chip = 1865;
rev = 'B';
break;
case 0x85:
chip = 1865;
rev = 'C';
break; /* Does not exist at this time */
default:
chip = -1;
rev = 'x';
}
dprintk(SX_DEBUG_INIT, " GFCR = 0x%02x\n", sx_in_off(bp, CD186x_GFRCR));
@ -584,10 +615,9 @@ static int sx_probe(struct specialix_board *bp)
mod_timer(&missed_irq_timer, jiffies + sx_poll);
#endif
printk(KERN_INFO"sx%d: specialix IO8+ board detected at 0x%03x, IRQ %d, CD%d Rev. %c.\n",
board_No(bp),
bp->base, bp->irq,
chip, rev);
printk(KERN_INFO
"sx%d: specialix IO8+ board detected at 0x%03x, IRQ %d, CD%d Rev. %c.\n",
board_No(bp), bp->base, bp->irq, chip, rev);
func_exit();
return 0;
@ -608,7 +638,9 @@ static inline struct specialix_port * sx_get_port(struct specialix_board * bp,
dprintk(SX_DEBUG_CHAN, "channel: %d\n", channel);
if (channel < CD186x_NCH) {
port = &sx_port[board_No(bp) * SX_NPORT + channel];
dprintk (SX_DEBUG_CHAN, "port: %d %p flags: 0x%lx\n",board_No(bp) * SX_NPORT + channel, port, port->port.flags & ASYNC_INITIALIZED);
dprintk(SX_DEBUG_CHAN, "port: %d %p flags: 0x%lx\n",
board_No(bp) * SX_NPORT + channel, port,
port->port.flags & ASYNC_INITIALIZED);
if (port->port.flags & ASYNC_INITIALIZED) {
dprintk(SX_DEBUG_CHAN, "port: %d %p\n", channel, port);
@ -644,7 +676,8 @@ static inline void sx_receive_exc(struct specialix_board * bp)
dprintk(SX_DEBUG_RX, "status: 0x%x\n", status);
if (status & RCSR_OE) {
port->overrun++;
dprintk(SX_DEBUG_FIFO, "sx%d: port %d: Overrun. Total %ld overruns.\n",
dprintk(SX_DEBUG_FIFO,
"sx%d: port %d: Overrun. Total %ld overruns.\n",
board_No(bp), port_No(port), port->overrun);
}
status &= port->mark_mask;
@ -652,7 +685,8 @@ static inline void sx_receive_exc(struct specialix_board * bp)
/* This flip buffer check needs to be below the reading of the
status register to reset the chip's IRQ.... */
if (tty_buffer_request_room(tty, 1) == 0) {
dprintk(SX_DEBUG_FIFO, "sx%d: port %d: Working around flip buffer overflow.\n",
dprintk(SX_DEBUG_FIFO,
"sx%d: port %d: Working around flip buffer overflow.\n",
board_No(bp), port_No(port));
func_exit();
return;
@ -664,7 +698,8 @@ static inline void sx_receive_exc(struct specialix_board * bp)
return;
}
if (status & RCSR_TOUT) {
printk(KERN_INFO "sx%d: port %d: Receiver timeout. Hardware problems ?\n",
printk(KERN_INFO
"sx%d: port %d: Receiver timeout. Hardware problems ?\n",
board_No(bp), port_No(port));
func_exit();
return;
@ -702,7 +737,8 @@ static inline void sx_receive(struct specialix_board * bp)
func_enter();
if (!(port = sx_get_port(bp, "Receive"))) {
port = sx_get_port(bp, "Receive");
if (port == NULL) {
dprintk(SX_DEBUG_RX, "Hmm, couldn't find port.\n");
func_exit();
return;
@ -729,7 +765,8 @@ static inline void sx_transmit(struct specialix_board * bp)
unsigned char count;
func_enter();
if (!(port = sx_get_port(bp, "Transmit"))) {
port = sx_get_port(bp, "Transmit");
if (port == NULL) {
func_exit();
return;
}
@ -765,7 +802,8 @@ static inline void sx_transmit(struct specialix_board * bp)
sx_out(bp, CD186x_TDR, CD186x_C_ESC);
sx_out(bp, CD186x_TDR, CD186x_C_DELAY);
sx_out(bp, CD186x_TDR, count);
if (!(port->break_length -= count))
port->break_length -= count;
if (port->break_length == 0)
port->break_length--;
} else {
sx_out(bp, CD186x_TDR, CD186x_C_ESC);
@ -808,13 +846,14 @@ static inline void sx_check_modem(struct specialix_board * bp)
int msvr_cd;
dprintk(SX_DEBUG_SIGNALS, "Modem intr. ");
if (!(port = sx_get_port(bp, "Modem")))
port = sx_get_port(bp, "Modem");
if (port == NULL)
return;
tty = port->port.tty;
mcr = sx_in(bp, CD186x_MCR);
printk ("mcr = %02x.\n", mcr);
printk("mcr = %02x.\n", mcr); /* FIXME */
if ((mcr & MCR_CDCHG)) {
dprintk(SX_DEBUG_SIGNALS, "CD just changed... ");
@ -874,9 +913,12 @@ static irqreturn_t sx_interrupt(int dummy, void *dev_id)
spin_lock_irqsave(&bp->lock, flags);
dprintk (SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __func__, port_No(sx_get_port(bp, "INT")), SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1);
dprintk(SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __func__,
port_No(sx_get_port(bp, "INT")),
SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1);
if (!(bp->flags & SX_BOARD_ACTIVE)) {
dprintk (SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n", bp->irq);
dprintk(SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n",
bp->irq);
spin_unlock_irqrestore(&bp->lock, flags);
func_exit();
return IRQ_NONE;
@ -884,10 +926,11 @@ static irqreturn_t sx_interrupt(int dummy, void *dev_id)
saved_reg = bp->reg;
while ((++loop < 16) && (status = (sx_in(bp, CD186x_SRSR) &
(SRSR_RREQint |
SRSR_TREQint |
SRSR_MREQint)))) {
while (++loop < 16) {
status = sx_in(bp, CD186x_SRSR) &
(SRSR_RREQint | SRSR_TREQint | SRSR_MREQint);
if (status == 0)
break;
if (status & SRSR_RREQint) {
ack = sx_in(bp, CD186x_RRAR);
@ -896,7 +939,8 @@ static irqreturn_t sx_interrupt(int dummy, void *dev_id)
else if (ack == (SX_ID | GIVR_IT_REXC))
sx_receive_exc(bp);
else
printk(KERN_ERR "sx%d: status: 0x%x Bad receive ack 0x%02x.\n",
printk(KERN_ERR
"sx%d: status: 0x%x Bad receive ack 0x%02x.\n",
board_No(bp), status, ack);
} else if (status & SRSR_TREQint) {
@ -906,14 +950,16 @@ static irqreturn_t sx_interrupt(int dummy, void *dev_id)
sx_transmit(bp);
else
printk(KERN_ERR "sx%d: status: 0x%x Bad transmit ack 0x%02x. port: %d\n",
board_No(bp), status, ack, port_No (sx_get_port (bp, "Int")));
board_No(bp), status, ack,
port_No(sx_get_port(bp, "Int")));
} else if (status & SRSR_MREQint) {
ack = sx_in(bp, CD186x_MRAR);
if (ack == (SX_ID | GIVR_IT_MODEM))
sx_check_modem(bp);
else
printk(KERN_ERR "sx%d: status: 0x%x Bad modem ack 0x%02x.\n",
printk(KERN_ERR
"sx%d: status: 0x%x Bad modem ack 0x%02x.\n",
board_No(bp), status, ack);
}
@ -977,9 +1023,11 @@ static inline int sx_setup_board(struct specialix_board * bp)
return 0;
if (bp->flags & SX_BOARD_IS_PCI)
error = request_irq(bp->irq, sx_interrupt, IRQF_DISABLED | IRQF_SHARED, "specialix IO8+", bp);
error = request_irq(bp->irq, sx_interrupt,
IRQF_DISABLED | IRQF_SHARED, "specialix IO8+", bp);
else
error = request_irq(bp->irq, sx_interrupt, IRQF_DISABLED, "specialix IO8+", bp);
error = request_irq(bp->irq, sx_interrupt,
IRQF_DISABLED, "specialix IO8+", bp);
if (error)
return error;
@ -1006,10 +1054,7 @@ static inline void sx_shutdown_board(struct specialix_board *bp)
dprintk(SX_DEBUG_IRQ, "Freeing IRQ%d for board %d.\n",
bp->irq, board_No(bp));
free_irq(bp->irq, bp);
turn_ints_off(bp);
func_exit();
}
@ -1018,7 +1063,8 @@ static inline void sx_shutdown_board(struct specialix_board *bp)
* Setting up port characteristics.
* Must be called with disabled interrupts
*/
static void sx_change_speed(struct specialix_board *bp, struct specialix_port *port)
static void sx_change_speed(struct specialix_board *bp,
struct specialix_port *port)
{
struct tty_struct *tty;
unsigned long baud;
@ -1030,7 +1076,8 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
func_enter();
if (!(tty = port->port.tty) || !tty->termios) {
tty = port->port.tty;
if (!tty || !tty->termios) {
func_exit();
return;
}
@ -1066,16 +1113,14 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
spin_lock_irqsave(&bp->lock, flags);
sx_out(bp, CD186x_MSVR, port->MSVR);
spin_unlock_irqrestore(&bp->lock, flags);
}
else
} else
dprintk(SX_DEBUG_TERMIOS, "Can't drop DTR: no DTR.\n");
return;
} else {
/* Set DTR on */
if (!SX_CRTSCTS (tty)) {
if (!SX_CRTSCTS(tty))
port->MSVR |= MSVR_DTR;
}
}
/*
* Now we must calculate some speed depended things
@ -1084,14 +1129,15 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
/* Set baud rate for port */
tmp = port->custom_divisor ;
if (tmp)
printk (KERN_INFO "sx%d: Using custom baud rate divisor %ld. \n"
"This is an untested option, please be carefull.\n",
printk(KERN_INFO
"sx%d: Using custom baud rate divisor %ld. \n"
"This is an untested option, please be careful.\n",
port_No(port), tmp);
else
tmp = (((SX_OSCFREQ + baud/2) / baud +
CD186x_TPC/2) / CD186x_TPC);
tmp = (((SX_OSCFREQ + baud/2) / baud + CD186x_TPC/2) /
CD186x_TPC);
if ((tmp < 0x10) && time_before(again, jiffies)) {
if (tmp < 0x10 && time_before(again, jiffies)) {
again = jiffies + HZ * 60;
/* Page 48 of version 2.0 of the CL-CD1865 databook */
if (tmp >= 12) {
@ -1101,10 +1147,8 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
port_No(port), tmp);
} else {
printk(KERN_INFO "sx%d: Baud rate divisor is %ld. \n"
"Warning: overstressing Cirrus chip. "
"This might not work.\n"
"Read specialix.txt for more info.\n",
port_No (port), tmp);
"Warning: overstressing Cirrus chip. This might not work.\n"
"Read specialix.txt for more info.\n", port_No(port), tmp);
}
}
spin_lock_irqsave(&bp->lock, flags);
@ -1114,7 +1158,8 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
sx_out(bp, CD186x_TBPRL, tmp & 0xff);
spin_unlock_irqrestore(&bp->lock, flags);
if (port->custom_divisor)
baud = (SX_OSCFREQ + port->custom_divisor/2) / port->custom_divisor;
baud = (SX_OSCFREQ + port->custom_divisor/2) /
port->custom_divisor;
baud = (baud + 5) / 10; /* Estimated CPS */
/* Two timer ticks seems enough to wakeup something like SLIP driver */
@ -1175,7 +1220,8 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
spin_lock_irqsave(&bp->lock, flags);
tty->hw_stopped = !(sx_in(bp, CD186x_MSVR) & (MSVR_CTS|MSVR_DSR));
tty->hw_stopped = !(sx_in(bp, CD186x_MSVR) &
(MSVR_CTS|MSVR_DSR));
spin_unlock_irqrestore(&bp->lock, flags);
#else
port->COR2 |= COR2_CTSAE;
@ -1219,7 +1265,8 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
spin_lock_irqsave(&bp->lock, flags);
sx_out(bp, CD186x_CCR, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
/* Setting up modem option registers */
dprintk (SX_DEBUG_TERMIOS, "Mcor1 = %02x, mcor2 = %02x.\n", mcor1, mcor2);
dprintk(SX_DEBUG_TERMIOS, "Mcor1 = %02x, mcor2 = %02x.\n",
mcor1, mcor2);
sx_out(bp, CD186x_MCOR1, mcor1);
sx_out(bp, CD186x_MCOR2, mcor2);
spin_unlock_irqrestore(&bp->lock, flags);
@ -1238,7 +1285,8 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
/* Must be called with interrupts enabled */
static int sx_setup_port(struct specialix_board *bp, struct specialix_port *port)
static int sx_setup_port(struct specialix_board *bp,
struct specialix_port *port)
{
unsigned long flags;
@ -1253,7 +1301,8 @@ static int sx_setup_port(struct specialix_board *bp, struct specialix_port *port
/* We may sleep in get_zeroed_page() */
unsigned long tmp;
if (!(tmp = get_zeroed_page(GFP_KERNEL))) {
tmp = get_zeroed_page(GFP_KERNEL);
if (tmp == 0L) {
func_exit();
return -ENOMEM;
}
@ -1284,7 +1333,8 @@ static int sx_setup_port(struct specialix_board *bp, struct specialix_port *port
/* Must be called with interrupts disabled */
static void sx_shutdown_port(struct specialix_board *bp, struct specialix_port *port)
static void sx_shutdown_port(struct specialix_board *bp,
struct specialix_port *port)
{
struct tty_struct *tty;
int i;
@ -1298,11 +1348,11 @@ static void sx_shutdown_port(struct specialix_board *bp, struct specialix_port *
}
if (sx_debug & SX_DEBUG_FIFO) {
dprintk(SX_DEBUG_FIFO, "sx%d: port %d: %ld overruns, FIFO hits [ ",
dprintk(SX_DEBUG_FIFO,
"sx%d: port %d: %ld overruns, FIFO hits [ ",
board_No(bp), port_No(port), port->overrun);
for (i = 0; i < 10; i++) {
for (i = 0; i < 10; i++)
dprintk(SX_DEBUG_FIFO, "%ld ", port->hits[i]);
}
dprintk(SX_DEBUG_FIFO, "].\n");
}
@ -1315,7 +1365,8 @@ static void sx_shutdown_port(struct specialix_board *bp, struct specialix_port *
spin_lock_irqsave(&bp->lock, flags);
sx_out(bp, CD186x_CAR, port_No(port));
if (!(tty = port->port.tty) || C_HUPCL(tty)) {
tty = port->port.tty;
if (tty == NULL || C_HUPCL(tty)) {
/* Drop DTR */
sx_out(bp, CD186x_MSVDTR, 0);
}
@ -1389,9 +1440,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
retval = 0;
add_wait_queue(&port->port.open_wait, &wait);
spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp)) {
if (!tty_hung_up_p(filp))
port->port.count--;
}
spin_unlock_irqrestore(&port->lock, flags);
port->port.blocked_open++;
while (1) {
@ -1430,9 +1480,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
set_current_state(TASK_RUNNING);
remove_wait_queue(&port->port.open_wait, &wait);
spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp)) {
if (!tty_hung_up_p(filp))
port->port.count++;
}
port->port.blocked_open--;
spin_unlock_irqrestore(&port->lock, flags);
if (retval) {
@ -1470,7 +1519,8 @@ static int sx_open(struct tty_struct * tty, struct file * filp)
for (i = 0; i < 10; i++)
port->hits[i] = 0;
dprintk (SX_DEBUG_OPEN, "Board = %d, bp = %p, port = %p, portno = %d.\n",
dprintk(SX_DEBUG_OPEN,
"Board = %d, bp = %p, port = %p, portno = %d.\n",
board, bp, port, SX_PORT(tty->index));
if (sx_paranoia_check(port, tty->name, "sx_open")) {
@ -1478,7 +1528,8 @@ static int sx_open(struct tty_struct * tty, struct file * filp)
return -ENODEV;
}
if ((error = sx_setup_board(bp))) {
error = sx_setup_board(bp);
if (error) {
func_exit();
return error;
}
@ -1490,12 +1541,14 @@ static int sx_open(struct tty_struct * tty, struct file * filp)
port->port.tty = tty;
spin_unlock_irqrestore(&bp->lock, flags);
if ((error = sx_setup_port(bp, port))) {
error = sx_setup_port(bp, port);
if (error) {
func_enter();
return error;
}
if ((error = block_til_ready(tty, filp, port))) {
error = block_til_ready(tty, filp, port);
if (error) {
func_enter();
return error;
}
@ -1571,9 +1624,8 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
tty->closing = 1;
spin_unlock_irqrestore(&port->lock, flags);
dprintk(SX_DEBUG_OPEN, "Closing\n");
if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
tty_wait_until_sent(tty, port->port.closing_wait);
}
/*
* At this point we stop accepting input. To do this, we
* disable the receive line status interrupts, and tell the
@ -1607,12 +1659,14 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
}
if (--bp->count < 0) {
printk(KERN_ERR "sx%d: sx_shutdown_port: bad board count: %d port: %d\n",
printk(KERN_ERR
"sx%d: sx_shutdown_port: bad board count: %d port: %d\n",
board_No(bp), bp->count, tty->index);
bp->count = 0;
}
if (--port->port.count < 0) {
printk(KERN_ERR "sx%d: sx_close: bad port count for tty%d: %d\n",
printk(KERN_ERR
"sx%d: sx_close: bad port count for tty%d: %d\n",
board_No(bp), port_No(port), port->port.count);
port->port.count = 0;
}
@ -1625,9 +1679,9 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
port->port.tty = NULL;
spin_unlock_irqrestore(&port->lock, flags);
if (port->port.blocked_open) {
if (port->port.close_delay) {
msleep_interruptible(jiffies_to_msecs(port->port.close_delay));
}
if (port->port.close_delay)
msleep_interruptible(
jiffies_to_msecs(port->port.close_delay));
wake_up_interruptible(&port->port.open_wait);
}
port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
@ -1710,8 +1764,9 @@ static int sx_put_char(struct tty_struct * tty, unsigned char ch)
bp = port_Board(port);
spin_lock_irqsave(&port->lock, flags);
dprintk (SX_DEBUG_TX, "xmit_cnt: %d xmit_buf: %p\n", port->xmit_cnt, port->xmit_buf);
if ((port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) || (!port->xmit_buf)) {
dprintk(SX_DEBUG_TX, "xmit_cnt: %d xmit_buf: %p\n",
port->xmit_cnt, port->xmit_buf);
if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1 || !port->xmit_buf) {
spin_unlock_irqrestore(&port->lock, flags);
dprintk(SX_DEBUG_TX, "Exit size\n");
func_exit();
@ -1790,8 +1845,6 @@ static int sx_chars_in_buffer(struct tty_struct *tty)
return port->xmit_cnt;
}
static int sx_tiocmget(struct tty_struct *tty, struct file *file)
{
struct specialix_port *port = (struct specialix_port *)tty->driver_data;
@ -1886,7 +1939,8 @@ static int sx_tiocmset(struct tty_struct *tty, struct file *file,
}
static inline void sx_send_break(struct specialix_port * port, unsigned long length)
static inline void sx_send_break(struct specialix_port *port,
unsigned long length)
{
struct specialix_board *bp = port_Board(port);
unsigned long flags;
@ -1952,9 +2006,9 @@ static inline int sx_set_serial_info(struct specialix_port * port,
port->port.closing_wait = tmp.closing_wait;
port->custom_divisor = tmp.custom_divisor;
}
if (change_speed) {
if (change_speed)
sx_change_speed(bp, port);
}
func_exit();
unlock_kernel();
return 0;
@ -2065,7 +2119,8 @@ static void sx_throttle(struct tty_struct * tty)
/* Or maybe we're supposed (allowed?) to do our side of hw
handshake anyway, even when hardware handshake is off.
When you see this in your logs, please report.... */
printk (KERN_ERR "sx%d: Need to throttle, but can't (hardware hs is off)\n",
printk(KERN_ERR
"sx%d: Need to throttle, but can't (hardware hs is off)\n",
port_No(port));
}
spin_lock_irqsave(&bp->lock, flags);
@ -2103,9 +2158,9 @@ static void sx_unthrottle(struct tty_struct * tty)
spin_lock_irqsave(&port->lock, flags);
/* XXXX Use DTR INSTEAD???? */
if (SX_CRTSCTS(tty)) {
if (SX_CRTSCTS(tty))
port->MSVR |= MSVR_DTR;
} /* Else clause: see remark in "sx_throttle"... */
/* Else clause: see remark in "sx_throttle"... */
spin_lock_irqsave(&bp->lock, flags);
sx_out(bp, CD186x_CAR, port_No(port));
spin_unlock_irqrestore(&bp->lock, flags);
@ -2201,7 +2256,8 @@ static void sx_hangup(struct tty_struct * tty)
spin_lock_irqsave(&port->lock, flags);
bp->count -= port->port.count;
if (bp->count < 0) {
printk(KERN_ERR "sx%d: sx_hangup: bad board count: %d port: %d\n",
printk(KERN_ERR
"sx%d: sx_hangup: bad board count: %d port: %d\n",
board_No(bp), bp->count, tty->index);
bp->count = 0;
}
@ -2215,7 +2271,8 @@ static void sx_hangup(struct tty_struct * tty)
}
static void sx_set_termios(struct tty_struct * tty, struct ktermios * old_termios)
static void sx_set_termios(struct tty_struct *tty,
struct ktermios *old_termios)
{
struct specialix_port *port = (struct specialix_port *)tty->driver_data;
unsigned long flags;
@ -2283,9 +2340,11 @@ static int sx_init_drivers(void)
specialix_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(specialix_driver, &sx_ops);
if ((error = tty_register_driver(specialix_driver))) {
error = tty_register_driver(specialix_driver);
if (error) {
put_tty_driver(specialix_driver);
printk(KERN_ERR "sx: Couldn't register specialix IO8+ driver, error = %d\n",
printk(KERN_ERR
"sx: Couldn't register specialix IO8+ driver, error = %d\n",
error);
func_exit();
return 1;
@ -2351,9 +2410,9 @@ static int __init specialix_init(void)
continue;
}
pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX,
PCI_DEVICE_ID_SPECIALIX_IO8,
pdev);
if (!pdev) break;
PCI_DEVICE_ID_SPECIALIX_IO8, pdev);
if (!pdev)
break;
if (pci_enable_device(pdev))
continue;