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,378 +980,342 @@ static unsigned detect_isa_irq(void __iomem * address) ...@@ -980,378 +980,342 @@ 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
/* determine the channel & change to that context */ /* determine the channel & change to that context */
spin_lock(&cinfo->card_lock); spin_lock(&cinfo->card_lock);
save_xir = (u_char) readb(base_addr + (CyRIR << index)); save_xir = (u_char) readb(base_addr + (CyRIR << index));
channel = (u_short) (save_xir & CyIRChannel); channel = (u_short) (save_xir & CyIRChannel);
info = &cinfo->ports[channel + chip * 4]; info = &cinfo->ports[channel + chip * 4];
save_car = readb(base_addr + (CyCAR << index)); save_car = readb(base_addr + (CyCAR << index));
cy_writeb(base_addr + (CyCAR << index), save_xir); cy_writeb(base_addr + (CyCAR << index), save_xir);
/* 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 + (CyRDCR << index));
char_count = readb(base_addr + while (char_count--)
(CyRDCR << index));
while (char_count--) {
data = readb(base_addr +
(CyRDSR << index));
}
}
} else { /* there is an open port for this data */
tty = info->tty;
j = (readb(base_addr + (CyRIVR << index)) &
CyIVRMask);
if (j == CyIVRRxEx) { /* exception */
data = readb(base_addr + (CyRDSR << index)); data = readb(base_addr + (CyRDSR << index));
}
/* For statistics only */ goto end;
if (data & CyBREAK) }
info->icount.brk++; /* there is an open port for this data */
else if (data & CyFRAME) tty = info->tty;
info->icount.frame++; j = readb(base_addr + (CyRIVR << index)) & CyIVRMask;
else if (data & CyPARITY) if (j == CyIVRRxEx) { /* exception */
info->icount.parity++; data = readb(base_addr + (CyRDSR << index));
else if (data & CyOVERRUN)
info->icount.overrun++; /* For statistics only */
if (data & CyBREAK)
if (data & info->ignore_status_mask) { info->icount.brk++;
else if (data & CyFRAME)
info->icount.frame++;
else if (data & CyPARITY)
info->icount.parity++;
else if (data & CyOVERRUN)
info->icount.overrun++;
if (data & info->ignore_status_mask) {
info->icount.rx++;
spin_unlock(&cinfo->card_lock);
return;
}
if (tty_buffer_request_room(tty, 1)) {
if (data & info->read_status_mask) {
if (data & CyBREAK) {
tty_insert_flip_char(tty,
readb(base_addr + (CyRDSR <<
index)), TTY_BREAK);
info->icount.rx++;
if (info->flags & ASYNC_SAK)
do_SAK(tty);
} else if (data & CyFRAME) {
tty_insert_flip_char( tty,
readb(base_addr + (CyRDSR <<
index)), TTY_FRAME);
info->icount.rx++;
info->idle_stats.frame_errs++;
} else if (data & CyPARITY) {
/* Pieces of seven... */
tty_insert_flip_char(tty,
readb(base_addr + (CyRDSR <<
index)), TTY_PARITY);
info->icount.rx++;
info->idle_stats.parity_errs++;
} else if (data & CyOVERRUN) {
tty_insert_flip_char(tty, 0,
TTY_OVERRUN);
info->icount.rx++;
/* If the flip buffer itself is
overflowing, we still lose
the next incoming character.
*/
tty_insert_flip_char(tty,
readb(base_addr + (CyRDSR <<
index)), TTY_FRAME);
info->icount.rx++; info->icount.rx++;
spin_unlock(&cinfo->card_lock);
return;
}
if (tty_buffer_request_room(tty, 1)) {
if (data & info->read_status_mask) {
if (data & CyBREAK) {
tty_insert_flip_char(
tty,
readb(
base_addr +
(CyRDSR <<
index)),
TTY_BREAK);
info->icount.rx++;
if (info->flags &
ASYNC_SAK) {
do_SAK(tty);
}
} else if (data & CyFRAME) {
tty_insert_flip_char(
tty,
readb(
base_addr +
(CyRDSR <<
index)),
TTY_FRAME);
info->icount.rx++;
info->idle_stats.
frame_errs++;
} else if (data & CyPARITY) {
/* Pieces of seven... */
tty_insert_flip_char(
tty,
readb(
base_addr +
(CyRDSR <<
index)),
TTY_PARITY);
info->icount.rx++;
info->idle_stats.
parity_errs++;
} else if (data & CyOVERRUN) {
tty_insert_flip_char(
tty, 0,
TTY_OVERRUN);
info->icount.rx++;
/* If the flip buffer itself is
overflowing, we still lose
the next incoming character.
*/
tty_insert_flip_char(
tty,
readb(
base_addr +
(CyRDSR <<
index)),
TTY_FRAME);
info->icount.rx++;
info->idle_stats.
overruns++;
/* 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);
info->icount.rx++;
}
} else {
tty_insert_flip_char(tty, 0,
TTY_NORMAL);
info->icount.rx++;
}
} else {
/* there was a software buffer
overrun and nothing could be
done about it!!! */
info->icount.buf_overrun++;
info->idle_stats.overruns++; info->idle_stats.overruns++;
/* 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);
info->icount.rx++;
} }
} else { /* normal character reception */ } else {
/* load # chars available from the chip */ tty_insert_flip_char(tty, 0, TTY_NORMAL);
char_count = readb(base_addr + info->icount.rx++;
(CyRDCR << index)); }
} else {
/* there was a software buffer overrun and nothing
* could be done about it!!! */
info->icount.buf_overrun++;
info->idle_stats.overruns++;
}
} else { /* normal character reception */
/* load # chars available from the chip */
char_count = readb(base_addr + (CyRDCR << index));
#ifdef CY_ENABLE_MONITORING #ifdef CY_ENABLE_MONITORING
++info->mon.int_count; ++info->mon.int_count;
info->mon.char_count += char_count; info->mon.char_count += char_count;
if (char_count > info->mon.char_max) if (char_count > info->mon.char_max)
info->mon.char_max = char_count; info->mon.char_max = char_count;
info->mon.char_last = char_count; info->mon.char_last = char_count;
#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, info->idle_stats.recv_bytes++;
TTY_NORMAL); info->icount.rx++;
info->idle_stats.recv_bytes++;
info->icount.rx++;
#ifdef CY_16Y_HACK #ifdef CY_16Y_HACK
udelay(10L); udelay(10L);
#endif #endif
}
info->idle_stats.recv_idle = jiffies;
}
tty_schedule_flip(tty);
} }
/* end of service */ info->idle_stats.recv_idle = jiffies;
cy_writeb(base_addr + (CyRIR << index), (save_xir & 0x3f));
cy_writeb(base_addr + (CyCAR << index), (save_car));
spin_unlock(&cinfo->card_lock);
} }
tty_schedule_flip(tty);
end:
/* end of service */
cy_writeb(base_addr + (CyRIR << index), save_xir & 0x3f);
cy_writeb(base_addr + (CyCAR << index), save_car);
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. */
#ifdef CY_DEBUG_INTERRUPTS #ifdef CY_DEBUG_INTERRUPTS
printk(KERN_DEBUG "cyy_interrupt: xmit intr, chip %d\n", chip); printk(KERN_DEBUG "cyy_interrupt: xmit intr, chip %d\n", chip);
#endif #endif
/* determine the channel & change to that context */ /* determine the channel & change to that context */
spin_lock(&cinfo->card_lock); spin_lock(&cinfo->card_lock);
save_xir = (u_char) readb(base_addr + (CyTIR << index)); save_xir = (u_char) readb(base_addr + (CyTIR << index));
channel = (u_short) (save_xir & CyIRChannel); channel = (u_short) (save_xir & CyIRChannel);
save_car = readb(base_addr + (CyCAR << index)); save_car = readb(base_addr + (CyCAR << index));
cy_writeb(base_addr + (CyCAR << index), save_xir); cy_writeb(base_addr + (CyCAR << index), save_xir);
/* 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)) & ~CyTxRdy);
readb(base_addr + (CySRER << index)) & goto end;
~CyTxRdy); }
goto txend;
}
/* load the on-chip space for outbound data */ /* load the on-chip space for outbound data */
char_count = info->xmit_fifo_size; char_count = info->xmit_fifo_size;
if (info->x_char) { /* send special char */ if (info->x_char) { /* send special char */
outch = info->x_char; outch = info->x_char;
cy_writeb(base_addr + (CyTDR << index), outch); cy_writeb(base_addr + (CyTDR << index), outch);
char_count--; char_count--;
info->icount.tx++; info->icount.tx++;
info->x_char = 0; info->x_char = 0;
} }
if (info->breakon || info->breakoff) { if (info->breakon || info->breakoff) {
if (info->breakon) { if (info->breakon) {
cy_writeb(base_addr + (CyTDR << index), 0); cy_writeb(base_addr + (CyTDR << index), 0);
cy_writeb(base_addr + (CyTDR << index), 0x81); cy_writeb(base_addr + (CyTDR << index), 0x81);
info->breakon = 0; info->breakon = 0;
char_count -= 2; char_count -= 2;
} }
if (info->breakoff) { if (info->breakoff) {
cy_writeb(base_addr + (CyTDR << index), 0); cy_writeb(base_addr + (CyTDR << index), 0);
cy_writeb(base_addr + (CyTDR << index), 0x83); cy_writeb(base_addr + (CyTDR << index), 0x83);
info->breakoff = 0; info->breakoff = 0;
char_count -= 2; char_count -= 2;
}
} }
}
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 + (CySRER << index)) &
readb(base_addr +
(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;
} }
if (info->xmit_buf == NULL) { goto done;
cy_writeb(base_addr + (CySRER << index), }
readb(base_addr + (CySRER << index)) & if (info->xmit_buf == NULL) {
cy_writeb(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];
*/ if (outch) {
outch = info->xmit_buf[info->xmit_tail]; info->xmit_cnt--;
if (outch) { info->xmit_tail = (info->xmit_tail + 1) &
(SERIAL_XMIT_SIZE - 1);
cy_writeb(base_addr + (CyTDR << index), outch);
info->icount.tx++;
} else {
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), outch); cy_writeb(base_addr + (CyTDR << index), outch);
cy_writeb(base_addr + (CyTDR << index), 0);
info->icount.tx++; info->icount.tx++;
} else { char_count--;
if (char_count > 1) {
info->xmit_cnt--;
info->xmit_tail = (info->xmit_tail + 1)&
(SERIAL_XMIT_SIZE - 1);
cy_writeb(base_addr + (CyTDR << index),
outch);
cy_writeb(base_addr + (CyTDR << index),
0);
info->icount.tx++;
char_count--;
}
} }
} }
txdone:
tty_wakeup(info->tty);
txend:
/* end of service */
cy_writeb(base_addr + (CyTIR << index), (save_xir & 0x3f));
cy_writeb(base_addr + (CyCAR << index), (save_car));
spin_unlock(&cinfo->card_lock);
} }
if (status & CySRModem) { /* modem interrupt */ done:
tty_wakeup(info->tty);
end:
/* end of service */
cy_writeb(base_addr + (CyTIR << index), save_xir & 0x3f);
cy_writeb(base_addr + (CyCAR << index), save_car);
spin_unlock(&cinfo->card_lock);
}
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);
save_xir = (u_char) readb(base_addr + (CyMIR << index)); save_xir = (u_char) readb(base_addr + (CyMIR << index));
channel = (u_short) (save_xir & CyIRChannel); channel = (u_short) (save_xir & CyIRChannel);
info = &cinfo->ports[channel + chip * 4]; info = &cinfo->ports[channel + chip * 4];
save_car = readb(base_addr + (CyCAR << index)); save_car = readb(base_addr + (CyCAR << index));
cy_writeb(base_addr + (CyCAR << index), save_xir); cy_writeb(base_addr + (CyCAR << index), save_xir);
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)
if (mdm_change & CyANY_DELTA) { goto end;
/* For statistics only */
if (mdm_change & CyDCD)
info->icount.dcd++;
if (mdm_change & CyCTS)
info->icount.cts++;
if (mdm_change & CyDSR)
info->icount.dsr++;
if (mdm_change & CyRI)
info->icount.rng++;
wake_up_interruptible(&info->delta_msr_wait);
}
if ((mdm_change & CyDCD) && if (mdm_change & CyANY_DELTA) {
(info->flags & ASYNC_CHECK_CD)) { /* For statistics only */
if (!(mdm_status & CyDCD)) { if (mdm_change & CyDCD)
tty_hangup(info->tty); info->icount.dcd++;
info->flags &= ~ASYNC_NORMAL_ACTIVE; if (mdm_change & CyCTS)
} info->icount.cts++;
wake_up_interruptible(&info->open_wait); if (mdm_change & CyDSR)
} info->icount.dsr++;
if ((mdm_change & CyCTS) && if (mdm_change & CyRI)
(info->flags & ASYNC_CTS_FLOW)) { info->icount.rng++;
if (info->tty->hw_stopped) {
if (mdm_status & CyCTS) { wake_up_interruptible(&info->delta_msr_wait);
/* cy_start isn't used }
because... !!! */
info->tty->hw_stopped = 0; if ((mdm_change & CyDCD) && (info->flags & ASYNC_CHECK_CD)) {
cy_writeb(base_addr + if (!(mdm_status & CyDCD)) {
(CySRER << index), tty_hangup(info->tty);
readb(base_addr + info->flags &= ~ASYNC_NORMAL_ACTIVE;
(CySRER << }
index))| wake_up_interruptible(&info->open_wait);
CyTxRdy); }
tty_wakeup(info->tty); if ((mdm_change & CyCTS) && (info->flags & ASYNC_CTS_FLOW)) {
} if (info->tty->hw_stopped) {
} else { if (mdm_status & CyCTS) {
if (!(mdm_status & CyCTS)) { /* cy_start isn't used
/* cy_stop isn't used because... !!! */
because ... !!! */ info->tty->hw_stopped = 0;
info->tty->hw_stopped = 1; cy_writeb(base_addr + (CySRER << index),
cy_writeb(base_addr + readb(base_addr + (CySRER << index)) |
(CySRER << index), CyTxRdy);
readb(base_addr + tty_wakeup(info->tty);
(CySRER <<
index)) &
~CyTxRdy);
}
}
} }
/* if (mdm_change & CyDSR) { } else {
if (!(mdm_status & CyCTS)) {
/* cy_stop isn't used
because ... !!! */
info->tty->hw_stopped = 1;
cy_writeb(base_addr + (CySRER << index),
readb(base_addr + (CySRER << index)) &
~CyTxRdy);
} }
if (mdm_change & CyRI) {
}*/
} }
/* end of service */
cy_writeb(base_addr + (CyMIR << index), (save_xir & 0x3f));
cy_writeb(base_addr + (CyCAR << index), save_car);
spin_unlock(&cinfo->card_lock);
} }
/* if (mdm_change & CyDSR) {
}
if (mdm_change & CyRI) {
}*/
end:
/* end of service */
cy_writeb(base_addr + (CyMIR << index), save_xir & 0x3f);
cy_writeb(base_addr + (CyCAR << index), save_car);
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