Commit ce97a097 authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds

Char: cyclades, make the isr code readable

Due to large indent the code was wrapped and unreadable.  Create 3 function
instead of one and reorder the code, so it is readable now.
Signed-off-by: default avatarJiri 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 ebafeeff
...@@ -980,17 +980,16 @@ static unsigned detect_isa_irq(void __iomem * address) ...@@ -980,17 +980,16 @@ static unsigned detect_isa_irq(void __iomem * address)
} }
#endif /* CONFIG_ISA */ #endif /* CONFIG_ISA */
static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
void __iomem * base_addr, int status, int index) void __iomem *base_addr)
{ {
struct cyclades_port *info; struct cyclades_port *info;
struct tty_struct *tty; struct tty_struct *tty;
int char_count; int char_count;
int j, len, mdm_change, mdm_status, outch; int j, len, index = cinfo->bus_index;
int save_xir, channel, save_car; int save_xir, channel, save_car;
char data; char data;
if (status & CySRReceive) { /* reception interrupt */
#ifdef CY_DEBUG_INTERRUPTS #ifdef CY_DEBUG_INTERRUPTS
printk(KERN_DEBUG "cyy_interrupt: rcvd intr, chip %d\n", chip); printk(KERN_DEBUG "cyy_interrupt: rcvd intr, chip %d\n", chip);
#endif #endif
...@@ -1004,22 +1003,19 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1004,22 +1003,19 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
/* if there is nowhere to put the data, discard it */ /* if there is nowhere to put the data, discard it */
if (info->tty == NULL) { if (info->tty == NULL) {
j = (readb(base_addr + (CyRIVR << index)) & j = (readb(base_addr + (CyRIVR << index)) & CyIVRMask);
CyIVRMask);
if (j == CyIVRRxEx) { /* exception */ if (j == CyIVRRxEx) { /* exception */
data = readb(base_addr + (CyRDSR << index)); data = readb(base_addr + (CyRDSR << index));
} else { /* normal character reception */ } else { /* normal character reception */
char_count = readb(base_addr + char_count = readb(base_addr + (CyRDCR << index));
(CyRDCR << index)); while (char_count--)
while (char_count--) { data = readb(base_addr + (CyRDSR << index));
data = readb(base_addr +
(CyRDSR << index));
} }
goto end;
} }
} else { /* there is an open port for this data */ /* there is an open port for this data */
tty = info->tty; tty = info->tty;
j = (readb(base_addr + (CyRIVR << index)) & j = readb(base_addr + (CyRIVR << index)) & CyIVRMask;
CyIVRMask);
if (j == CyIVRRxEx) { /* exception */ if (j == CyIVRRxEx) { /* exception */
data = readb(base_addr + (CyRDSR << index)); data = readb(base_addr + (CyRDSR << index));
...@@ -1041,86 +1037,60 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1041,86 +1037,60 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
if (tty_buffer_request_room(tty, 1)) { if (tty_buffer_request_room(tty, 1)) {
if (data & info->read_status_mask) { if (data & info->read_status_mask) {
if (data & CyBREAK) { if (data & CyBREAK) {
tty_insert_flip_char( tty_insert_flip_char(tty,
tty, readb(base_addr + (CyRDSR <<
readb( index)), TTY_BREAK);
base_addr +
(CyRDSR <<
index)),
TTY_BREAK);
info->icount.rx++; info->icount.rx++;
if (info->flags & if (info->flags & ASYNC_SAK)
ASYNC_SAK) {
do_SAK(tty); do_SAK(tty);
}
} else if (data & CyFRAME) { } else if (data & CyFRAME) {
tty_insert_flip_char( tty_insert_flip_char( tty,
tty, readb(base_addr + (CyRDSR <<
readb( index)), TTY_FRAME);
base_addr +
(CyRDSR <<
index)),
TTY_FRAME);
info->icount.rx++; info->icount.rx++;
info->idle_stats. info->idle_stats.frame_errs++;
frame_errs++;
} else if (data & CyPARITY) { } else if (data & CyPARITY) {
/* Pieces of seven... */ /* Pieces of seven... */
tty_insert_flip_char( tty_insert_flip_char(tty,
tty, readb(base_addr + (CyRDSR <<
readb( index)), TTY_PARITY);
base_addr +
(CyRDSR <<
index)),
TTY_PARITY);
info->icount.rx++; info->icount.rx++;
info->idle_stats. info->idle_stats.parity_errs++;
parity_errs++;
} else if (data & CyOVERRUN) { } else if (data & CyOVERRUN) {
tty_insert_flip_char( tty_insert_flip_char(tty, 0,
tty, 0,
TTY_OVERRUN); TTY_OVERRUN);
info->icount.rx++; info->icount.rx++;
/* If the flip buffer itself is /* If the flip buffer itself is
overflowing, we still lose overflowing, we still lose
the next incoming character. the next incoming character.
*/ */
tty_insert_flip_char( tty_insert_flip_char(tty,
tty, readb(base_addr + (CyRDSR <<
readb( index)), TTY_FRAME);
base_addr +
(CyRDSR <<
index)),
TTY_FRAME);
info->icount.rx++; info->icount.rx++;
info->idle_stats. info->idle_stats.overruns++;
overruns++;
/* These two conditions may imply */ /* These two conditions may imply */
/* a normal read should be done. */ /* a normal read should be done. */
/* }else if(data & CyTIMEOUT){ */ /* } else if(data & CyTIMEOUT) { */
/* }else if(data & CySPECHAR){ */ /* } else if(data & CySPECHAR) { */
} else { } else {
tty_insert_flip_char( tty_insert_flip_char(tty, 0,
tty, 0,
TTY_NORMAL); TTY_NORMAL);
info->icount.rx++; info->icount.rx++;
} }
} else { } else {
tty_insert_flip_char(tty, 0, tty_insert_flip_char(tty, 0, TTY_NORMAL);
TTY_NORMAL);
info->icount.rx++; info->icount.rx++;
} }
} else { } else {
/* there was a software buffer /* there was a software buffer overrun and nothing
overrun and nothing could be * could be done about it!!! */
done about it!!! */
info->icount.buf_overrun++; info->icount.buf_overrun++;
info->idle_stats.overruns++; info->idle_stats.overruns++;
} }
} else { /* normal character reception */ } else { /* normal character reception */
/* load # chars available from the chip */ /* load # chars available from the chip */
char_count = readb(base_addr + char_count = readb(base_addr + (CyRDCR << index));
(CyRDCR << index));
#ifdef CY_ENABLE_MONITORING #ifdef CY_ENABLE_MONITORING
++info->mon.int_count; ++info->mon.int_count;
...@@ -1131,10 +1101,8 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1131,10 +1101,8 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
#endif #endif
len = tty_buffer_request_room(tty, char_count); len = tty_buffer_request_room(tty, char_count);
while (len--) { while (len--) {
data = readb(base_addr + data = readb(base_addr + (CyRDSR << index));
(CyRDSR << index)); tty_insert_flip_char(tty, data, TTY_NORMAL);
tty_insert_flip_char(tty, data,
TTY_NORMAL);
info->idle_stats.recv_bytes++; info->idle_stats.recv_bytes++;
info->icount.rx++; info->icount.rx++;
#ifdef CY_16Y_HACK #ifdef CY_16Y_HACK
...@@ -1144,14 +1112,21 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1144,14 +1112,21 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
info->idle_stats.recv_idle = jiffies; info->idle_stats.recv_idle = jiffies;
} }
tty_schedule_flip(tty); tty_schedule_flip(tty);
} end:
/* end of service */ /* end of service */
cy_writeb(base_addr + (CyRIR << index), (save_xir & 0x3f)); cy_writeb(base_addr + (CyRIR << index), save_xir & 0x3f);
cy_writeb(base_addr + (CyCAR << index), (save_car)); cy_writeb(base_addr + (CyCAR << index), save_car);
spin_unlock(&cinfo->card_lock); spin_unlock(&cinfo->card_lock);
} }
static void cyy_chip_tx(struct cyclades_card *cinfo, int chip,
void __iomem *base_addr)
{
struct cyclades_port *info;
int char_count;
int outch;
int save_xir, channel, save_car, index = cinfo->bus_index;
if (status & CySRTransmit) { /* transmission interrupt */
/* Since we only get here when the transmit buffer /* Since we only get here when the transmit buffer
is empty, we know we can always stuff a dozen is empty, we know we can always stuff a dozen
characters. */ characters. */
...@@ -1169,16 +1144,14 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1169,16 +1144,14 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
/* validate the port# (as configured and open) */ /* validate the port# (as configured and open) */
if (channel + chip * 4 >= cinfo->nports) { if (channel + chip * 4 >= cinfo->nports) {
cy_writeb(base_addr + (CySRER << index), cy_writeb(base_addr + (CySRER << index),
readb(base_addr + (CySRER << index)) & readb(base_addr + (CySRER << index)) & ~CyTxRdy);
~CyTxRdy); goto end;
goto txend;
} }
info = &cinfo->ports[channel + chip * 4]; info = &cinfo->ports[channel + chip * 4];
if (info->tty == NULL) { if (info->tty == NULL) {
cy_writeb(base_addr + (CySRER << index), cy_writeb(base_addr + (CySRER << index),
readb(base_addr + (CySRER << index)) & readb(base_addr + (CySRER << index)) & ~CyTxRdy);
~CyTxRdy); goto end;
goto txend;
} }
/* load the on-chip space for outbound data */ /* load the on-chip space for outbound data */
...@@ -1209,42 +1182,37 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1209,42 +1182,37 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
while (char_count-- > 0) { while (char_count-- > 0) {
if (!info->xmit_cnt) { if (!info->xmit_cnt) {
if (readb(base_addr + (CySRER << index)) & if (readb(base_addr + (CySRER << index)) & CyTxMpty) {
CyTxMpty) {
cy_writeb(base_addr + (CySRER << index), cy_writeb(base_addr + (CySRER << index),
readb(base_addr + readb(base_addr + (CySRER << index)) &
(CySRER << index)) &
~CyTxMpty); ~CyTxMpty);
} else { } else {
cy_writeb(base_addr + (CySRER << index), cy_writeb(base_addr + (CySRER << index),
(readb(base_addr + (readb(base_addr + (CySRER << index)) &
(CySRER << index)) &
~CyTxRdy) | CyTxMpty); ~CyTxRdy) | CyTxMpty);
} }
goto txdone; goto done;
} }
if (info->xmit_buf == NULL) { if (info->xmit_buf == NULL) {
cy_writeb(base_addr + (CySRER << index), cy_writeb(base_addr + (CySRER << index),
readb(base_addr + (CySRER << index)) & readb(base_addr + (CySRER << index)) &
~CyTxRdy); ~CyTxRdy);
goto txdone; goto done;
} }
if (info->tty->stopped || info->tty->hw_stopped) { if (info->tty->stopped || info->tty->hw_stopped) {
cy_writeb(base_addr + (CySRER << index), cy_writeb(base_addr + (CySRER << index),
readb(base_addr + (CySRER << index)) & readb(base_addr + (CySRER << index)) &
~CyTxRdy); ~CyTxRdy);
goto txdone; goto done;
} }
/* Because the Embedded Transmit Commands have /* Because the Embedded Transmit Commands have been enabled,
been enabled, we must check to see if the * we must check to see if the escape character, NULL, is being
escape character, NULL, is being sent. If it * sent. If it is, we must ensure that there is room for it to
is, we must ensure that there is room for it * be doubled in the output stream. Therefore we no longer
to be doubled in the output stream. Therefore * advance the pointer when the character is fetched, but
we no longer advance the pointer when the * rather wait until after the check for a NULL output
character is fetched, but rather wait until * character. This is necessary because there may not be room
after the check for a NULL output character. * for the two chars needed to send a NULL.)
This is necessary because there may not be
room for the two chars needed to send a NULL.)
*/ */
outch = info->xmit_buf[info->xmit_tail]; outch = info->xmit_buf[info->xmit_tail];
if (outch) { if (outch) {
...@@ -1256,28 +1224,31 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, ...@@ -1256,28 +1224,31 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
} else { } else {
if (char_count > 1) { if (char_count > 1) {
info->xmit_cnt--; info->xmit_cnt--;
info->xmit_tail = (info->xmit_tail + 1)& info->xmit_tail = (info->xmit_tail + 1) &
(SERIAL_XMIT_SIZE - 1); (SERIAL_XMIT_SIZE - 1);
cy_writeb(base_addr + (CyTDR << index), cy_writeb(base_addr + (CyTDR << index), outch);
outch); cy_writeb(base_addr + (CyTDR << index), 0);
cy_writeb(base_addr + (CyTDR << index),
0);
info->icount.tx++; info->icount.tx++;
char_count--; char_count--;
} }
} }
} }
txdone: done:
tty_wakeup(info->tty); tty_wakeup(info->tty);
txend: end:
/* end of service */ /* end of service */
cy_writeb(base_addr + (CyTIR << index), (save_xir & 0x3f)); cy_writeb(base_addr + (CyTIR << index), save_xir & 0x3f);
cy_writeb(base_addr + (CyCAR << index), (save_car)); cy_writeb(base_addr + (CyCAR << index), save_car);
spin_unlock(&cinfo->card_lock); spin_unlock(&cinfo->card_lock);
} }
if (status & CySRModem) { /* modem interrupt */ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
void __iomem *base_addr)
{
struct cyclades_port *info;
int mdm_change, mdm_status;
int save_xir, channel, save_car, index = cinfo->bus_index;
/* determine the channel & change to that context */ /* determine the channel & change to that context */
spin_lock(&cinfo->card_lock); spin_lock(&cinfo->card_lock);
...@@ -1290,7 +1261,9 @@ txend: ...@@ -1290,7 +1261,9 @@ txend:
mdm_change = readb(base_addr + (CyMISR << index)); mdm_change = readb(base_addr + (CyMISR << index));
mdm_status = readb(base_addr + (CyMSVR1 << index)); mdm_status = readb(base_addr + (CyMSVR1 << index));
if (info->tty) { if (!info->tty)
goto end;
if (mdm_change & CyANY_DELTA) { if (mdm_change & CyANY_DELTA) {
/* For statistics only */ /* For statistics only */
if (mdm_change & CyDCD) if (mdm_change & CyDCD)
...@@ -1305,26 +1278,21 @@ txend: ...@@ -1305,26 +1278,21 @@ txend:
wake_up_interruptible(&info->delta_msr_wait); wake_up_interruptible(&info->delta_msr_wait);
} }
if ((mdm_change & CyDCD) && if ((mdm_change & CyDCD) && (info->flags & ASYNC_CHECK_CD)) {
(info->flags & ASYNC_CHECK_CD)) {
if (!(mdm_status & CyDCD)) { if (!(mdm_status & CyDCD)) {
tty_hangup(info->tty); tty_hangup(info->tty);
info->flags &= ~ASYNC_NORMAL_ACTIVE; info->flags &= ~ASYNC_NORMAL_ACTIVE;
} }
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&info->open_wait);
} }
if ((mdm_change & CyCTS) && if ((mdm_change & CyCTS) && (info->flags & ASYNC_CTS_FLOW)) {
(info->flags & ASYNC_CTS_FLOW)) {
if (info->tty->hw_stopped) { if (info->tty->hw_stopped) {
if (mdm_status & CyCTS) { if (mdm_status & CyCTS) {
/* cy_start isn't used /* cy_start isn't used
because... !!! */ because... !!! */
info->tty->hw_stopped = 0; info->tty->hw_stopped = 0;
cy_writeb(base_addr + cy_writeb(base_addr + (CySRER << index),
(CySRER << index), readb(base_addr + (CySRER << index)) |
readb(base_addr +
(CySRER <<
index))|
CyTxRdy); CyTxRdy);
tty_wakeup(info->tty); tty_wakeup(info->tty);
} }
...@@ -1333,11 +1301,8 @@ txend: ...@@ -1333,11 +1301,8 @@ txend:
/* cy_stop isn't used /* cy_stop isn't used
because ... !!! */ because ... !!! */
info->tty->hw_stopped = 1; info->tty->hw_stopped = 1;
cy_writeb(base_addr + cy_writeb(base_addr + (CySRER << index),
(CySRER << index), readb(base_addr + (CySRER << index)) &
readb(base_addr +
(CySRER <<
index)) &
~CyTxRdy); ~CyTxRdy);
} }
} }
...@@ -1346,12 +1311,11 @@ txend: ...@@ -1346,12 +1311,11 @@ txend:
} }
if (mdm_change & CyRI) { if (mdm_change & CyRI) {
}*/ }*/
} end:
/* end of service */ /* end of service */
cy_writeb(base_addr + (CyMIR << index), (save_xir & 0x3f)); cy_writeb(base_addr + (CyMIR << index), save_xir & 0x3f);
cy_writeb(base_addr + (CyCAR << index), save_car); cy_writeb(base_addr + (CyCAR << index), save_car);
spin_unlock(&cinfo->card_lock); spin_unlock(&cinfo->card_lock);
}
} }
/* The real interrupt service routine is called /* The real interrupt service routine is called
...@@ -1401,11 +1365,14 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id) ...@@ -1401,11 +1365,14 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)
chips to be checked in a round-robin fashion (after chips to be checked in a round-robin fashion (after
draining each of a bunch (1000) of characters). draining each of a bunch (1000) of characters).
*/ */
if (1000 < too_many++) { if (1000 < too_many++)
break; break;
} if (status & CySRReceive) /* rx intr */
cyy_intr_chip(cinfo, chip, base_addr, status, cyy_chip_rx(cinfo, chip, base_addr);
index); if (status & CySRTransmit) /* tx intr */
cyy_chip_tx(cinfo, chip, base_addr);
if (status & CySRModem) /* modem intr */
cyy_chip_modem(cinfo, chip, base_addr);
} }
} }
} while (had_work); } while (had_work);
......
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