Commit 9492e135 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

riscom8: coding style

Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8e8bcf16
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <asm/io.h> #include <linux/io.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/ioport.h> #include <linux/ioport.h>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include <linux/tty_flip.h> #include <linux/tty_flip.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/uaccess.h> #include <linux/uaccess.h>
#include "riscom8.h" #include "riscom8.h"
#include "riscom8_reg.h" #include "riscom8_reg.h"
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
#define RISCOM_PARANOIA_CHECK #define RISCOM_PARANOIA_CHECK
/* /*
* Crazy InteliCom/8 boards sometimes has swapped CTS & DSR signals. * Crazy InteliCom/8 boards sometimes have swapped CTS & DSR signals.
* You can slightly speed up things by #undefing the following option, * You can slightly speed up things by #undefing the following option,
* if you are REALLY sure that your board is correct one. * if you are REALLY sure that your board is correct one.
*/ */
...@@ -112,7 +112,7 @@ static unsigned short rc_ioport[] = { ...@@ -112,7 +112,7 @@ static unsigned short rc_ioport[] = {
#define RC_NIOPORT ARRAY_SIZE(rc_ioport) #define RC_NIOPORT ARRAY_SIZE(rc_ioport)
static inline int rc_paranoia_check(struct riscom_port const * port, static int rc_paranoia_check(struct riscom_port const *port,
char *name, const char *routine) char *name, const char *routine)
{ {
#ifdef RISCOM_PARANOIA_CHECK #ifdef RISCOM_PARANOIA_CHECK
...@@ -140,38 +140,39 @@ static inline int rc_paranoia_check(struct riscom_port const * port, ...@@ -140,38 +140,39 @@ static inline int rc_paranoia_check(struct riscom_port const * port,
*/ */
/* Get board number from pointer */ /* Get board number from pointer */
static inline int board_No (struct riscom_board const * bp) static inline int board_No(struct riscom_board const *bp)
{ {
return bp - rc_board; return bp - rc_board;
} }
/* Get port number from pointer */ /* Get port number from pointer */
static inline int port_No (struct riscom_port const * port) static inline int port_No(struct riscom_port const *port)
{ {
return RC_PORT(port - rc_port); return RC_PORT(port - rc_port);
} }
/* Get pointer to board from pointer to port */ /* Get pointer to board from pointer to port */
static inline struct riscom_board * port_Board(struct riscom_port const * port) static inline struct riscom_board *port_Board(struct riscom_port const *port)
{ {
return &rc_board[RC_BOARD(port - rc_port)]; return &rc_board[RC_BOARD(port - rc_port)];
} }
/* Input Byte from CL CD180 register */ /* Input Byte from CL CD180 register */
static inline unsigned char rc_in(struct riscom_board const * bp, unsigned short reg) static inline unsigned char rc_in(struct riscom_board const *bp,
unsigned short reg)
{ {
return inb(bp->base + RC_TO_ISA(reg)); return inb(bp->base + RC_TO_ISA(reg));
} }
/* Output Byte to CL CD180 register */ /* Output Byte to CL CD180 register */
static inline void rc_out(struct riscom_board const * bp, unsigned short reg, static inline void rc_out(struct riscom_board const *bp, unsigned short reg,
unsigned char val) unsigned char val)
{ {
outb(val, bp->base + RC_TO_ISA(reg)); outb(val, bp->base + RC_TO_ISA(reg));
} }
/* Wait for Channel Command Register ready */ /* Wait for Channel Command Register ready */
static inline void rc_wait_CCR(struct riscom_board const * bp) static void rc_wait_CCR(struct riscom_board const *bp)
{ {
unsigned long delay; unsigned long delay;
...@@ -187,7 +188,7 @@ static inline void rc_wait_CCR(struct riscom_board const * bp) ...@@ -187,7 +188,7 @@ static inline void rc_wait_CCR(struct riscom_board const * bp)
* RISCom/8 probe functions. * RISCom/8 probe functions.
*/ */
static inline int rc_request_io_range(struct riscom_board * const bp) static int rc_request_io_range(struct riscom_board * const bp)
{ {
int i; int i;
...@@ -200,12 +201,12 @@ static inline int rc_request_io_range(struct riscom_board * const bp) ...@@ -200,12 +201,12 @@ static inline int rc_request_io_range(struct riscom_board * const bp)
out_release: out_release:
printk(KERN_INFO "rc%d: Skipping probe at 0x%03x. IO address in use.\n", printk(KERN_INFO "rc%d: Skipping probe at 0x%03x. IO address in use.\n",
board_No(bp), bp->base); board_No(bp), bp->base);
while(--i >= 0) while (--i >= 0)
release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1); release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1);
return 1; return 1;
} }
static inline void rc_release_io_range(struct riscom_board * const bp) static void rc_release_io_range(struct riscom_board * const bp)
{ {
int i; int i;
...@@ -214,7 +215,7 @@ static inline void rc_release_io_range(struct riscom_board * const bp) ...@@ -214,7 +215,7 @@ static inline void rc_release_io_range(struct riscom_board * const bp)
} }
/* Reset and setup CD180 chip */ /* Reset and setup CD180 chip */
static void __init rc_init_CD180(struct riscom_board const * bp) static void __init rc_init_CD180(struct riscom_board const *bp)
{ {
unsigned long flags; unsigned long flags;
...@@ -229,8 +230,8 @@ static void __init rc_init_CD180(struct riscom_board const * bp) ...@@ -229,8 +230,8 @@ static void __init rc_init_CD180(struct riscom_board const * bp)
rc_out(bp, CD180_GIVR, RC_ID); /* Set ID for this chip */ rc_out(bp, CD180_GIVR, RC_ID); /* Set ID for this chip */
rc_out(bp, CD180_GICR, 0); /* Clear all bits */ rc_out(bp, CD180_GICR, 0); /* Clear all bits */
rc_out(bp, CD180_PILR1, RC_ACK_MINT); /* Prio for modem intr */ rc_out(bp, CD180_PILR1, RC_ACK_MINT); /* Prio for modem intr */
rc_out(bp, CD180_PILR2, RC_ACK_TINT); /* Prio for transmitter intr */ rc_out(bp, CD180_PILR2, RC_ACK_TINT); /* Prio for tx intr */
rc_out(bp, CD180_PILR3, RC_ACK_RINT); /* Prio for receiver intr */ rc_out(bp, CD180_PILR3, RC_ACK_RINT); /* Prio for rx intr */
/* Setting up prescaler. We need 4 ticks per 1 ms */ /* Setting up prescaler. We need 4 ticks per 1 ms */
rc_out(bp, CD180_PPRH, (RC_OSCFREQ/(1000000/RISCOM_TPS)) >> 8); rc_out(bp, CD180_PPRH, (RC_OSCFREQ/(1000000/RISCOM_TPS)) >> 8);
...@@ -272,7 +273,7 @@ static int __init rc_probe(struct riscom_board *bp) ...@@ -272,7 +273,7 @@ static int __init rc_probe(struct riscom_board *bp)
rc_out(bp, CD180_CAR, 2); /* Select port 2 */ rc_out(bp, CD180_CAR, 2); /* Select port 2 */
rc_wait_CCR(bp); rc_wait_CCR(bp);
rc_out(bp, CD180_CCR, CCR_TXEN); /* Enable transmitter */ rc_out(bp, CD180_CCR, CCR_TXEN); /* Enable transmitter */
rc_out(bp, CD180_IER, IER_TXRDY); /* Enable tx empty intr */ rc_out(bp, CD180_IER, IER_TXRDY);/* Enable tx empty intr */
msleep(50); msleep(50);
irqs = probe_irq_off(irqs); irqs = probe_irq_off(irqs);
val1 = rc_in(bp, RC_BSR); /* Get Board Status reg */ val1 = rc_in(bp, RC_BSR); /* Get Board Status reg */
...@@ -312,32 +313,32 @@ static int __init rc_probe(struct riscom_board *bp) ...@@ -312,32 +313,32 @@ static int __init rc_probe(struct riscom_board *bp)
* *
*/ */
static inline struct riscom_port * rc_get_port(struct riscom_board const * bp, static struct riscom_port *rc_get_port(struct riscom_board const *bp,
unsigned char const * what) unsigned char const *what)
{ {
unsigned char channel; unsigned char channel;
struct riscom_port * port; struct riscom_port *port;
channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF; channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF;
if (channel < CD180_NCH) { if (channel < CD180_NCH) {
port = &rc_port[board_No(bp) * RC_NPORT + channel]; port = &rc_port[board_No(bp) * RC_NPORT + channel];
if (port->flags & ASYNC_INITIALIZED) { if (port->flags & ASYNC_INITIALIZED)
return port; return port;
} }
}
printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n", printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n",
board_No(bp), what, channel); board_No(bp), what, channel);
return NULL; return NULL;
} }
static inline void rc_receive_exc(struct riscom_board const * bp) static void rc_receive_exc(struct riscom_board const *bp)
{ {
struct riscom_port *port; struct riscom_port *port;
struct tty_struct *tty; struct tty_struct *tty;
unsigned char status; unsigned char status;
unsigned char ch, flag; unsigned char ch, flag;
if (!(port = rc_get_port(bp, "Receive"))) port = rc_get_port(bp, "Receive");
if (port == NULL)
return; return;
tty = port->tty; tty = port->tty;
...@@ -351,9 +352,8 @@ static inline void rc_receive_exc(struct riscom_board const * bp) ...@@ -351,9 +352,8 @@ static inline void rc_receive_exc(struct riscom_board const * bp)
status = rc_in(bp, CD180_RCSR) & port->mark_mask; status = rc_in(bp, CD180_RCSR) & port->mark_mask;
#endif #endif
ch = rc_in(bp, CD180_RDR); ch = rc_in(bp, CD180_RDR);
if (!status) { if (!status)
return; return;
}
if (status & RCSR_TOUT) { if (status & RCSR_TOUT) {
printk(KERN_WARNING "rc%d: port %d: Receiver timeout. " printk(KERN_WARNING "rc%d: port %d: Receiver timeout. "
"Hardware problems ?\n", "Hardware problems ?\n",
...@@ -375,7 +375,6 @@ static inline void rc_receive_exc(struct riscom_board const * bp) ...@@ -375,7 +375,6 @@ static inline void rc_receive_exc(struct riscom_board const * bp)
else if (status & RCSR_OE) else if (status & RCSR_OE)
flag = TTY_OVERRUN; flag = TTY_OVERRUN;
else else
flag = TTY_NORMAL; flag = TTY_NORMAL;
...@@ -383,13 +382,14 @@ static inline void rc_receive_exc(struct riscom_board const * bp) ...@@ -383,13 +382,14 @@ static inline void rc_receive_exc(struct riscom_board const * bp)
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
} }
static inline void rc_receive(struct riscom_board const * bp) static void rc_receive(struct riscom_board const *bp)
{ {
struct riscom_port *port; struct riscom_port *port;
struct tty_struct *tty; struct tty_struct *tty;
unsigned char count; unsigned char count;
if (!(port = rc_get_port(bp, "Receive"))) port = rc_get_port(bp, "Receive");
if (port == NULL)
return; return;
tty = port->tty; tty = port->tty;
...@@ -412,14 +412,14 @@ static inline void rc_receive(struct riscom_board const * bp) ...@@ -412,14 +412,14 @@ static inline void rc_receive(struct riscom_board const * bp)
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
} }
static inline void rc_transmit(struct riscom_board const * bp) static void rc_transmit(struct riscom_board const *bp)
{ {
struct riscom_port *port; struct riscom_port *port;
struct tty_struct *tty; struct tty_struct *tty;
unsigned char count; unsigned char count;
port = rc_get_port(bp, "Transmit");
if (!(port = rc_get_port(bp, "Transmit"))) if (port == NULL)
return; return;
tty = port->tty; tty = port->tty;
...@@ -451,7 +451,8 @@ static inline void rc_transmit(struct riscom_board const * bp) ...@@ -451,7 +451,8 @@ static inline void rc_transmit(struct riscom_board const * bp)
rc_out(bp, CD180_TDR, CD180_C_ESC); rc_out(bp, CD180_TDR, CD180_C_ESC);
rc_out(bp, CD180_TDR, CD180_C_DELAY); rc_out(bp, CD180_TDR, CD180_C_DELAY);
rc_out(bp, CD180_TDR, count); rc_out(bp, CD180_TDR, count);
if (!(port->break_length -= count)) port->break_length -= count;
if (port->break_length == 0)
port->break_length--; port->break_length--;
} else { } else {
rc_out(bp, CD180_TDR, CD180_C_ESC); rc_out(bp, CD180_TDR, CD180_C_ESC);
...@@ -481,13 +482,14 @@ static inline void rc_transmit(struct riscom_board const * bp) ...@@ -481,13 +482,14 @@ static inline void rc_transmit(struct riscom_board const * bp)
tty_wakeup(tty); tty_wakeup(tty);
} }
static inline void rc_check_modem(struct riscom_board const * bp) static void rc_check_modem(struct riscom_board const *bp)
{ {
struct riscom_port *port; struct riscom_port *port;
struct tty_struct *tty; struct tty_struct *tty;
unsigned char mcr; unsigned char mcr;
if (!(port = rc_get_port(bp, "Modem"))) port = rc_get_port(bp, "Modem");
if (port == NULL)
return; return;
tty = port->tty; tty = port->tty;
...@@ -532,7 +534,7 @@ static inline void rc_check_modem(struct riscom_board const * bp) ...@@ -532,7 +534,7 @@ static inline void rc_check_modem(struct riscom_board const * bp)
} }
/* The main interrupt processing routine */ /* The main interrupt processing routine */
static irqreturn_t rc_interrupt(int dummy, void * dev_id) static irqreturn_t rc_interrupt(int dummy, void *dev_id)
{ {
unsigned char status; unsigned char status;
unsigned char ack; unsigned char ack;
...@@ -550,10 +552,8 @@ static irqreturn_t rc_interrupt(int dummy, void * dev_id) ...@@ -550,10 +552,8 @@ static irqreturn_t rc_interrupt(int dummy, void * dev_id)
if (status & RC_BSR_TOUT) if (status & RC_BSR_TOUT)
printk(KERN_WARNING "rc%d: Got timeout. Hardware " printk(KERN_WARNING "rc%d: Got timeout. Hardware "
"error?\n", board_No(bp)); "error?\n", board_No(bp));
else if (status & RC_BSR_RINT) { else if (status & RC_BSR_RINT) {
ack = rc_in(bp, RC_ACK_RINT); ack = rc_in(bp, RC_ACK_RINT);
if (ack == (RC_ID | GIVR_IT_RCV)) if (ack == (RC_ID | GIVR_IT_RCV))
rc_receive(bp); rc_receive(bp);
else if (ack == (RC_ID | GIVR_IT_REXC)) else if (ack == (RC_ID | GIVR_IT_REXC))
...@@ -562,29 +562,23 @@ static irqreturn_t rc_interrupt(int dummy, void * dev_id) ...@@ -562,29 +562,23 @@ static irqreturn_t rc_interrupt(int dummy, void * dev_id)
printk(KERN_WARNING "rc%d: Bad receive ack " printk(KERN_WARNING "rc%d: Bad receive ack "
"0x%02x.\n", "0x%02x.\n",
board_No(bp), ack); board_No(bp), ack);
} else if (status & RC_BSR_TINT) { } else if (status & RC_BSR_TINT) {
ack = rc_in(bp, RC_ACK_TINT); ack = rc_in(bp, RC_ACK_TINT);
if (ack == (RC_ID | GIVR_IT_TX)) if (ack == (RC_ID | GIVR_IT_TX))
rc_transmit(bp); rc_transmit(bp);
else else
printk(KERN_WARNING "rc%d: Bad transmit ack " printk(KERN_WARNING "rc%d: Bad transmit ack "
"0x%02x.\n", "0x%02x.\n",
board_No(bp), ack); board_No(bp), ack);
} else /* if (status & RC_BSR_MINT) */ { } else /* if (status & RC_BSR_MINT) */ {
ack = rc_in(bp, RC_ACK_MINT); ack = rc_in(bp, RC_ACK_MINT);
if (ack == (RC_ID | GIVR_IT_MODEM)) if (ack == (RC_ID | GIVR_IT_MODEM))
rc_check_modem(bp); rc_check_modem(bp);
else else
printk(KERN_WARNING "rc%d: Bad modem ack " printk(KERN_WARNING "rc%d: Bad modem ack "
"0x%02x.\n", "0x%02x.\n",
board_No(bp), ack); board_No(bp), ack);
} }
rc_out(bp, CD180_EOIR, 0); /* Mark end of interrupt */ rc_out(bp, CD180_EOIR, 0); /* Mark end of interrupt */
rc_out(bp, RC_CTOUT, 0); /* Clear timeout flag */ rc_out(bp, RC_CTOUT, 0); /* Clear timeout flag */
} }
...@@ -596,7 +590,7 @@ static irqreturn_t rc_interrupt(int dummy, void * dev_id) ...@@ -596,7 +590,7 @@ static irqreturn_t rc_interrupt(int dummy, void * dev_id)
*/ */
/* Called with disabled interrupts */ /* Called with disabled interrupts */
static int rc_setup_board(struct riscom_board * bp) static int rc_setup_board(struct riscom_board *bp)
{ {
int error; int error;
...@@ -638,13 +632,13 @@ static void rc_shutdown_board(struct riscom_board *bp) ...@@ -638,13 +632,13 @@ static void rc_shutdown_board(struct riscom_board *bp)
*/ */
static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port) static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
{ {
struct tty_struct *tty; struct tty_struct *tty = port->tty;
unsigned long baud; unsigned long baud;
long tmp; long tmp;
unsigned char cor1 = 0, cor3 = 0; unsigned char cor1 = 0, cor3 = 0;
unsigned char mcor1 = 0, mcor2 = 0; unsigned char mcor1 = 0, mcor2 = 0;
if (!(tty = port->tty) || !tty->termios) if (tty == NULL || tty->termios == NULL)
return; return;
port->IER = 0; port->IER = 0;
...@@ -706,7 +700,6 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port) ...@@ -706,7 +700,6 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
cor1 |= COR1_8BITS; cor1 |= COR1_8BITS;
break; break;
} }
if (C_CSTOPB(tty)) if (C_CSTOPB(tty))
cor1 |= COR1_2SB; cor1 |= COR1_2SB;
...@@ -738,7 +731,8 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port) ...@@ -738,7 +731,8 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
port->IER |= IER_DSR | IER_CTS; port->IER |= IER_DSR | IER_CTS;
mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD; mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
mcor2 |= MCOR2_DSROD | MCOR2_CTSOD; mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
tty->hw_stopped = !(rc_in(bp, CD180_MSVR) & (MSVR_CTS|MSVR_DSR)); tty->hw_stopped = !(rc_in(bp, CD180_MSVR) &
(MSVR_CTS|MSVR_DSR));
#else #else
port->COR2 |= COR2_CTSAE; port->COR2 |= COR2_CTSAE;
#endif #endif
...@@ -797,26 +791,20 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port) ...@@ -797,26 +791,20 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
if (!port->xmit_buf) { if (!port->xmit_buf) {
/* We may sleep in get_zeroed_page() */ /* We may sleep in get_zeroed_page() */
unsigned long tmp; unsigned long tmp = get_zeroed_page(GFP_KERNEL);
if (tmp == 0)
if (!(tmp = get_zeroed_page(GFP_KERNEL)))
return -ENOMEM; return -ENOMEM;
if (port->xmit_buf)
if (port->xmit_buf) {
free_page(tmp); free_page(tmp);
return -ERESTARTSYS; else
}
port->xmit_buf = (unsigned char *) tmp; port->xmit_buf = (unsigned char *) tmp;
} }
spin_lock_irqsave(&riscom_lock, flags); spin_lock_irqsave(&riscom_lock, flags);
if (port->tty) if (port->tty)
clear_bit(TTY_IO_ERROR, &port->tty->flags); clear_bit(TTY_IO_ERROR, &port->tty->flags);
if (port->count == 1) if (port->count == 1)
bp->count++; bp->count++;
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
rc_change_speed(bp, port); rc_change_speed(bp, port);
port->flags |= ASYNC_INITIALIZED; port->flags |= ASYNC_INITIALIZED;
...@@ -843,9 +831,8 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port) ...@@ -843,9 +831,8 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
printk(KERN_INFO "rc%d: port %d: FIFO hits [ ", printk(KERN_INFO "rc%d: port %d: FIFO hits [ ",
board_No(bp), port_No(port)); board_No(bp), port_No(port));
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++)
printk("%ld ", port->hits[i]); printk("%ld ", port->hits[i]);
}
printk("].\n"); printk("].\n");
} }
#endif #endif
...@@ -854,7 +841,9 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port) ...@@ -854,7 +841,9 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
port->xmit_buf = NULL; port->xmit_buf = NULL;
} }
if (!(tty = port->tty) || C_HUPCL(tty)) { tty = port->tty;
if (tty == NULL || C_HUPCL(tty)) {
/* Drop DTR */ /* Drop DTR */
bp->DTR |= (1u << port_No(port)); bp->DTR |= (1u << port_No(port));
rc_out(bp, RC_DTR, bp->DTR); rc_out(bp, RC_DTR, bp->DTR);
...@@ -879,7 +868,6 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port) ...@@ -879,7 +868,6 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
board_No(bp), bp->count); board_No(bp), bp->count);
bp->count = 0; bp->count = 0;
} }
/* /*
* If this is the last opened port on the board * If this is the last opened port on the board
* shutdown whole board * shutdown whole board
...@@ -888,8 +876,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port) ...@@ -888,8 +876,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
rc_shutdown_board(bp); rc_shutdown_board(bp);
} }
static int block_til_ready(struct tty_struct *tty, struct file *filp,
static int block_til_ready(struct tty_struct *tty, struct file * filp,
struct riscom_port *port) struct riscom_port *port)
{ {
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
...@@ -983,12 +970,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -983,12 +970,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
return 0; return 0;
} }
static int rc_open(struct tty_struct * tty, struct file * filp) static int rc_open(struct tty_struct *tty, struct file *filp)
{ {
int board; int board;
int error; int error;
struct riscom_port * port; struct riscom_port *port;
struct riscom_board * bp; struct riscom_board *bp;
board = RC_BOARD(tty->index); board = RC_BOARD(tty->index);
if (board >= RC_NBOARD || !(rc_board[board].flags & RC_BOARD_PRESENT)) if (board >= RC_NBOARD || !(rc_board[board].flags & RC_BOARD_PRESENT))
...@@ -999,20 +986,18 @@ static int rc_open(struct tty_struct * tty, struct file * filp) ...@@ -999,20 +986,18 @@ static int rc_open(struct tty_struct * tty, struct file * filp)
if (rc_paranoia_check(port, tty->name, "rc_open")) if (rc_paranoia_check(port, tty->name, "rc_open"))
return -ENODEV; return -ENODEV;
if ((error = rc_setup_board(bp))) error = rc_setup_board(bp);
if (error)
return error; return error;
port->count++; port->count++;
tty->driver_data = port; tty->driver_data = port;
port->tty = tty; port->tty = tty;
if ((error = rc_setup_port(bp, port))) error = rc_setup_port(bp, port);
if (error == 0)
error = block_til_ready(tty, filp, port);
return error; return error;
if ((error = block_til_ready(tty, filp, port)))
return error;
return 0;
} }
static void rc_flush_buffer(struct tty_struct *tty) static void rc_flush_buffer(struct tty_struct *tty)
...@@ -1024,16 +1009,13 @@ static void rc_flush_buffer(struct tty_struct *tty) ...@@ -1024,16 +1009,13 @@ static void rc_flush_buffer(struct tty_struct *tty)
return; return;
spin_lock_irqsave(&riscom_lock, flags); spin_lock_irqsave(&riscom_lock, flags);
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
spin_unlock_irqrestore(&riscom_lock, flags); spin_unlock_irqrestore(&riscom_lock, flags);
tty_wakeup(tty); tty_wakeup(tty);
} }
static void rc_close(struct tty_struct *tty, struct file *filp)
static void rc_close(struct tty_struct * tty, struct file * filp)
{ {
struct riscom_port *port = (struct riscom_port *) tty->driver_data; struct riscom_port *port = (struct riscom_port *) tty->driver_data;
struct riscom_board *bp; struct riscom_board *bp;
...@@ -1088,8 +1070,8 @@ static void rc_close(struct tty_struct * tty, struct file * filp) ...@@ -1088,8 +1070,8 @@ static void rc_close(struct tty_struct * tty, struct file * filp)
* has completely drained; this is especially * has completely drained; this is especially
* important if there is a transmit FIFO! * important if there is a transmit FIFO!
*/ */
timeout = jiffies+HZ; timeout = jiffies + HZ;
while(port->IER & IER_TXEMPTY) { while (port->IER & IER_TXEMPTY) {
msleep_interruptible(jiffies_to_msecs(port->timeout)); msleep_interruptible(jiffies_to_msecs(port->timeout));
if (time_after(jiffies, timeout)) if (time_after(jiffies, timeout))
break; break;
...@@ -1102,9 +1084,8 @@ static void rc_close(struct tty_struct * tty, struct file * filp) ...@@ -1102,9 +1084,8 @@ static void rc_close(struct tty_struct * tty, struct file * filp)
tty->closing = 0; tty->closing = 0;
port->tty = NULL; port->tty = NULL;
if (port->blocked_open) { if (port->blocked_open) {
if (port->close_delay) { if (port->close_delay)
msleep_interruptible(jiffies_to_msecs(port->close_delay)); msleep_interruptible(jiffies_to_msecs(port->close_delay));
}
wake_up_interruptible(&port->open_wait); wake_up_interruptible(&port->open_wait);
} }
port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
...@@ -1114,7 +1095,7 @@ static void rc_close(struct tty_struct * tty, struct file * filp) ...@@ -1114,7 +1095,7 @@ static void rc_close(struct tty_struct * tty, struct file * filp)
spin_unlock_irqrestore(&riscom_lock, flags); spin_unlock_irqrestore(&riscom_lock, flags);
} }
static int rc_write(struct tty_struct * tty, static int rc_write(struct tty_struct *tty,
const unsigned char *buf, int count) const unsigned char *buf, int count)
{ {
struct riscom_port *port = (struct riscom_port *)tty->driver_data; struct riscom_port *port = (struct riscom_port *)tty->driver_data;
...@@ -1161,7 +1142,7 @@ static int rc_write(struct tty_struct * tty, ...@@ -1161,7 +1142,7 @@ static int rc_write(struct tty_struct * tty,
return total; return total;
} }
static int rc_put_char(struct tty_struct * tty, unsigned char ch) static int rc_put_char(struct tty_struct *tty, unsigned char ch)
{ {
struct riscom_port *port = (struct riscom_port *)tty->driver_data; struct riscom_port *port = (struct riscom_port *)tty->driver_data;
unsigned long flags; unsigned long flags;
...@@ -1188,7 +1169,7 @@ static int rc_put_char(struct tty_struct * tty, unsigned char ch) ...@@ -1188,7 +1169,7 @@ static int rc_put_char(struct tty_struct * tty, unsigned char ch)
return ret; return ret;
} }
static void rc_flush_chars(struct tty_struct * tty) static void rc_flush_chars(struct tty_struct *tty)
{ {
struct riscom_port *port = (struct riscom_port *)tty->driver_data; struct riscom_port *port = (struct riscom_port *)tty->driver_data;
unsigned long flags; unsigned long flags;
...@@ -1209,7 +1190,7 @@ static void rc_flush_chars(struct tty_struct * tty) ...@@ -1209,7 +1190,7 @@ static void rc_flush_chars(struct tty_struct * tty)
spin_unlock_irqrestore(&riscom_lock, flags); spin_unlock_irqrestore(&riscom_lock, flags);
} }
static int rc_write_room(struct tty_struct * tty) static int rc_write_room(struct tty_struct *tty)
{ {
struct riscom_port *port = (struct riscom_port *)tty->driver_data; struct riscom_port *port = (struct riscom_port *)tty->driver_data;
int ret; int ret;
...@@ -1236,7 +1217,7 @@ static int rc_chars_in_buffer(struct tty_struct *tty) ...@@ -1236,7 +1217,7 @@ static int rc_chars_in_buffer(struct tty_struct *tty)
static int rc_tiocmget(struct tty_struct *tty, struct file *file) static int rc_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct riscom_port *port = (struct riscom_port *)tty->driver_data; struct riscom_port *port = (struct riscom_port *)tty->driver_data;
struct riscom_board * bp; struct riscom_board *bp;
unsigned char status; unsigned char status;
unsigned int result; unsigned int result;
unsigned long flags; unsigned long flags;
...@@ -1295,7 +1276,7 @@ static int rc_tiocmset(struct tty_struct *tty, struct file *file, ...@@ -1295,7 +1276,7 @@ static int rc_tiocmset(struct tty_struct *tty, struct file *file,
return 0; return 0;
} }
static inline void rc_send_break(struct riscom_port * port, unsigned long length) static void rc_send_break(struct riscom_port *port, unsigned long length)
{ {
struct riscom_board *bp = port_Board(port); struct riscom_board *bp = port_Board(port);
unsigned long flags; unsigned long flags;
...@@ -1315,8 +1296,8 @@ static inline void rc_send_break(struct riscom_port * port, unsigned long length ...@@ -1315,8 +1296,8 @@ static inline void rc_send_break(struct riscom_port * port, unsigned long length
spin_unlock_irqrestore(&riscom_lock, flags); spin_unlock_irqrestore(&riscom_lock, flags);
} }
static inline int rc_set_serial_info(struct riscom_port * port, static int rc_set_serial_info(struct riscom_port *port,
struct serial_struct __user * newinfo) struct serial_struct __user *newinfo)
{ {
struct serial_struct tmp; struct serial_struct tmp;
struct riscom_board *bp = port_Board(port); struct riscom_board *bp = port_Board(port);
...@@ -1363,7 +1344,7 @@ static inline int rc_set_serial_info(struct riscom_port * port, ...@@ -1363,7 +1344,7 @@ static inline int rc_set_serial_info(struct riscom_port * port,
return 0; return 0;
} }
static inline int rc_get_serial_info(struct riscom_port * port, static int rc_get_serial_info(struct riscom_port *port,
struct serial_struct __user *retinfo) struct serial_struct __user *retinfo)
{ {
struct serial_struct tmp; struct serial_struct tmp;
...@@ -1382,9 +1363,8 @@ static inline int rc_get_serial_info(struct riscom_port * port, ...@@ -1382,9 +1363,8 @@ static inline int rc_get_serial_info(struct riscom_port * port,
return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0; return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
} }
static int rc_ioctl(struct tty_struct * tty, struct file * filp, static int rc_ioctl(struct tty_struct *tty, struct file *filp,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct riscom_port *port = (struct riscom_port *)tty->driver_data; struct riscom_port *port = (struct riscom_port *)tty->driver_data;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
...@@ -1425,7 +1405,7 @@ static int rc_ioctl(struct tty_struct * tty, struct file * filp, ...@@ -1425,7 +1405,7 @@ static int rc_ioctl(struct tty_struct * tty, struct file * filp,
return retval; return retval;
} }
static void rc_throttle(struct tty_struct * tty) static void rc_throttle(struct tty_struct *tty)
{ {
struct riscom_port *port = (struct riscom_port *)tty->driver_data; struct riscom_port *port = (struct riscom_port *)tty->driver_data;
struct riscom_board *bp; struct riscom_board *bp;
...@@ -1433,11 +1413,9 @@ static void rc_throttle(struct tty_struct * tty) ...@@ -1433,11 +1413,9 @@ static void rc_throttle(struct tty_struct * tty)
if (rc_paranoia_check(port, tty->name, "rc_throttle")) if (rc_paranoia_check(port, tty->name, "rc_throttle"))
return; return;
bp = port_Board(port); bp = port_Board(port);
spin_lock_irqsave(&riscom_lock, flags); spin_lock_irqsave(&riscom_lock, flags);
port->MSVR &= ~MSVR_RTS; port->MSVR &= ~MSVR_RTS;
rc_out(bp, CD180_CAR, port_No(port)); rc_out(bp, CD180_CAR, port_No(port));
if (I_IXOFF(tty)) { if (I_IXOFF(tty)) {
...@@ -1446,11 +1424,10 @@ static void rc_throttle(struct tty_struct * tty) ...@@ -1446,11 +1424,10 @@ static void rc_throttle(struct tty_struct * tty)
rc_wait_CCR(bp); rc_wait_CCR(bp);
} }
rc_out(bp, CD180_MSVR, port->MSVR); rc_out(bp, CD180_MSVR, port->MSVR);
spin_unlock_irqrestore(&riscom_lock, flags); spin_unlock_irqrestore(&riscom_lock, flags);
} }
static void rc_unthrottle(struct tty_struct * tty) static void rc_unthrottle(struct tty_struct *tty)
{ {
struct riscom_port *port = (struct riscom_port *)tty->driver_data; struct riscom_port *port = (struct riscom_port *)tty->driver_data;
struct riscom_board *bp; struct riscom_board *bp;
...@@ -1458,11 +1435,9 @@ static void rc_unthrottle(struct tty_struct * tty) ...@@ -1458,11 +1435,9 @@ static void rc_unthrottle(struct tty_struct * tty)
if (rc_paranoia_check(port, tty->name, "rc_unthrottle")) if (rc_paranoia_check(port, tty->name, "rc_unthrottle"))
return; return;
bp = port_Board(port); bp = port_Board(port);
spin_lock_irqsave(&riscom_lock, flags); spin_lock_irqsave(&riscom_lock, flags);
port->MSVR |= MSVR_RTS; port->MSVR |= MSVR_RTS;
rc_out(bp, CD180_CAR, port_No(port)); rc_out(bp, CD180_CAR, port_No(port));
if (I_IXOFF(tty)) { if (I_IXOFF(tty)) {
...@@ -1471,11 +1446,10 @@ static void rc_unthrottle(struct tty_struct * tty) ...@@ -1471,11 +1446,10 @@ static void rc_unthrottle(struct tty_struct * tty)
rc_wait_CCR(bp); rc_wait_CCR(bp);
} }
rc_out(bp, CD180_MSVR, port->MSVR); rc_out(bp, CD180_MSVR, port->MSVR);
spin_unlock_irqrestore(&riscom_lock, flags); spin_unlock_irqrestore(&riscom_lock, flags);
} }
static void rc_stop(struct tty_struct * tty) static void rc_stop(struct tty_struct *tty)
{ {
struct riscom_port *port = (struct riscom_port *)tty->driver_data; struct riscom_port *port = (struct riscom_port *)tty->driver_data;
struct riscom_board *bp; struct riscom_board *bp;
...@@ -1487,15 +1461,13 @@ static void rc_stop(struct tty_struct * tty) ...@@ -1487,15 +1461,13 @@ static void rc_stop(struct tty_struct * tty)
bp = port_Board(port); bp = port_Board(port);
spin_lock_irqsave(&riscom_lock, flags); spin_lock_irqsave(&riscom_lock, flags);
port->IER &= ~IER_TXRDY; port->IER &= ~IER_TXRDY;
rc_out(bp, CD180_CAR, port_No(port)); rc_out(bp, CD180_CAR, port_No(port));
rc_out(bp, CD180_IER, port->IER); rc_out(bp, CD180_IER, port->IER);
spin_unlock_irqrestore(&riscom_lock, flags); spin_unlock_irqrestore(&riscom_lock, flags);
} }
static void rc_start(struct tty_struct * tty) static void rc_start(struct tty_struct *tty)
{ {
struct riscom_port *port = (struct riscom_port *)tty->driver_data; struct riscom_port *port = (struct riscom_port *)tty->driver_data;
struct riscom_board *bp; struct riscom_board *bp;
...@@ -1513,11 +1485,10 @@ static void rc_start(struct tty_struct * tty) ...@@ -1513,11 +1485,10 @@ static void rc_start(struct tty_struct * tty)
rc_out(bp, CD180_CAR, port_No(port)); rc_out(bp, CD180_CAR, port_No(port));
rc_out(bp, CD180_IER, port->IER); rc_out(bp, CD180_IER, port->IER);
} }
spin_unlock_irqrestore(&riscom_lock, flags); spin_unlock_irqrestore(&riscom_lock, flags);
} }
static void rc_hangup(struct tty_struct * tty) static void rc_hangup(struct tty_struct *tty)
{ {
struct riscom_port *port = (struct riscom_port *)tty->driver_data; struct riscom_port *port = (struct riscom_port *)tty->driver_data;
struct riscom_board *bp; struct riscom_board *bp;
...@@ -1534,7 +1505,8 @@ static void rc_hangup(struct tty_struct * tty) ...@@ -1534,7 +1505,8 @@ static void rc_hangup(struct tty_struct * tty)
wake_up_interruptible(&port->open_wait); wake_up_interruptible(&port->open_wait);
} }
static void rc_set_termios(struct tty_struct * tty, struct ktermios * old_termios) static void rc_set_termios(struct tty_struct *tty,
struct ktermios *old_termios)
{ {
struct riscom_port *port = (struct riscom_port *)tty->driver_data; struct riscom_port *port = (struct riscom_port *)tty->driver_data;
unsigned long flags; unsigned long flags;
...@@ -1542,10 +1514,6 @@ static void rc_set_termios(struct tty_struct * tty, struct ktermios * old_termio ...@@ -1542,10 +1514,6 @@ static void rc_set_termios(struct tty_struct * tty, struct ktermios * old_termio
if (rc_paranoia_check(port, tty->name, "rc_set_termios")) if (rc_paranoia_check(port, tty->name, "rc_set_termios"))
return; return;
if (tty->termios->c_cflag == old_termios->c_cflag &&
tty->termios->c_iflag == old_termios->c_iflag)
return;
spin_lock_irqsave(&riscom_lock, flags); spin_lock_irqsave(&riscom_lock, flags);
rc_change_speed(port_Board(port), port); rc_change_speed(port_Board(port), port);
spin_unlock_irqrestore(&riscom_lock, flags); spin_unlock_irqrestore(&riscom_lock, flags);
...@@ -1598,23 +1566,21 @@ static int __init rc_init_drivers(void) ...@@ -1598,23 +1566,21 @@ static int __init rc_init_drivers(void)
riscom_driver->init_termios.c_ospeed = 9600; riscom_driver->init_termios.c_ospeed = 9600;
riscom_driver->flags = TTY_DRIVER_REAL_RAW; riscom_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(riscom_driver, &riscom_ops); tty_set_operations(riscom_driver, &riscom_ops);
if ((error = tty_register_driver(riscom_driver))) { error = tty_register_driver(riscom_driver);
if (error != 0) {
put_tty_driver(riscom_driver); put_tty_driver(riscom_driver);
printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, " printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, "
"error = %d\n", "error = %d\n", error);
error);
return 1; return 1;
} }
memset(rc_port, 0, sizeof(rc_port)); memset(rc_port, 0, sizeof(rc_port));
for (i = 0; i < RC_NPORT * RC_NBOARD; i++) { for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
rc_port[i].magic = RISCOM8_MAGIC; rc_port[i].magic = RISCOM8_MAGIC;
rc_port[i].close_delay = 50 * HZ/100; rc_port[i].close_delay = 50 * HZ / 100;
rc_port[i].closing_wait = 3000 * HZ/100; rc_port[i].closing_wait = 3000 * HZ / 100;
init_waitqueue_head(&rc_port[i].open_wait); init_waitqueue_head(&rc_port[i].open_wait);
init_waitqueue_head(&rc_port[i].close_wait); init_waitqueue_head(&rc_port[i].close_wait);
} }
return 0; return 0;
} }
...@@ -1675,7 +1641,6 @@ static int __init riscom8_init(void) ...@@ -1675,7 +1641,6 @@ static int __init riscom8_init(void)
for (i = 0; i < RC_NBOARD; i++) for (i = 0; i < RC_NBOARD; i++)
if (rc_board[i].base && !rc_probe(&rc_board[i])) if (rc_board[i].base && !rc_probe(&rc_board[i]))
found++; found++;
if (!found) { if (!found) {
rc_release_drivers(); rc_release_drivers();
printk(no_boards_msg); printk(no_boards_msg);
...@@ -1702,13 +1667,13 @@ MODULE_LICENSE("GPL"); ...@@ -1702,13 +1667,13 @@ MODULE_LICENSE("GPL");
* by specifying "iobase=0xXXX iobase1=0xXXX ..." as insmod parameter. * by specifying "iobase=0xXXX iobase1=0xXXX ..." as insmod parameter.
* *
*/ */
static int __init riscom8_init_module (void) static int __init riscom8_init_module(void)
{ {
#ifdef MODULE #ifdef MODULE
int i; int i;
if (iobase || iobase1 || iobase2 || iobase3) { if (iobase || iobase1 || iobase2 || iobase3) {
for(i = 0; i < RC_NBOARD; i++) for (i = 0; i < RC_NBOARD; i++)
rc_board[i].base = 0; rc_board[i].base = 0;
} }
...@@ -1725,7 +1690,7 @@ static int __init riscom8_init_module (void) ...@@ -1725,7 +1690,7 @@ static int __init riscom8_init_module (void)
return riscom8_init(); return riscom8_init();
} }
static void __exit riscom8_exit_module (void) static void __exit riscom8_exit_module(void)
{ {
int i; int i;
...@@ -1738,4 +1703,3 @@ static void __exit riscom8_exit_module (void) ...@@ -1738,4 +1703,3 @@ static void __exit riscom8_exit_module (void)
module_init(riscom8_init_module); module_init(riscom8_init_module);
module_exit(riscom8_exit_module); module_exit(riscom8_exit_module);
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