提交 44bafdf3 编写于 作者: J Jiri Slaby 提交者: Linus Torvalds

[PATCH] Char: serial167, cleanup

serial167, cleanup

- Lindent the code
- remove 3 pointers from paranoia_check
Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 30a063a9
......@@ -112,11 +112,12 @@ u_char initial_console_speed;
/* This is the per-port data structure */
struct cyclades_port cy_port[] = {
/* CARD# */
{-1 }, /* ttyS0 */
{-1 }, /* ttyS1 */
{-1 }, /* ttyS2 */
{-1 }, /* ttyS3 */
{-1}, /* ttyS0 */
{-1}, /* ttyS1 */
{-1}, /* ttyS2 */
{-1}, /* ttyS3 */
};
#define NR_PORTS ARRAY_SIZE(cy_port)
/*
......@@ -129,19 +130,22 @@ struct cyclades_port cy_port[] = {
*/
static int baud_table[] = {
0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800,115200,150000,
0};
1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 150000,
0
};
#if 0
static char baud_co[] = { /* 25 MHz clock option table */
/* value => 00 01 02 03 04 */
/* divide by 8 32 128 512 2048 */
0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02,
0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static char baud_bpr[] = { /* 25 MHz baud rate period table */
0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3,
0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15};
0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15
};
#endif
/* I think 166 brd clocks 2401 at 20MHz.... */
......@@ -149,21 +153,22 @@ static char baud_bpr[] = { /* 25 MHz baud rate period table */
/* These values are written directly to tcor, and >> 5 for writing to rcor */
static u_char baud_co[] = { /* 20 MHz clock option table */
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x40,
0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* These values written directly to tbpr/rbpr */
static u_char baud_bpr[] = { /* 20 MHz baud rate period table */
0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0xc0, 0x81, 0x40, 0x81,
0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10};
0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10
};
static u_char baud_cor4[] = { /* receive threshold */
0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07};
0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07
};
static void shutdown(struct cyclades_port *);
static int startup (struct cyclades_port *);
static int startup(struct cyclades_port *);
static void cy_throttle(struct tty_struct *);
static void cy_unthrottle(struct tty_struct *);
static void config_setup(struct cyclades_port *);
......@@ -174,7 +179,7 @@ static void show_status(int);
#ifdef CONFIG_REMOTE_DEBUG
static void debug_setup(void);
void queueDebugChar (int c);
void queueDebugChar(int c);
int getDebugChar(void);
#define DEBUG_PORT 1
......@@ -196,7 +201,7 @@ debugq debugiq;
* delay, but this wild guess will do for now.
*/
void my_udelay (long us)
void my_udelay(long us)
{
u_char x;
volatile u_char *p = &x;
......@@ -207,31 +212,26 @@ void my_udelay (long us)
x |= *p;
}
static inline int
serial_paranoia_check(struct cyclades_port *info, char *name,
static inline int serial_paranoia_check(struct cyclades_port *info, char *name,
const char *routine)
{
#ifdef SERIAL_PARANOIA_CHECK
static const char *badmagic =
"Warning: bad magic number for serial struct (%s) in %s\n";
static const char *badinfo =
"Warning: null cyclades_port for (%s) in %s\n";
static const char *badrange =
"Warning: cyclades_port out of range for (%s) in %s\n";
if (!info) {
printk(badinfo, name, routine);
printk("Warning: null cyclades_port for (%s) in %s\n", name,
routine);
return 1;
}
if( (long)info < (long)(&cy_port[0])
|| (long)(&cy_port[NR_PORTS]) < (long)info ){
printk(badrange, name, routine);
if ((long)info < (long)(&cy_port[0])
|| (long)(&cy_port[NR_PORTS]) < (long)info) {
printk("Warning: cyclades_port out of range for (%s) in %s\n",
name, routine);
return 1;
}
if (info->magic != CYCLADES_MAGIC) {
printk(badmagic, name, routine);
printk("Warning: bad magic number for serial struct (%s) in "
"%s\n", name, routine);
return 1;
}
#endif
......@@ -242,27 +242,43 @@ serial_paranoia_check(struct cyclades_port *info, char *name,
/* The following diagnostic routines allow the driver to spew
information on the screen, even (especially!) during interrupts.
*/
void
SP(char *data){
void SP(char *data)
{
unsigned long flags;
local_irq_save(flags);
console_print(data);
local_irq_restore(flags);
}
char scrn[2];
void
CP(char data){
void CP(char data)
{
unsigned long flags;
local_irq_save(flags);
scrn[0] = data;
console_print(scrn);
local_irq_restore(flags);
}/* CP */
} /* CP */
void CP1(int data) { (data<10)? CP(data+'0'): CP(data+'A'-10); }/* CP1 */
void CP2(int data) { CP1((data>>4) & 0x0f); CP1( data & 0x0f); }/* CP2 */
void CP4(int data) { CP2((data>>8) & 0xff); CP2(data & 0xff); }/* CP4 */
void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */
void CP1(int data)
{
(data < 10) ? CP(data + '0') : CP(data + 'A' - 10);
} /* CP1 */
void CP2(int data)
{
CP1((data >> 4) & 0x0f);
CP1(data & 0x0f);
} /* CP2 */
void CP4(int data)
{
CP2((data >> 8) & 0xff);
CP2(data & 0xff);
} /* CP4 */
void CP8(long data)
{
CP4((data >> 16) & 0xffff);
CP4(data & 0xffff);
} /* CP8 */
#endif
/* This routine waits up to 1000 micro-seconds for the previous
......@@ -270,23 +286,22 @@ void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */
new command. An error is returned if the previous command
didn't finish within the time limit.
*/
u_short
write_cy_cmd(volatile u_char *base_addr, u_char cmd)
u_short write_cy_cmd(volatile u_char * base_addr, u_char cmd)
{
unsigned long flags;
volatile int i;
local_irq_save(flags);
/* Check to see that the previous command has completed */
for(i = 0 ; i < 100 ; i++){
if (base_addr[CyCCR] == 0){
for (i = 0; i < 100; i++) {
if (base_addr[CyCCR] == 0) {
break;
}
my_udelay(10L);
}
/* if the CCR never cleared, the previous command
didn't finish within the "reasonable time" */
if ( i == 10 ) {
if (i == 10) {
local_irq_restore(flags);
return (-1);
}
......@@ -294,15 +309,13 @@ write_cy_cmd(volatile u_char *base_addr, u_char cmd)
/* Issue the new command */
base_addr[CyCCR] = cmd;
local_irq_restore(flags);
return(0);
return (0);
} /* write_cy_cmd */
/* cy_start and cy_stop provide software output flow control as a
function of XON/XOFF, software CTS, and other such stuff. */
static void
cy_stop(struct tty_struct *tty)
static void cy_stop(struct tty_struct *tty)
{
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
......@@ -319,15 +332,12 @@ cy_stop(struct tty_struct *tty)
channel = info->line;
local_irq_save(flags);
base_addr[CyCAR] = (u_char)(channel); /* index channel */
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
base_addr[CyCAR] = (u_char) (channel); /* index channel */
base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
local_irq_restore(flags);
return;
} /* cy_stop */
static void
cy_start(struct tty_struct *tty)
static void cy_start(struct tty_struct *tty)
{
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
......@@ -344,34 +354,28 @@ cy_start(struct tty_struct *tty)
channel = info->line;
local_irq_save(flags);
base_addr[CyCAR] = (u_char)(channel);
base_addr[CyCAR] = (u_char) (channel);
base_addr[CyIER] |= CyTxMpty;
local_irq_restore(flags);
return;
} /* cy_start */
/*
* This routine is used by the interrupt handler to schedule
* processing in the software interrupt portion of the driver
* (also known as the "bottom half"). This can be called any
* number of times for any channel without harm.
*/
static inline void
cy_sched_event(struct cyclades_port *info, int event)
static inline void cy_sched_event(struct cyclades_port *info, int event)
{
info->event |= 1 << event; /* remember what kind of event and who */
schedule_work(&info->tqueue);
} /* cy_sched_event */
/* The real interrupt service routines are called
whenever the card wants its hand held--chars
received, out buffer empty, modem change, etc.
*/
static irqreturn_t
cd2401_rxerr_interrupt(int irq, void *dev_id)
static irqreturn_t cd2401_rxerr_interrupt(int irq, void *dev_id)
{
struct tty_struct *tty;
struct cyclades_port *info;
......@@ -381,7 +385,7 @@ cd2401_rxerr_interrupt(int irq, void *dev_id)
char data;
/* determine the channel and change to that context */
channel = (u_short ) (base_addr[CyLICR] >> 2);
channel = (u_short) (base_addr[CyLICR] >> 2);
info = &cy_port[channel];
info->last_active = jiffies;
......@@ -400,48 +404,54 @@ cd2401_rxerr_interrupt(int irq, void *dev_id)
data = 0;
/* if there is nowhere to put the data, discard it */
if(info->tty == 0) {
if (info->tty == 0) {
base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
return IRQ_HANDLED;
}
else { /* there is an open port for this data */
} else { /* there is an open port for this data */
tty = info->tty;
if(err & info->ignore_status_mask){
if (err & info->ignore_status_mask) {
base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
return IRQ_HANDLED;
}
if (tty_buffer_request_room(tty, 1) != 0){
if (err & info->read_status_mask){
if(err & CyBREAK){
tty_insert_flip_char(tty, data, TTY_BREAK);
if (info->flags & ASYNC_SAK){
if (tty_buffer_request_room(tty, 1) != 0) {
if (err & info->read_status_mask) {
if (err & CyBREAK) {
tty_insert_flip_char(tty, data,
TTY_BREAK);
if (info->flags & ASYNC_SAK) {
do_SAK(tty);
}
}else if(err & CyFRAME){
tty_insert_flip_char(tty, data, TTY_FRAME);
}else if(err & CyPARITY){
tty_insert_flip_char(tty, data, TTY_PARITY);
}else if(err & CyOVERRUN){
tty_insert_flip_char(tty, 0, TTY_OVERRUN);
} else if (err & CyFRAME) {
tty_insert_flip_char(tty, data,
TTY_FRAME);
} else if (err & CyPARITY) {
tty_insert_flip_char(tty, data,
TTY_PARITY);
} else if (err & CyOVERRUN) {
tty_insert_flip_char(tty, 0,
TTY_OVERRUN);
/*
If the flip buffer itself is
overflowing, we still loose
the next incoming character.
*/
if (tty_buffer_request_room(tty, 1) != 0){
tty_insert_flip_char(tty, data, TTY_FRAME);
if (tty_buffer_request_room(tty, 1) !=
0) {
tty_insert_flip_char(tty, data,
TTY_FRAME);
}
/* These two conditions may imply */
/* a normal read should be done. */
/* else if(data & CyTIMEOUT) */
/* else if(data & CySPECHAR) */
}else{
tty_insert_flip_char(tty, 0, TTY_NORMAL);
} else {
tty_insert_flip_char(tty, 0,
TTY_NORMAL);
}
}else{
} else {
tty_insert_flip_char(tty, data, TTY_NORMAL);
}
}else{
} else {
/* there was a software buffer overrun
and nothing could be done about it!!! */
}
......@@ -452,8 +462,7 @@ cd2401_rxerr_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
} /* cy_rxerr_interrupt */
static irqreturn_t
cd2401_modem_interrupt(int irq, void *dev_id)
static irqreturn_t cd2401_modem_interrupt(int irq, void *dev_id)
{
struct cyclades_port *info;
volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
......@@ -461,21 +470,20 @@ cd2401_modem_interrupt(int irq, void *dev_id)
int mdm_change;
int mdm_status;
/* determine the channel and change to that context */
channel = (u_short ) (base_addr[CyLICR] >> 2);
channel = (u_short) (base_addr[CyLICR] >> 2);
info = &cy_port[channel];
info->last_active = jiffies;
mdm_change = base_addr[CyMISR];
mdm_status = base_addr[CyMSVR1];
if(info->tty == 0){ /* nowhere to put the data, ignore it */
if (info->tty == 0) { /* nowhere to put the data, ignore it */
;
}else{
if((mdm_change & CyDCD)
&& (info->flags & ASYNC_CHECK_CD)){
if(mdm_status & CyDCD){
} else {
if ((mdm_change & CyDCD)
&& (info->flags & ASYNC_CHECK_CD)) {
if (mdm_status & CyDCD) {
/* CP('!'); */
cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP);
} else {
......@@ -483,32 +491,33 @@ cd2401_modem_interrupt(int irq, void *dev_id)
cy_sched_event(info, Cy_EVENT_HANGUP);
}
}
if((mdm_change & CyCTS)
&& (info->flags & ASYNC_CTS_FLOW)){
if(info->tty->stopped){
if(mdm_status & CyCTS){
if ((mdm_change & CyCTS)
&& (info->flags & ASYNC_CTS_FLOW)) {
if (info->tty->stopped) {
if (mdm_status & CyCTS) {
/* !!! cy_start isn't used because... */
info->tty->stopped = 0;
base_addr[CyIER] |= CyTxMpty;
cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
cy_sched_event(info,
Cy_EVENT_WRITE_WAKEUP);
}
}else{
if(!(mdm_status & CyCTS)){
} else {
if (!(mdm_status & CyCTS)) {
/* !!! cy_stop isn't used because... */
info->tty->stopped = 1;
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
base_addr[CyIER] &=
~(CyTxMpty | CyTxRdy);
}
}
}
if(mdm_status & CyDSR){
if (mdm_status & CyDSR) {
}
}
base_addr[CyMEOIR] = 0;
return IRQ_HANDLED;
} /* cy_modem_interrupt */
static irqreturn_t
cd2401_tx_interrupt(int irq, void *dev_id)
static irqreturn_t cd2401_tx_interrupt(int irq, void *dev_id)
{
struct cyclades_port *info;
volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
......@@ -517,25 +526,25 @@ cd2401_tx_interrupt(int irq, void *dev_id)
int outch;
/* determine the channel and change to that context */
channel = (u_short ) (base_addr[CyLICR] >> 2);
channel = (u_short) (base_addr[CyLICR] >> 2);
#ifdef CONFIG_REMOTE_DEBUG
if (channel == DEBUG_PORT) {
panic ("TxInt on debug port!!!");
panic("TxInt on debug port!!!");
}
#endif
info = &cy_port[channel];
/* validate the port number (as configured and open) */
if( (channel < 0) || (NR_PORTS <= channel) ){
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
if ((channel < 0) || (NR_PORTS <= channel)) {
base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
base_addr[CyTEOIR] = CyNOTRANS;
return IRQ_HANDLED;
}
info->last_active = jiffies;
if(info->tty == 0){
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
if (info->tty == 0) {
base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
if (info->xmit_cnt < WAKEUP_CHARS) {
cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
}
......@@ -546,14 +555,14 @@ cd2401_tx_interrupt(int irq, void *dev_id)
/* load the on-chip space available for outbound data */
saved_cnt = char_count = base_addr[CyTFTC];
if(info->x_char) { /* send special char */
if (info->x_char) { /* send special char */
outch = info->x_char;
base_addr[CyTDR] = outch;
char_count--;
info->x_char = 0;
}
if (info->x_break){
if (info->x_break) {
/* The Cirrus chip requires the "Embedded Transmit
Commands" of start break, delay, and end break
sequences to be sent. The duration of the
......@@ -567,24 +576,24 @@ cd2401_tx_interrupt(int irq, void *dev_id)
base_addr[CyTDR] = 0x81;
base_addr[CyTDR] = 0; /* delay a bit */
base_addr[CyTDR] = 0x82;
base_addr[CyTDR] = info->x_break*200/HZ;
base_addr[CyTDR] = info->x_break * 200 / HZ;
base_addr[CyTDR] = 0; /* terminate break */
base_addr[CyTDR] = 0x83;
char_count -= 7;
info->x_break = 0;
}
while (char_count > 0){
if (!info->xmit_cnt){
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
while (char_count > 0) {
if (!info->xmit_cnt) {
base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
break;
}
if (info->xmit_buf == 0){
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
if (info->xmit_buf == 0) {
base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
break;
}
if (info->tty->stopped || info->tty->hw_stopped){
base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
if (info->tty->stopped || info->tty->hw_stopped) {
base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
break;
}
/* Because the Embedded Transmit Commands have been
......@@ -599,14 +608,14 @@ cd2401_tx_interrupt(int irq, void *dev_id)
needed to send a NULL.
*/
outch = info->xmit_buf[info->xmit_tail];
if( outch ){
if (outch) {
info->xmit_cnt--;
info->xmit_tail = (info->xmit_tail + 1)
& (PAGE_SIZE - 1);
base_addr[CyTDR] = outch;
char_count--;
}else{
if(char_count > 1){
} else {
if (char_count > 1) {
info->xmit_cnt--;
info->xmit_tail = (info->xmit_tail + 1)
& (PAGE_SIZE - 1);
......@@ -614,7 +623,7 @@ cd2401_tx_interrupt(int irq, void *dev_id)
base_addr[CyTDR] = 0;
char_count--;
char_count--;
}else{
} else {
break;
}
}
......@@ -627,8 +636,7 @@ cd2401_tx_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
} /* cy_tx_interrupt */
static irqreturn_t
cd2401_rx_interrupt(int irq, void *dev_id)
static irqreturn_t cd2401_rx_interrupt(int irq, void *dev_id)
{
struct tty_struct *tty;
struct cyclades_port *info;
......@@ -640,7 +648,7 @@ cd2401_rx_interrupt(int irq, void *dev_id)
int len;
/* determine the channel and change to that context */
channel = (u_short ) (base_addr[CyLICR] >> 2);
channel = (u_short) (base_addr[CyLICR] >> 2);
info = &cy_port[channel];
info->last_active = jiffies;
save_cnt = char_count = base_addr[CyRFOC];
......@@ -651,15 +659,14 @@ cd2401_rx_interrupt(int irq, void *dev_id)
data = base_addr[CyRDR];
queueDebugChar(data);
}
}
else
} else
#endif
/* if there is nowhere to put the data, discard it */
if(info->tty == 0){
while(char_count--){
if (info->tty == 0) {
while (char_count--) {
data = base_addr[CyRDR];
}
}else{ /* there is an open port for this data */
} else { /* there is an open port for this data */
tty = info->tty;
/* load # characters available from the chip */
......@@ -671,7 +678,7 @@ cd2401_rx_interrupt(int irq, void *dev_id)
info->mon.char_last = char_count;
#endif
len = tty_buffer_request_room(tty, char_count);
while(len--){
while (len--) {
data = base_addr[CyRDR];
tty_insert_flip_char(tty, data, TTY_NORMAL);
#ifdef CYCLOM_16Y_HACK
......@@ -705,10 +712,10 @@ cd2401_rx_interrupt(int irq, void *dev_id)
* structure) to the bottom half of the driver. Previous kernels
* had to poll every port to see if that port needed servicing.
*/
static void
do_softint(struct work_struct *ugly_api)
static void do_softint(struct work_struct *ugly_api)
{
struct cyclades_port *info = container_of(ugly_api, struct cyclades_port, tqueue);
struct cyclades_port *info =
container_of(ugly_api, struct cyclades_port, tqueue);
struct tty_struct *tty;
tty = info->tty;
......@@ -728,30 +735,28 @@ do_softint(struct work_struct *ugly_api)
}
} /* do_softint */
/* This is called whenever a port becomes active;
interrupts are enabled and DTR & RTS are turned on.
*/
static int
startup(struct cyclades_port * info)
static int startup(struct cyclades_port *info)
{
unsigned long flags;
volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
int channel;
if (info->flags & ASYNC_INITIALIZED){
if (info->flags & ASYNC_INITIALIZED) {
return 0;
}
if (!info->type){
if (info->tty){
if (!info->type) {
if (info->tty) {
set_bit(TTY_IO_ERROR, &info->tty->flags);
}
return 0;
}
if (!info->xmit_buf){
info->xmit_buf = (unsigned char *) get_zeroed_page (GFP_KERNEL);
if (!info->xmit_buf){
if (!info->xmit_buf) {
info->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL);
if (!info->xmit_buf) {
return -ENOMEM;
}
}
......@@ -765,23 +770,24 @@ startup(struct cyclades_port * info)
#endif
local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel;
write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR);
base_addr[CyCAR] = (u_char) channel;
write_cy_cmd(base_addr, CyENB_RCVR | CyENB_XMTR);
base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */
base_addr[CyCAR] = (u_char) channel; /* !!! Is this needed? */
base_addr[CyMSVR1] = CyRTS;
/* CP('S');CP('1'); */
base_addr[CyMSVR2] = CyDTR;
#ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: raising DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif
base_addr[CyIER] |= CyRxData;
info->flags |= ASYNC_INITIALIZED;
if (info->tty){
if (info->tty) {
clear_bit(TTY_IO_ERROR, &info->tty->flags);
}
info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
......@@ -794,11 +800,10 @@ startup(struct cyclades_port * info)
return 0;
} /* startup */
void
start_xmit( struct cyclades_port *info )
void start_xmit(struct cyclades_port *info)
{
unsigned long flags;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel;
channel = info->line;
......@@ -812,14 +817,13 @@ start_xmit( struct cyclades_port *info )
* This routine shuts down a serial port; interrupts are disabled,
* and DTR is dropped if the hangup on close termio flag is on.
*/
static void
shutdown(struct cyclades_port * info)
static void shutdown(struct cyclades_port *info)
{
unsigned long flags;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel;
if (!(info->flags & ASYNC_INITIALIZED)){
if (!(info->flags & ASYNC_INITIALIZED)) {
/* CP('$'); */
return;
}
......@@ -837,26 +841,27 @@ shutdown(struct cyclades_port * info)
or schedule some later processing.
*/
local_irq_save(flags);
if (info->xmit_buf){
free_page((unsigned long) info->xmit_buf);
if (info->xmit_buf) {
free_page((unsigned long)info->xmit_buf);
info->xmit_buf = NULL;
}
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
base_addr[CyMSVR1] = 0;
/* CP('C');CP('1'); */
base_addr[CyMSVR2] = 0;
#ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: dropping DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif
}
write_cy_cmd(base_addr,CyDIS_RCVR);
write_cy_cmd(base_addr, CyDIS_RCVR);
/* it may be appropriate to clear _XMIT at
some later date (after testing)!!! */
if (info->tty){
if (info->tty) {
set_bit(TTY_IO_ERROR, &info->tty->flags);
}
info->flags &= ~ASYNC_INITIALIZED;
......@@ -865,26 +870,24 @@ shutdown(struct cyclades_port * info)
#ifdef SERIAL_DEBUG_OPEN
printk(" done\n");
#endif
return;
} /* shutdown */
/*
* This routine finds or computes the various line characteristics.
*/
static void
config_setup(struct cyclades_port * info)
static void config_setup(struct cyclades_port *info)
{
unsigned long flags;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel;
unsigned cflag;
int i;
unsigned char ti, need_init_chan = 0;
if (!info->tty || !info->tty->termios){
if (!info->tty || !info->tty->termios) {
return;
}
if (info->line == -1){
if (info->line == -1) {
return;
}
cflag = info->tty->termios->c_cflag;
......@@ -903,10 +906,10 @@ config_setup(struct cyclades_port * info)
if (i & CBAUDEX) {
if (i == B57600)
i = 16;
else if(i == B115200)
else if (i == B115200)
i = 18;
#ifdef B78600
else if(i == B78600)
else if (i == B78600)
i = 17;
#endif
else
......@@ -929,10 +932,13 @@ config_setup(struct cyclades_port * info)
info->rbpr = baud_bpr[i]; /* Rx BPR */
info->rco = baud_co[i] >> 5; /* Rx CO */
if (baud_table[i] == 134) {
info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2;
info->timeout =
(info->xmit_fifo_size * HZ * 30 / 269) + 2;
/* get it right for 134.5 baud */
} else if (baud_table[i]) {
info->timeout = (info->xmit_fifo_size*HZ*15/baud_table[i]) + 2;
info->timeout =
(info->xmit_fifo_size * HZ * 15 / baud_table[i]) +
2;
/* this needs to be propagated into the card info */
} else {
info->timeout = 0;
......@@ -946,36 +952,36 @@ config_setup(struct cyclades_port * info)
info->cor7 = 0;
info->cor6 = 0;
info->cor5 = 0;
info->cor4 = (info->default_threshold
? info->default_threshold
: baud_cor4[i]); /* receive threshold */
info->cor4 = (info->default_threshold ? info->default_threshold : baud_cor4[i]); /* receive threshold */
/* Following two lines added 101295, RGH. */
/* It is obviously wrong to access CyCORx, and not info->corx here,
* try and remember to fix it later! */
channel = info->line;
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
if (C_CLOCAL(info->tty)) {
if (base_addr[CyIER] & CyMdmCh)
base_addr[CyIER] &= ~CyMdmCh; /* without modem intr */
/* ignore 1->0 modem transitions */
if (base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD))
base_addr[CyCOR4] &= ~(CyDSR|CyCTS|CyDCD);
if (base_addr[CyCOR4] & (CyDSR | CyCTS | CyDCD))
base_addr[CyCOR4] &= ~(CyDSR | CyCTS | CyDCD);
/* ignore 0->1 modem transitions */
if (base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD))
base_addr[CyCOR5] &= ~(CyDSR|CyCTS|CyDCD);
if (base_addr[CyCOR5] & (CyDSR | CyCTS | CyDCD))
base_addr[CyCOR5] &= ~(CyDSR | CyCTS | CyDCD);
} else {
if ((base_addr[CyIER] & CyMdmCh) != CyMdmCh)
base_addr[CyIER] |= CyMdmCh; /* with modem intr */
/* act on 1->0 modem transitions */
if ((base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD))
base_addr[CyCOR4] |= CyDSR|CyCTS|CyDCD;
if ((base_addr[CyCOR4] & (CyDSR | CyCTS | CyDCD)) !=
(CyDSR | CyCTS | CyDCD))
base_addr[CyCOR4] |= CyDSR | CyCTS | CyDCD;
/* act on 0->1 modem transitions */
if ((base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD))
base_addr[CyCOR5] |= CyDSR|CyCTS|CyDCD;
if ((base_addr[CyCOR5] & (CyDSR | CyCTS | CyDCD)) !=
(CyDSR | CyCTS | CyDCD))
base_addr[CyCOR5] |= CyDSR | CyCTS | CyDCD;
}
info->cor3 = (cflag & CSTOPB) ? Cy_2_STOP : Cy_1_STOP;
info->cor2 = CyETC;
switch(cflag & CSIZE){
switch (cflag & CSIZE) {
case CS5:
info->cor1 = Cy_5_BITS;
break;
......@@ -989,23 +995,23 @@ config_setup(struct cyclades_port * info)
info->cor1 = Cy_8_BITS;
break;
}
if (cflag & PARENB){
if (cflag & PARODD){
if (cflag & PARENB) {
if (cflag & PARODD) {
info->cor1 |= CyPARITY_O;
}else{
} else {
info->cor1 |= CyPARITY_E;
}
}else{
} else {
info->cor1 |= CyPARITY_NONE;
}
/* CTS flow control flag */
#if 0
/* Don't complcate matters for now! RGH 141095 */
if (cflag & CRTSCTS){
if (cflag & CRTSCTS) {
info->flags |= ASYNC_CTS_FLOW;
info->cor2 |= CyCtsAE;
}else{
} else {
info->flags &= ~ASYNC_CTS_FLOW;
info->cor2 &= ~CyCtsAE;
}
......@@ -1028,7 +1034,7 @@ config_setup(struct cyclades_port * info)
channel = info->line;
local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
/* CyCMR set once only in mvme167_init_serial() */
if (base_addr[CyLICR] != channel << 2)
......@@ -1075,9 +1081,9 @@ config_setup(struct cyclades_port * info)
base_addr[CyCOR7] = info->cor7;
if (need_init_chan)
write_cy_cmd(base_addr,CyINIT_CHAN);
write_cy_cmd(base_addr, CyINIT_CHAN);
base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */
base_addr[CyCAR] = (u_char) channel; /* !!! Is this needed? */
/* 2ms default rx timeout */
ti = info->default_timeout ? info->default_timeout : 0x02;
......@@ -1087,23 +1093,25 @@ config_setup(struct cyclades_port * info)
base_addr[CyRTPRH] = 0;
/* Set up RTS here also ????? RGH 141095 */
if(i == 0){ /* baud rate is zero, turn off line */
if (i == 0) { /* baud rate is zero, turn off line */
if ((base_addr[CyMSVR2] & CyDTR) == CyDTR)
base_addr[CyMSVR2] = 0;
#ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: dropping DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif
}else{
} else {
if ((base_addr[CyMSVR2] & CyDTR) != CyDTR)
base_addr[CyMSVR2] = CyDTR;
#ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: raising DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif
}
if (info->tty){
if (info->tty) {
clear_bit(TTY_IO_ERROR, &info->tty->flags);
}
......@@ -1111,9 +1119,7 @@ config_setup(struct cyclades_port * info)
} /* config_setup */
static void
cy_put_char(struct tty_struct *tty, unsigned char ch)
static void cy_put_char(struct tty_struct *tty, unsigned char ch)
{
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
unsigned long flags;
......@@ -1140,13 +1146,11 @@ cy_put_char(struct tty_struct *tty, unsigned char ch)
local_irq_restore(flags);
} /* cy_put_char */
static void
cy_flush_chars(struct tty_struct *tty)
static void cy_flush_chars(struct tty_struct *tty)
{
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
unsigned long flags;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel;
#ifdef SERIAL_DEBUG_IO
......@@ -1168,16 +1172,13 @@ cy_flush_chars(struct tty_struct *tty)
local_irq_restore(flags);
} /* cy_flush_chars */
/* This routine gets called when tty_write has put something into
the write_queue. If the port is not already transmitting stuff,
start it off by enabling interrupts. The interrupt service
routine will then ensure that the characters are sent. If the
port is already active, there is no need to kick it.
*/
static int
cy_write(struct tty_struct * tty,
const unsigned char *buf, int count)
static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
{
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
unsigned long flags;
......@@ -1187,11 +1188,11 @@ cy_write(struct tty_struct * tty,
printk("cy_write %s\n", tty->name); /* */
#endif
if (serial_paranoia_check(info, tty->name, "cy_write")){
if (serial_paranoia_check(info, tty->name, "cy_write")) {
return 0;
}
if (!info->xmit_buf){
if (!info->xmit_buf) {
return 0;
}
......@@ -1205,7 +1206,8 @@ cy_write(struct tty_struct * tty,
}
memcpy(info->xmit_buf + info->xmit_head, buf, c);
info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
info->xmit_head =
(info->xmit_head + c) & (SERIAL_XMIT_SIZE - 1);
info->xmit_cnt += c;
local_irq_restore(flags);
......@@ -1214,17 +1216,13 @@ cy_write(struct tty_struct * tty,
total += c;
}
if (info->xmit_cnt
&& !tty->stopped
&& !tty->hw_stopped ) {
if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) {
start_xmit(info);
}
return total;
} /* cy_write */
static int
cy_write_room(struct tty_struct *tty)
static int cy_write_room(struct tty_struct *tty)
{
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
int ret;
......@@ -1241,9 +1239,7 @@ cy_write_room(struct tty_struct *tty)
return ret;
} /* cy_write_room */
static int
cy_chars_in_buffer(struct tty_struct *tty)
static int cy_chars_in_buffer(struct tty_struct *tty)
{
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
......@@ -1257,9 +1253,7 @@ cy_chars_in_buffer(struct tty_struct *tty)
return info->xmit_cnt;
} /* cy_chars_in_buffer */
static void
cy_flush_buffer(struct tty_struct *tty)
static void cy_flush_buffer(struct tty_struct *tty)
{
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
unsigned long flags;
......@@ -1276,17 +1270,15 @@ cy_flush_buffer(struct tty_struct *tty)
tty_wakeup(tty);
} /* cy_flush_buffer */
/* This routine is called by the upper-layer tty layer to signal
that incoming characters should be throttled or that the
throttle should be released.
*/
static void
cy_throttle(struct tty_struct * tty)
static void cy_throttle(struct tty_struct *tty)
{
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
unsigned long flags;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel;
#ifdef SERIAL_DEBUG_THROTTLE
......@@ -1297,7 +1289,7 @@ cy_throttle(struct tty_struct * tty)
printk("cy_throttle %s\n", tty->name);
#endif
if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){
if (serial_paranoia_check(info, tty->name, "cy_nthrottle")) {
return;
}
......@@ -1309,20 +1301,16 @@ cy_throttle(struct tty_struct * tty)
channel = info->line;
local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
base_addr[CyMSVR1] = 0;
local_irq_restore(flags);
return;
} /* cy_throttle */
static void
cy_unthrottle(struct tty_struct * tty)
static void cy_unthrottle(struct tty_struct *tty)
{
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
unsigned long flags;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel;
#ifdef SERIAL_DEBUG_THROTTLE
......@@ -1333,7 +1321,7 @@ cy_unthrottle(struct tty_struct * tty)
printk("cy_unthrottle %s\n", tty->name);
#endif
if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){
if (serial_paranoia_check(info, tty->name, "cy_nthrottle")) {
return;
}
......@@ -1345,15 +1333,13 @@ cy_unthrottle(struct tty_struct * tty)
channel = info->line;
local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
base_addr[CyMSVR1] = CyRTS;
local_irq_restore(flags);
return;
} /* cy_unthrottle */
static int
get_serial_info(struct cyclades_port * info,
get_serial_info(struct cyclades_port *info,
struct serial_struct __user * retinfo)
{
struct serial_struct tmp;
......@@ -1367,15 +1353,15 @@ get_serial_info(struct cyclades_port * info,
tmp.port = info->line;
tmp.irq = 0;
tmp.flags = info->flags;
tmp.baud_base = 0; /*!!!*/
tmp.baud_base = 0; /*!!! */
tmp.close_delay = info->close_delay;
tmp.custom_divisor = 0; /*!!!*/
tmp.hub6 = 0; /*!!!*/
return copy_to_user(retinfo,&tmp,sizeof(*retinfo)) ? -EFAULT : 0;
tmp.custom_divisor = 0; /*!!! */
tmp.hub6 = 0; /*!!! */
return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
} /* get_serial_info */
static int
set_serial_info(struct cyclades_port * info,
set_serial_info(struct cyclades_port *info,
struct serial_struct __user * new_info)
{
struct serial_struct new_serial;
......@@ -1384,7 +1370,7 @@ set_serial_info(struct cyclades_port * info,
/* CP('s'); */
if (!new_info)
return -EFAULT;
if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
return -EFAULT;
old_info = *info;
......@@ -1398,7 +1384,6 @@ set_serial_info(struct cyclades_port * info,
goto check_and_exit;
}
/*
* OK, past this point, all the error checking has been done.
* At this point, we start making changes.....
......@@ -1408,29 +1393,26 @@ set_serial_info(struct cyclades_port * info,
(new_serial.flags & ASYNC_FLAGS));
info->close_delay = new_serial.close_delay;
check_and_exit:
if (info->flags & ASYNC_INITIALIZED){
if (info->flags & ASYNC_INITIALIZED) {
config_setup(info);
return 0;
}else{
return startup(info);
}
return startup(info);
} /* set_serial_info */
static int
cy_tiocmget(struct tty_struct *tty, struct file *file)
static int cy_tiocmget(struct tty_struct *tty, struct file *file)
{
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
int channel;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
unsigned long flags;
unsigned char status;
channel = info->line;
local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
status = base_addr[CyMSVR1] | base_addr[CyMSVR2];
local_irq_restore(flags);
......@@ -1445,45 +1427,47 @@ static int
cy_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear)
{
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
int channel;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
unsigned long flags;
channel = info->line;
if (set & TIOCM_RTS){
if (set & TIOCM_RTS) {
local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
base_addr[CyMSVR1] = CyRTS;
local_irq_restore(flags);
}
if (set & TIOCM_DTR){
if (set & TIOCM_DTR) {
local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
/* CP('S');CP('2'); */
base_addr[CyMSVR2] = CyDTR;
#ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: raising DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif
local_irq_restore(flags);
}
if (clear & TIOCM_RTS){
if (clear & TIOCM_RTS) {
local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
base_addr[CyMSVR1] = 0;
local_irq_restore(flags);
}
if (clear & TIOCM_DTR){
if (clear & TIOCM_DTR) {
local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
/* CP('C');CP('2'); */
base_addr[CyMSVR2] = 0;
#ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: dropping DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif
local_irq_restore(flags);
}
......@@ -1491,19 +1475,18 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
return 0;
} /* set_modem_info */
static void
send_break( struct cyclades_port * info, int duration)
static void send_break(struct cyclades_port *info, int duration)
{ /* Let the transmit ISR take care of this (since it
requires stuffing characters into the output stream).
*/
info->x_break = duration;
if (!info->xmit_cnt ) {
if (!info->xmit_cnt) {
start_xmit(info);
}
} /* send_break */
static int
get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon)
get_mon_info(struct cyclades_port *info, struct cyclades_monitor __user * mon)
{
if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
......@@ -1515,10 +1498,9 @@ get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon)
return 0;
}
static int
set_threshold(struct cyclades_port * info, unsigned long __user *arg)
static int set_threshold(struct cyclades_port *info, unsigned long __user * arg)
{
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
unsigned long value;
int channel;
......@@ -1533,20 +1515,20 @@ set_threshold(struct cyclades_port * info, unsigned long __user *arg)
}
static int
get_threshold(struct cyclades_port * info, unsigned long __user *value)
get_threshold(struct cyclades_port *info, unsigned long __user * value)
{
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel;
unsigned long tmp;
channel = info->line;
tmp = base_addr[CyCOR4] & CyREC_FIFO;
return put_user(tmp,value);
return put_user(tmp, value);
}
static int
set_default_threshold(struct cyclades_port * info, unsigned long __user *arg)
set_default_threshold(struct cyclades_port *info, unsigned long __user * arg)
{
unsigned long value;
......@@ -1558,15 +1540,14 @@ set_default_threshold(struct cyclades_port * info, unsigned long __user *arg)
}
static int
get_default_threshold(struct cyclades_port * info, unsigned long __user *value)
get_default_threshold(struct cyclades_port *info, unsigned long __user * value)
{
return put_user(info->default_threshold,value);
return put_user(info->default_threshold, value);
}
static int
set_timeout(struct cyclades_port * info, unsigned long __user *arg)
static int set_timeout(struct cyclades_port *info, unsigned long __user * arg)
{
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel;
unsigned long value;
......@@ -1580,38 +1561,36 @@ set_timeout(struct cyclades_port * info, unsigned long __user *arg)
return 0;
}
static int
get_timeout(struct cyclades_port * info, unsigned long __user *value)
static int get_timeout(struct cyclades_port *info, unsigned long __user * value)
{
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel;
unsigned long tmp;
channel = info->line;
tmp = base_addr[CyRTPRL];
return put_user(tmp,value);
return put_user(tmp, value);
}
static int
set_default_timeout(struct cyclades_port * info, unsigned long value)
static int set_default_timeout(struct cyclades_port *info, unsigned long value)
{
info->default_timeout = value & 0xff;
return 0;
}
static int
get_default_timeout(struct cyclades_port * info, unsigned long __user *value)
get_default_timeout(struct cyclades_port *info, unsigned long __user * value)
{
return put_user(info->default_timeout,value);
return put_user(info->default_timeout, value);
}
static int
cy_ioctl(struct tty_struct *tty, struct file * file,
cy_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg)
{
unsigned long val;
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
int ret_val = 0;
void __user *argp = (void __user *)arg;
......@@ -1651,24 +1630,26 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
ret_val = tty_check_change(tty);
if (ret_val)
break;
tty_wait_until_sent(tty,0);
tty_wait_until_sent(tty, 0);
if (!arg)
send_break(info, HZ/4); /* 1/4 second */
send_break(info, HZ / 4); /* 1/4 second */
break;
case TCSBRKP: /* support for POSIX tcsendbreak() */
ret_val = tty_check_change(tty);
if (ret_val)
break;
tty_wait_until_sent(tty,0);
send_break(info, arg ? arg*(HZ/10) : HZ/4);
tty_wait_until_sent(tty, 0);
send_break(info, arg ? arg * (HZ / 10) : HZ / 4);
break;
/* The following commands are incompletely implemented!!! */
case TIOCGSOFTCAR:
ret_val = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) argp);
ret_val =
put_user(C_CLOCAL(tty) ? 1 : 0,
(unsigned long __user *)argp);
break;
case TIOCSSOFTCAR:
ret_val = get_user(val, (unsigned long __user *) argp);
ret_val = get_user(val, (unsigned long __user *)argp);
if (ret_val)
break;
tty->termios->c_cflag =
......@@ -1691,11 +1672,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
return ret_val;
} /* cy_ioctl */
static void
cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios)
static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
{
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
......@@ -1717,23 +1694,18 @@ cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios)
(tty->termios->c_cflag & CLOCAL))
wake_up_interruptible(&info->open_wait);
#endif
return;
} /* cy_set_termios */
static void
cy_close(struct tty_struct * tty, struct file * filp)
static void cy_close(struct tty_struct *tty, struct file *filp)
{
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
/* CP('C'); */
#ifdef SERIAL_DEBUG_OTHER
printk("cy_close %s\n", tty->name);
#endif
if (!info
|| serial_paranoia_check(info, tty->name, "cy_close")){
if (!info || serial_paranoia_check(info, tty->name, "cy_close")) {
return;
}
#ifdef SERIAL_DEBUG_OPEN
......@@ -1753,7 +1725,8 @@ cy_close(struct tty_struct * tty, struct file * filp)
info->count = 1;
}
#ifdef SERIAL_DEBUG_COUNT
printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count - 1);
printk("cyc: %d: decrementing count to %d\n", __LINE__,
info->count - 1);
#endif
if (--info->count < 0) {
printk("cy_close: bad serial port count for ttys%d: %d\n",
......@@ -1776,27 +1749,25 @@ cy_close(struct tty_struct * tty, struct file * filp)
info->tty = NULL;
if (info->blocked_open) {
if (info->close_delay) {
msleep_interruptible(jiffies_to_msecs(info->close_delay));
msleep_interruptible(jiffies_to_msecs
(info->close_delay));
}
wake_up_interruptible(&info->open_wait);
}
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
wake_up_interruptible(&info->close_wait);
#ifdef SERIAL_DEBUG_OTHER
printk("cy_close done\n");
#endif
return;
} /* cy_close */
/*
* cy_hangup() --- called by tty_hangup() when a hangup is signaled.
*/
void
cy_hangup(struct tty_struct *tty)
void cy_hangup(struct tty_struct *tty)
{
struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
#ifdef SERIAL_DEBUG_OTHER
printk("cy_hangup %s\n", tty->name); /* */
......@@ -1818,8 +1789,6 @@ cy_hangup(struct tty_struct *tty)
wake_up_interruptible(&info->open_wait);
} /* cy_hangup */
/*
* ------------------------------------------------------------
* cy_open() and friends
......@@ -1827,14 +1796,14 @@ cy_hangup(struct tty_struct *tty)
*/
static int
block_til_ready(struct tty_struct *tty, struct file * filp,
block_til_ready(struct tty_struct *tty, struct file *filp,
struct cyclades_port *info)
{
DECLARE_WAITQUEUE(wait, current);
unsigned long flags;
int channel;
int retval;
volatile u_char *base_addr = (u_char *)BASE_ADDR;
volatile u_char *base_addr = (u_char *) BASE_ADDR;
/*
* If the device is in the middle of being closed, then block
......@@ -1842,9 +1811,9 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
*/
if (info->flags & ASYNC_CLOSING) {
interruptible_sleep_on(&info->close_wait);
if (info->flags & ASYNC_HUP_NOTIFY){
if (info->flags & ASYNC_HUP_NOTIFY) {
return -EAGAIN;
}else{
} else {
return -ERESTARTSYS;
}
}
......@@ -1869,7 +1838,8 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
add_wait_queue(&info->open_wait, &wait);
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready before block: %s, count = %d\n",
tty->name, info->count);/**/
tty->name, info->count);
/**/
#endif
info->count--;
#ifdef SERIAL_DEBUG_COUNT
......@@ -1881,27 +1851,28 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
while (1) {
local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
base_addr[CyMSVR1] = CyRTS;
/* CP('S');CP('4'); */
base_addr[CyMSVR2] = CyDTR;
#ifdef SERIAL_DEBUG_DTR
printk("cyc: %d: raising DTR\n", __LINE__);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
base_addr[CyMSVR2]);
#endif
local_irq_restore(flags);
set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp)
|| !(info->flags & ASYNC_INITIALIZED) ){
|| !(info->flags & ASYNC_INITIALIZED)) {
if (info->flags & ASYNC_HUP_NOTIFY) {
retval = -EAGAIN;
}else{
} else {
retval = -ERESTARTSYS;
}
break;
}
local_irq_save(flags);
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
/* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */
if (!(info->flags & ASYNC_CLOSING)
&& (C_CLOCAL(tty)
......@@ -1916,22 +1887,25 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
}
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready blocking: %s, count = %d\n",
tty->name, info->count);/**/
tty->name, info->count);
/**/
#endif
schedule();
}
current->state = TASK_RUNNING;
remove_wait_queue(&info->open_wait, &wait);
if (!tty_hung_up_p(filp)){
if (!tty_hung_up_p(filp)) {
info->count++;
#ifdef SERIAL_DEBUG_COUNT
printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count);
printk("cyc: %d: incrementing count to %d\n", __LINE__,
info->count);
#endif
}
info->blocked_open--;
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready after blocking: %s, count = %d\n",
tty->name, info->count);/**/
tty->name, info->count);
/**/
#endif
if (retval)
return retval;
......@@ -1943,29 +1917,29 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
* This routine is called whenever a serial port is opened. It
* performs the serial-specific initialization for the tty structure.
*/
int
cy_open(struct tty_struct *tty, struct file * filp)
int cy_open(struct tty_struct *tty, struct file *filp)
{
struct cyclades_port *info;
int retval, line;
/* CP('O'); */
line = tty->index;
if ((line < 0) || (NR_PORTS <= line)){
if ((line < 0) || (NR_PORTS <= line)) {
return -ENODEV;
}
info = &cy_port[line];
if (info->line < 0){
if (info->line < 0) {
return -ENODEV;
}
#ifdef SERIAL_DEBUG_OTHER
printk("cy_open %s\n", tty->name); /* */
#endif
if (serial_paranoia_check(info, tty->name, "cy_open")){
if (serial_paranoia_check(info, tty->name, "cy_open")) {
return -ENODEV;
}
#ifdef SERIAL_DEBUG_OPEN
printk("cy_open %s, count = %d\n", tty->name, info->count);/**/
printk("cy_open %s, count = %d\n", tty->name, info->count);
/**/
#endif
info->count++;
#ifdef SERIAL_DEBUG_COUNT
......@@ -1978,7 +1952,7 @@ cy_open(struct tty_struct *tty, struct file * filp)
* Start up serial port
*/
retval = startup(info);
if (retval){
if (retval) {
return retval;
}
......@@ -1990,15 +1964,13 @@ cy_open(struct tty_struct *tty, struct file * filp)
#endif
return retval;
}
#ifdef SERIAL_DEBUG_OPEN
printk("cy_open done\n");/**/
printk("cy_open done\n");
/**/
#endif
return 0;
} /* cy_open */
/*
* ---------------------------------------------------------------------
* serial167_init() and friends
......@@ -2012,8 +1984,7 @@ cy_open(struct tty_struct *tty, struct file * filp)
* number, and identifies which options were configured into this
* driver.
*/
static void
show_version(void)
static void show_version(void)
{
printk("MVME166/167 cd2401 driver\n");
} /* show_version */
......@@ -2030,10 +2001,9 @@ show_version(void)
* ... I wonder what I should do if this fails ...
*/
void
mvme167_serial_console_setup(int cflag)
void mvme167_serial_console_setup(int cflag)
{
volatile unsigned char* base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int ch;
u_char spd;
u_char rcor, rbpr, badspeed = 0;
......@@ -2063,7 +2033,7 @@ mvme167_serial_console_setup(int cflag)
/* OK, we have chosen a speed, now reset and reinitialise */
my_udelay(20000L); /* Allow time for any active o/p to complete */
if(base_addr[CyCCR] != 0x00){
if (base_addr[CyCCR] != 0x00) {
local_irq_restore(flags);
/* printk(" chip is never idle (CCR != 0)\n"); */
return;
......@@ -2072,7 +2042,7 @@ mvme167_serial_console_setup(int cflag)
base_addr[CyCCR] = CyCHIP_RESET; /* Reset the chip */
my_udelay(1000L);
if(base_addr[CyGFRCR] == 0x00){
if (base_addr[CyGFRCR] == 0x00) {
local_irq_restore(flags);
/* printk(" chip is not responding (GFRCR stayed 0)\n"); */
return;
......@@ -2095,11 +2065,11 @@ mvme167_serial_console_setup(int cflag)
* the ammount of fiddling we have to do in normal running.
*/
for (ch = 3; ch >= 0 ; ch--) {
base_addr[CyCAR] = (u_char)ch;
for (ch = 3; ch >= 0; ch--) {
base_addr[CyCAR] = (u_char) ch;
base_addr[CyIER] = 0;
base_addr[CyCMR] = CyASYNC;
base_addr[CyLICR] = (u_char)ch << 2;
base_addr[CyLICR] = (u_char) ch << 2;
base_addr[CyLIVR] = 0x5c;
base_addr[CyTCOR] = baud_co[spd];
base_addr[CyTBPR] = baud_bpr[spd];
......@@ -2120,7 +2090,7 @@ mvme167_serial_console_setup(int cflag)
base_addr[CyRTPRH] = 0;
base_addr[CyMSVR1] = 0;
base_addr[CyMSVR2] = 0;
write_cy_cmd(base_addr,CyINIT_CHAN|CyDIS_RCVR|CyDIS_XMTR);
write_cy_cmd(base_addr, CyINIT_CHAN | CyDIS_RCVR | CyDIS_XMTR);
}
/*
......@@ -2130,7 +2100,7 @@ mvme167_serial_console_setup(int cflag)
base_addr[CyMSVR1] = CyRTS;
base_addr[CyMSVR2] = CyDTR;
base_addr[CyIER] = CyRxData;
write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR);
write_cy_cmd(base_addr, CyENB_RCVR | CyENB_XMTR);
local_irq_restore(flags);
......@@ -2138,7 +2108,8 @@ mvme167_serial_console_setup(int cflag)
printk("CD2401 initialised, chip is rev 0x%02x\n", base_addr[CyGFRCR]);
if (badspeed)
printk(" WARNING: Failed to identify line speed, rcor=%02x,rbpr=%02x\n",
printk
(" WARNING: Failed to identify line speed, rcor=%02x,rbpr=%02x\n",
rcor >> 5, rbpr);
} /* serial_console_init */
......@@ -2161,6 +2132,7 @@ static const struct tty_operations cy_ops = {
.tiocmget = cy_tiocmget,
.tiocmset = cy_tiocmset,
};
/* The serial driver boot-time initialization code!
Hardware I/O ports are mapped to character special devices on a
first found, first allocated manner. That is, this code searches
......@@ -2177,8 +2149,7 @@ static const struct tty_operations cy_ops = {
If there are more cards with more ports than have been statically
allocated above, a warning is printed and the extra ports are ignored.
*/
static int __init
serial167_init(void)
static int __init serial167_init(void)
{
struct cyclades_port *info;
int ret = 0;
......@@ -2190,7 +2161,7 @@ serial167_init(void)
struct sigaction sa;
#endif
if (!(mvme16x_config &MVME16x_CONFIG_GOT_CD2401))
if (!(mvme16x_config & MVME16x_CONFIG_GOT_CD2401))
return 0;
cy_serial_driver = alloc_tty_driver(NR_PORTS);
......@@ -2198,7 +2169,7 @@ serial167_init(void)
return -ENOMEM;
#if 0
scrn[1] = '\0';
scrn[1] = '\0';
#endif
show_version();
......@@ -2211,7 +2182,7 @@ scrn[1] = '\0';
serial_console_info = &cy_port[0];
serial_console_cflag = DefSpeed | CS8;
#if 0
serial_console = 64; /*callout_driver.minor_start*/
serial_console = 64; /*callout_driver.minor_start */
#endif
}
......@@ -2242,8 +2213,8 @@ scrn[1] = '\0';
good_ports = 4;
if(port_num < NR_PORTS){
while( good_ports-- && port_num < NR_PORTS){
if (port_num < NR_PORTS) {
while (good_ports-- && port_num < NR_PORTS) {
/*** initialize port ***/
info->magic = CYCLADES_MAGIC;
info->type = PORT_CIRRUS;
......@@ -2252,7 +2223,7 @@ scrn[1] = '\0';
info->flags = STD_COM_FLAGS;
info->tty = NULL;
info->xmit_fifo_size = 12;
info->cor1 = CyPARITY_NONE|Cy_8_BITS;
info->cor1 = CyPARITY_NONE | Cy_8_BITS;
info->cor2 = CyETC;
info->cor3 = Cy_1_STOP;
info->cor4 = 0x08; /* _very_ small receive threshold */
......@@ -2268,7 +2239,8 @@ scrn[1] = '\0';
info->event = 0;
info->count = 0;
#ifdef SERIAL_DEBUG_COUNT
printk("cyc: %d: setting count to 0\n", __LINE__);
printk("cyc: %d: setting count to 0\n",
__LINE__);
#endif
info->blocked_open = 0;
info->default_threshold = 0;
......@@ -2279,22 +2251,25 @@ scrn[1] = '\0';
/* info->session */
/* info->pgrp */
/*** !!!!!!!! this may expose new bugs !!!!!!!!! *********/
info->read_status_mask = CyTIMEOUT| CySPECHAR| CyBREAK
| CyPARITY| CyFRAME| CyOVERRUN;
info->read_status_mask =
CyTIMEOUT | CySPECHAR | CyBREAK | CyPARITY |
CyFRAME | CyOVERRUN;
/* info->timeout */
printk("ttyS%d ", info->line);
port_num++;info++;
if(!(port_num & 7)){
port_num++;
info++;
if (!(port_num & 7)) {
printk("\n ");
}
}
}
printk("\n");
}
while( port_num < NR_PORTS){
while (port_num < NR_PORTS) {
info->line = -1;
port_num++;info++;
port_num++;
info++;
}
#ifdef CONFIG_REMOTE_DEBUG
debug_setup();
......@@ -2344,45 +2319,42 @@ scrn[1] = '\0';
free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt);
cleanup_serial_driver:
if (tty_unregister_driver(cy_serial_driver))
printk(KERN_ERR "Couldn't unregister MVME166/7 serial driver\n");
printk(KERN_ERR
"Couldn't unregister MVME166/7 serial driver\n");
put_tty_driver(cy_serial_driver);
return ret;
} /* serial167_init */
module_init(serial167_init);
#ifdef CYCLOM_SHOW_STATUS
static void
show_status(int line_num)
static void show_status(int line_num)
{
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int channel;
struct cyclades_port * info;
struct cyclades_port *info;
unsigned long flags;
info = &cy_port[line_num];
channel = info->line;
printk(" channel %d\n", channel);/**/
printk(" cy_port\n");
printk(" channel %d\n", channel);
/**/ printk(" cy_port\n");
printk(" card line flags = %d %d %x\n",
info->card, info->line, info->flags);
printk(" *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n",
(long)info->tty, info->read_status_mask,
info->timeout, info->xmit_fifo_size);
printk
(" *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n",
(long)info->tty, info->read_status_mask, info->timeout,
info->xmit_fifo_size);
printk(" cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n",
info->cor1, info->cor2, info->cor3, info->cor4, info->cor5,
info->cor6, info->cor7);
printk(" tbpr,tco,rbpr,rco = %d %d %d %d\n",
info->tbpr, info->tco, info->rbpr, info->rco);
printk(" close_delay event count = %d %d %d\n",
info->close_delay, info->event, info->count);
printk(" x_char blocked_open = %x %x\n",
info->x_char, info->blocked_open);
printk(" open_wait = %lx %lx %lx\n",
(long)info->open_wait);
printk(" tbpr,tco,rbpr,rco = %d %d %d %d\n", info->tbpr, info->tco,
info->rbpr, info->rco);
printk(" close_delay event count = %d %d %d\n", info->close_delay,
info->event, info->count);
printk(" x_char blocked_open = %x %x\n", info->x_char,
info->blocked_open);
printk(" open_wait = %lx %lx %lx\n", (long)info->open_wait);
local_irq_save(flags);
......@@ -2398,7 +2370,7 @@ show_status(int line_num)
printk(" CyMIR %x\n", base_addr[CyMIR]);
printk(" CyTPR %x\n", base_addr[CyTPR]);
base_addr[CyCAR] = (u_char)channel;
base_addr[CyCAR] = (u_char) channel;
/* Virtual Registers */
......@@ -2446,7 +2418,6 @@ show_status(int line_num)
} /* show_status */
#endif
#if 0
/* Dummy routine in mvme16x/config.c for now */
......@@ -2459,23 +2430,27 @@ void console_setup(char *str, int *ints)
int cflag = 0;
/* Sanity check. */
if (ints[0] > 3 || ints[1] > 3) return;
if (ints[0] > 3 || ints[1] > 3)
return;
/* Get baud, bits and parity */
baud = 2400;
bits = 8;
parity = 'n';
if (ints[2]) baud = ints[2];
if (ints[2])
baud = ints[2];
if ((s = strchr(str, ','))) {
do {
s++;
} while(*s >= '0' && *s <= '9');
if (*s) parity = *s++;
if (*s) bits = *s - '0';
} while (*s >= '0' && *s <= '9');
if (*s)
parity = *s++;
if (*s)
bits = *s - '0';
}
/* Now construct a cflag setting. */
switch(baud) {
switch (baud) {
case 1200:
cflag |= B1200;
break;
......@@ -2493,7 +2468,7 @@ void console_setup(char *str, int *ints)
cflag |= B2400;
break;
}
switch(bits) {
switch (bits) {
case 7:
cflag |= CS7;
break;
......@@ -2502,18 +2477,20 @@ void console_setup(char *str, int *ints)
cflag |= CS8;
break;
}
switch(parity) {
case 'o': case 'O':
switch (parity) {
case 'o':
case 'O':
cflag |= PARODD;
break;
case 'e': case 'E':
case 'e':
case 'E':
cflag |= PARENB;
break;
}
serial_console_info = &cy_port[ints[1]];
serial_console_cflag = cflag;
serial_console = ints[1] + 64; /*callout_driver.minor_start*/
serial_console = ints[1] + 64; /*callout_driver.minor_start */
}
#endif
......@@ -2532,9 +2509,10 @@ void console_setup(char *str, int *ints)
* The console must be locked when we get here.
*/
void serial167_console_write(struct console *co, const char *str, unsigned count)
void serial167_console_write(struct console *co, const char *str,
unsigned count)
{
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
unsigned long flags;
volatile u_char sink;
u_char ier;
......@@ -2547,7 +2525,7 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
/* Ensure transmitter is enabled! */
port = 0;
base_addr[CyCAR] = (u_char)port;
base_addr[CyCAR] = (u_char) port;
while (base_addr[CyCCR])
;
base_addr[CyCCR] = CyENB_XMTR;
......@@ -2556,8 +2534,7 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
base_addr[CyIER] = CyTxMpty;
while (1) {
if (pcc2chip[PccSCCTICR] & 0x20)
{
if (pcc2chip[PccSCCTICR] & 0x20) {
/* We have a Tx int. Acknowledge it */
sink = pcc2chip[PccTPIACKR];
if ((base_addr[CyLICR] >> 2) == port) {
......@@ -2571,18 +2548,15 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
str++;
i++;
do_lf = 0;
}
else if (*str == '\n') {
} else if (*str == '\n') {
base_addr[CyTDR] = '\r';
do_lf = 1;
}
else {
} else {
base_addr[CyTDR] = *str++;
i++;
}
base_addr[CyTEOIR] = 0;
}
else
} else
base_addr[CyTEOIR] = CyNOTRANS;
}
}
......@@ -2592,19 +2566,18 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
local_irq_restore(flags);
}
static struct tty_driver *serial167_console_device(struct console *c, int *index)
static struct tty_driver *serial167_console_device(struct console *c,
int *index)
{
*index = c->index;
return cy_serial_driver;
}
static int __init serial167_console_setup(struct console *co, char *options)
{
return 0;
}
static struct console sercons = {
.name = "ttyS",
.write = serial167_console_write,
......@@ -2614,7 +2587,6 @@ static struct console sercons = {
.index = -1,
};
static int __init serial167_console_init(void)
{
if (vme_brdtype == VME_TYPE_MVME166 ||
......@@ -2625,12 +2597,13 @@ static int __init serial167_console_init(void)
}
return 0;
}
console_initcall(serial167_console_init);
#ifdef CONFIG_REMOTE_DEBUG
void putDebugChar (int c)
void putDebugChar(int c)
{
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
unsigned long flags;
volatile u_char sink;
u_char ier;
......@@ -2641,7 +2614,7 @@ void putDebugChar (int c)
/* Ensure transmitter is enabled! */
port = DEBUG_PORT;
base_addr[CyCAR] = (u_char)port;
base_addr[CyCAR] = (u_char) port;
while (base_addr[CyCCR])
;
base_addr[CyCCR] = CyENB_XMTR;
......@@ -2650,16 +2623,14 @@ void putDebugChar (int c)
base_addr[CyIER] = CyTxMpty;
while (1) {
if (pcc2chip[PccSCCTICR] & 0x20)
{
if (pcc2chip[PccSCCTICR] & 0x20) {
/* We have a Tx int. Acknowledge it */
sink = pcc2chip[PccTPIACKR];
if ((base_addr[CyLICR] >> 2) == port) {
base_addr[CyTDR] = c;
base_addr[CyTEOIR] = 0;
break;
}
else
} else
base_addr[CyTEOIR] = CyNOTRANS;
}
}
......@@ -2671,7 +2642,7 @@ void putDebugChar (int c)
int getDebugChar()
{
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
unsigned long flags;
volatile u_char sink;
u_char ier;
......@@ -2693,7 +2664,7 @@ int getDebugChar()
/* Ensure receiver is enabled! */
port = DEBUG_PORT;
base_addr[CyCAR] = (u_char)port;
base_addr[CyCAR] = (u_char) port;
#if 0
while (base_addr[CyCCR])
;
......@@ -2703,31 +2674,30 @@ int getDebugChar()
base_addr[CyIER] = CyRxData;
while (1) {
if (pcc2chip[PccSCCRICR] & 0x20)
{
if (pcc2chip[PccSCCRICR] & 0x20) {
/* We have a Rx int. Acknowledge it */
sink = pcc2chip[PccRPIACKR];
if ((base_addr[CyLICR] >> 2) == port) {
int cnt = base_addr[CyRFOC];
while (cnt-- > 0)
{
while (cnt-- > 0) {
c = base_addr[CyRDR];
if (c == 0)
printk ("!! debug char is null (cnt=%d) !!", cnt);
printk
("!! debug char is null (cnt=%d) !!",
cnt);
else
queueDebugChar (c);
queueDebugChar(c);
}
base_addr[CyREOIR] = 0;
i = debugiq.out;
if (i == debugiq.in)
panic ("Debug input queue empty!");
panic("Debug input queue empty!");
c = debugiq.buf[i];
if (++i == DEBUG_LEN)
i = 0;
debugiq.out = i;
break;
}
else
} else
base_addr[CyREOIR] = CyNOTRANS;
}
}
......@@ -2739,7 +2709,7 @@ int getDebugChar()
return (c);
}
void queueDebugChar (int c)
void queueDebugChar(int c)
{
int i;
......@@ -2751,19 +2721,17 @@ void queueDebugChar (int c)
debugiq.in = i;
}
static void
debug_setup()
static void debug_setup()
{
unsigned long flags;
volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
int i, cflag;
cflag = B19200;
local_irq_save(flags);
for (i = 0; i < 4; i++)
{
for (i = 0; i < 4; i++) {
base_addr[CyCAR] = i;
base_addr[CyLICR] = i << 2;
}
......@@ -2802,8 +2770,8 @@ debug_setup()
base_addr[CyCOR6] = 0;
base_addr[CyCOR7] = 0;
write_cy_cmd(base_addr,CyINIT_CHAN);
write_cy_cmd(base_addr,CyENB_RCVR);
write_cy_cmd(base_addr, CyINIT_CHAN);
write_cy_cmd(base_addr, CyENB_RCVR);
base_addr[CyCAR] = DEBUG_PORT; /* !!! Is this needed? */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册