2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-18 18:23:53 +08:00

riscom8: coding style

Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Alan Cox 2008-04-30 00:54:15 -07:00 committed by Linus Torvalds
parent 8e8bcf16c2
commit 9492e13516

View File

@ -33,7 +33,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>
@ -49,7 +49,7 @@
#include <linux/tty_flip.h>
#include <linux/spinlock.h>
#include <asm/uaccess.h>
#include <linux/uaccess.h>
#include "riscom8.h"
#include "riscom8_reg.h"
@ -58,7 +58,7 @@
#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,
* if you are REALLY sure that your board is correct one.
*/
@ -112,7 +112,7 @@ static unsigned short 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)
{
#ifdef RISCOM_PARANOIA_CHECK
@ -158,7 +158,8 @@ static inline struct riscom_board * port_Board(struct riscom_port const * port)
}
/* 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));
}
@ -171,7 +172,7 @@ static inline void rc_out(struct riscom_board const * bp, unsigned short reg,
}
/* 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;
@ -187,7 +188,7 @@ static inline void rc_wait_CCR(struct riscom_board const * bp)
* 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;
@ -205,7 +206,7 @@ out_release:
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;
@ -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_GICR, 0); /* Clear all bits */
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_PILR3, RC_ACK_RINT); /* Prio for receiver intr */
rc_out(bp, CD180_PILR2, RC_ACK_TINT); /* Prio for tx intr */
rc_out(bp, CD180_PILR3, RC_ACK_RINT); /* Prio for rx intr */
/* Setting up prescaler. We need 4 ticks per 1 ms */
rc_out(bp, CD180_PPRH, (RC_OSCFREQ/(1000000/RISCOM_TPS)) >> 8);
@ -312,7 +313,7 @@ out_release:
*
*/
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 channel;
@ -321,23 +322,23 @@ static inline struct riscom_port * rc_get_port(struct riscom_board const * bp,
channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF;
if (channel < CD180_NCH) {
port = &rc_port[board_No(bp) * RC_NPORT + channel];
if (port->flags & ASYNC_INITIALIZED) {
if (port->flags & ASYNC_INITIALIZED)
return port;
}
}
printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n",
board_No(bp), what, channel);
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 tty_struct *tty;
unsigned char status;
unsigned char ch, flag;
if (!(port = rc_get_port(bp, "Receive")))
port = rc_get_port(bp, "Receive");
if (port == NULL)
return;
tty = port->tty;
@ -351,9 +352,8 @@ static inline void rc_receive_exc(struct riscom_board const * bp)
status = rc_in(bp, CD180_RCSR) & port->mark_mask;
#endif
ch = rc_in(bp, CD180_RDR);
if (!status) {
if (!status)
return;
}
if (status & RCSR_TOUT) {
printk(KERN_WARNING "rc%d: port %d: Receiver timeout. "
"Hardware problems ?\n",
@ -375,7 +375,6 @@ static inline void rc_receive_exc(struct riscom_board const * bp)
else if (status & RCSR_OE)
flag = TTY_OVERRUN;
else
flag = TTY_NORMAL;
@ -383,13 +382,14 @@ static inline void rc_receive_exc(struct riscom_board const * bp)
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 tty_struct *tty;
unsigned char count;
if (!(port = rc_get_port(bp, "Receive")))
port = rc_get_port(bp, "Receive");
if (port == NULL)
return;
tty = port->tty;
@ -412,14 +412,14 @@ static inline void rc_receive(struct riscom_board const * bp)
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 tty_struct *tty;
unsigned char count;
if (!(port = rc_get_port(bp, "Transmit")))
port = rc_get_port(bp, "Transmit");
if (port == NULL)
return;
tty = port->tty;
@ -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_DELAY);
rc_out(bp, CD180_TDR, count);
if (!(port->break_length -= count))
port->break_length -= count;
if (port->break_length == 0)
port->break_length--;
} else {
rc_out(bp, CD180_TDR, CD180_C_ESC);
@ -481,13 +482,14 @@ static inline void rc_transmit(struct riscom_board const * bp)
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 tty_struct *tty;
unsigned char mcr;
if (!(port = rc_get_port(bp, "Modem")))
port = rc_get_port(bp, "Modem");
if (port == NULL)
return;
tty = port->tty;
@ -550,10 +552,8 @@ static irqreturn_t rc_interrupt(int dummy, void * dev_id)
if (status & RC_BSR_TOUT)
printk(KERN_WARNING "rc%d: Got timeout. Hardware "
"error?\n", board_No(bp));
else if (status & RC_BSR_RINT) {
ack = rc_in(bp, RC_ACK_RINT);
if (ack == (RC_ID | GIVR_IT_RCV))
rc_receive(bp);
else if (ack == (RC_ID | GIVR_IT_REXC))
@ -562,29 +562,23 @@ static irqreturn_t rc_interrupt(int dummy, void * dev_id)
printk(KERN_WARNING "rc%d: Bad receive ack "
"0x%02x.\n",
board_No(bp), ack);
} else if (status & RC_BSR_TINT) {
ack = rc_in(bp, RC_ACK_TINT);
if (ack == (RC_ID | GIVR_IT_TX))
rc_transmit(bp);
else
printk(KERN_WARNING "rc%d: Bad transmit ack "
"0x%02x.\n",
board_No(bp), ack);
} else /* if (status & RC_BSR_MINT) */ {
ack = rc_in(bp, RC_ACK_MINT);
if (ack == (RC_ID | GIVR_IT_MODEM))
rc_check_modem(bp);
else
printk(KERN_WARNING "rc%d: Bad modem ack "
"0x%02x.\n",
board_No(bp), ack);
}
rc_out(bp, CD180_EOIR, 0); /* Mark end of interrupt */
rc_out(bp, RC_CTOUT, 0); /* Clear timeout flag */
}
@ -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)
{
struct tty_struct *tty;
struct tty_struct *tty = port->tty;
unsigned long baud;
long tmp;
unsigned char cor1 = 0, cor3 = 0;
unsigned char mcor1 = 0, mcor2 = 0;
if (!(tty = port->tty) || !tty->termios)
if (tty == NULL || tty->termios == NULL)
return;
port->IER = 0;
@ -706,7 +700,6 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
cor1 |= COR1_8BITS;
break;
}
if (C_CSTOPB(tty))
cor1 |= COR1_2SB;
@ -738,7 +731,8 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
port->IER |= IER_DSR | IER_CTS;
mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
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
port->COR2 |= COR2_CTSAE;
#endif
@ -797,26 +791,20 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
if (!port->xmit_buf) {
/* We may sleep in get_zeroed_page() */
unsigned long tmp;
if (!(tmp = get_zeroed_page(GFP_KERNEL)))
unsigned long tmp = get_zeroed_page(GFP_KERNEL);
if (tmp == 0)
return -ENOMEM;
if (port->xmit_buf) {
if (port->xmit_buf)
free_page(tmp);
return -ERESTARTSYS;
}
else
port->xmit_buf = (unsigned char *) tmp;
}
spin_lock_irqsave(&riscom_lock, flags);
if (port->tty)
clear_bit(TTY_IO_ERROR, &port->tty->flags);
if (port->count == 1)
bp->count++;
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
rc_change_speed(bp, port);
port->flags |= ASYNC_INITIALIZED;
@ -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 [ ",
board_No(bp), port_No(port));
for (i = 0; i < 10; i++) {
for (i = 0; i < 10; i++)
printk("%ld ", port->hits[i]);
}
printk("].\n");
}
#endif
@ -854,7 +841,9 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
port->xmit_buf = NULL;
}
if (!(tty = port->tty) || C_HUPCL(tty)) {
tty = port->tty;
if (tty == NULL || C_HUPCL(tty)) {
/* Drop DTR */
bp->DTR |= (1u << port_No(port));
rc_out(bp, RC_DTR, bp->DTR);
@ -879,7 +868,6 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
board_No(bp), bp->count);
bp->count = 0;
}
/*
* If this is the last opened port on the board
* shutdown whole board
@ -888,7 +876,6 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
rc_shutdown_board(bp);
}
static int block_til_ready(struct tty_struct *tty, struct file *filp,
struct riscom_port *port)
{
@ -999,20 +986,18 @@ static int rc_open(struct tty_struct * tty, struct file * filp)
if (rc_paranoia_check(port, tty->name, "rc_open"))
return -ENODEV;
if ((error = rc_setup_board(bp)))
error = rc_setup_board(bp);
if (error)
return error;
port->count++;
tty->driver_data = port;
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;
if ((error = block_til_ready(tty, filp, port)))
return error;
return 0;
}
static void rc_flush_buffer(struct tty_struct *tty)
@ -1024,15 +1009,12 @@ static void rc_flush_buffer(struct tty_struct *tty)
return;
spin_lock_irqsave(&riscom_lock, flags);
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
spin_unlock_irqrestore(&riscom_lock, flags);
tty_wakeup(tty);
}
static void rc_close(struct tty_struct *tty, struct file *filp)
{
struct riscom_port *port = (struct riscom_port *) tty->driver_data;
@ -1102,9 +1084,8 @@ static void rc_close(struct tty_struct * tty, struct file * filp)
tty->closing = 0;
port->tty = NULL;
if (port->blocked_open) {
if (port->close_delay) {
if (port->close_delay)
msleep_interruptible(jiffies_to_msecs(port->close_delay));
}
wake_up_interruptible(&port->open_wait);
}
port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
@ -1295,7 +1276,7 @@ static int rc_tiocmset(struct tty_struct *tty, struct file *file,
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);
unsigned long flags;
@ -1315,7 +1296,7 @@ static inline void rc_send_break(struct riscom_port * port, unsigned long length
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 tmp;
@ -1363,7 +1344,7 @@ static inline int rc_set_serial_info(struct riscom_port * port,
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 tmp;
@ -1384,7 +1365,6 @@ static inline int rc_get_serial_info(struct riscom_port * port,
static int rc_ioctl(struct tty_struct *tty, struct file *filp,
unsigned int cmd, unsigned long arg)
{
struct riscom_port *port = (struct riscom_port *)tty->driver_data;
void __user *argp = (void __user *)arg;
@ -1433,11 +1413,9 @@ static void rc_throttle(struct tty_struct * tty)
if (rc_paranoia_check(port, tty->name, "rc_throttle"))
return;
bp = port_Board(port);
spin_lock_irqsave(&riscom_lock, flags);
port->MSVR &= ~MSVR_RTS;
rc_out(bp, CD180_CAR, port_No(port));
if (I_IXOFF(tty)) {
@ -1446,7 +1424,6 @@ static void rc_throttle(struct tty_struct * tty)
rc_wait_CCR(bp);
}
rc_out(bp, CD180_MSVR, port->MSVR);
spin_unlock_irqrestore(&riscom_lock, flags);
}
@ -1458,11 +1435,9 @@ static void rc_unthrottle(struct tty_struct * tty)
if (rc_paranoia_check(port, tty->name, "rc_unthrottle"))
return;
bp = port_Board(port);
spin_lock_irqsave(&riscom_lock, flags);
port->MSVR |= MSVR_RTS;
rc_out(bp, CD180_CAR, port_No(port));
if (I_IXOFF(tty)) {
@ -1471,7 +1446,6 @@ static void rc_unthrottle(struct tty_struct * tty)
rc_wait_CCR(bp);
}
rc_out(bp, CD180_MSVR, port->MSVR);
spin_unlock_irqrestore(&riscom_lock, flags);
}
@ -1487,11 +1461,9 @@ static void rc_stop(struct tty_struct * tty)
bp = port_Board(port);
spin_lock_irqsave(&riscom_lock, flags);
port->IER &= ~IER_TXRDY;
rc_out(bp, CD180_CAR, port_No(port));
rc_out(bp, CD180_IER, port->IER);
spin_unlock_irqrestore(&riscom_lock, flags);
}
@ -1513,7 +1485,6 @@ static void rc_start(struct tty_struct * tty)
rc_out(bp, CD180_CAR, port_No(port));
rc_out(bp, CD180_IER, port->IER);
}
spin_unlock_irqrestore(&riscom_lock, flags);
}
@ -1534,7 +1505,8 @@ static void rc_hangup(struct tty_struct * tty)
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;
unsigned long flags;
@ -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"))
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);
rc_change_speed(port_Board(port), port);
spin_unlock_irqrestore(&riscom_lock, flags);
@ -1598,14 +1566,13 @@ static int __init rc_init_drivers(void)
riscom_driver->init_termios.c_ospeed = 9600;
riscom_driver->flags = TTY_DRIVER_REAL_RAW;
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);
printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, "
"error = %d\n",
error);
"error = %d\n", error);
return 1;
}
memset(rc_port, 0, sizeof(rc_port));
for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
rc_port[i].magic = RISCOM8_MAGIC;
@ -1614,7 +1581,6 @@ static int __init rc_init_drivers(void)
init_waitqueue_head(&rc_port[i].open_wait);
init_waitqueue_head(&rc_port[i].close_wait);
}
return 0;
}
@ -1675,7 +1641,6 @@ static int __init riscom8_init(void)
for (i = 0; i < RC_NBOARD; i++)
if (rc_board[i].base && !rc_probe(&rc_board[i]))
found++;
if (!found) {
rc_release_drivers();
printk(no_boards_msg);
@ -1738,4 +1703,3 @@ static void __exit riscom8_exit_module (void)
module_init(riscom8_init_module);
module_exit(riscom8_exit_module);