2005-01-16 13:53:28

by James Nelson

[permalink] [raw]
Subject: [PATCH 0/13] remove cli()/sti() in drivers/char/*

This series of patches removes the last cli()/sti()/save_flags()/restore_flags()
function calls in drivers/char.

Diffstat output:
epca.c | 158 +++++++++++++++++-------------------------
esp.c | 139 ++++++++++++++++++------------------
ftape/lowlevel/ftape-format.c | 2
ftape/lowlevel/ftape-io.c | 6 -
generic_serial.c | 6 -
ip2main.c | 12 +--
istallion.c | 121 +++++++++++++-------------------
ite_gpio.c | 5 -
moxa.c | 25 ++----
pcxx.c | 140 +++++++++++++++----------------------
riscom8.c | 89 +++++++++++------------
serial_tx3912.c | 36 ++++-----
stallion.c | 146 +++++++++++++++-----------------------
13 files changed, 382 insertions(+), 503 deletions(-)


2005-01-16 13:54:32

by James Nelson

[permalink] [raw]
Subject: [PATCH 1/13] epca: remove cli()/sti() in drivers/char/epca.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/epca.c linux-2.6.11-rc1-mm1/drivers/char/epca.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/epca.c 2004-12-24 16:34:58.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/epca.c 2005-01-16 07:32:19.278559215 -0500
@@ -501,13 +501,11 @@
if ((ch = verifyChannel(tty)) != NULL)
{ /* Begin if ch != NULL */

- save_flags(flags);
- cli();
+ local_irq_save(flags);

if (tty_hung_up_p(filp))
{
- restore_flags(flags);
- return;
+ goto out;
}

/* Check to see if the channel is open more than once */
@@ -519,8 +517,7 @@
the channel.
---------------------------------------------------------------- */

- restore_flags(flags);
- return;
+ goto out;
} /* End channel is open more than once */

/* Port open only once go ahead with shutdown & reset */
@@ -572,8 +569,8 @@
ASYNC_CLOSING);
wake_up_interruptible(&ch->close_wait);

-
- restore_flags(flags);
+out:
+ local_irq_restore(flags);

} /* End if ch != NULL */

@@ -591,8 +588,7 @@
if (!(ch->asyncflags & ASYNC_INITIALIZED))
return;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);

bc = ch->brdchan;
@@ -628,7 +624,7 @@
/* Prevent future Digi programmed interrupts from coming active */

ch->asyncflags &= ~ASYNC_INITIALIZED;
- restore_flags(flags);
+ local_irq_restore(flags);

} /* End shutdown */

@@ -649,8 +645,7 @@

unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
if (tty->driver->flush_buffer)
tty->driver->flush_buffer(tty);
tty_ldisc_flush(tty);
@@ -659,7 +654,7 @@
ch->tty = NULL;
ch->event = 0;
ch->count = 0;
- restore_flags(flags);
+ local_irq_restore(flags);
ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED);
wake_up_interruptible(&ch->open_wait);

@@ -708,8 +703,7 @@
size = ch->txbufsize;

amountCopied = 0;
- save_flags(flags);
- cli();
+ local_irq_save(flags);

globalwinon(ch);

@@ -785,7 +779,7 @@
bc->ilow = 1;
}
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

return(amountCopied);

@@ -822,8 +816,7 @@

if ((ch = verifyChannel(tty)) != NULL)
{
- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);

bc = ch->brdchan;
@@ -844,7 +837,7 @@
bc->ilow = 1;
}
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/* Return how much room is left on card */
@@ -873,8 +866,7 @@
if ((ch = verifyChannel(tty)) == NULL)
return(0);

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);

bc = ch->brdchan;
@@ -915,7 +907,7 @@
} /* End if some space on the card has been used */

memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

/* Return number of characters residing on card. */
return(chars);
@@ -941,8 +933,7 @@
if ((ch = verifyChannel(tty)) == NULL)
return;

- save_flags(flags);
- cli();
+ local_irq_save(flags);

globalwinon(ch);

@@ -954,7 +945,7 @@
fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0);

memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

wake_up_interruptible(&tty->write_wait);
tty_wakeup(tty);
@@ -977,8 +968,7 @@
{
unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);

/* ----------------------------------------------------------------
If not already set and the transmitter is busy setup an event
@@ -988,7 +978,7 @@
if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT))
setup_empty_event(tty,ch);

- restore_flags(flags);
+ local_irq_restore(flags);
}

} /* End pc_flush_chars */
@@ -1047,15 +1037,13 @@

retval = 0;
add_wait_queue(&ch->open_wait, &wait);
- save_flags(flags);
- cli();
-
+ local_irq_save(flags);

/* We dec count so that pc_close will know when to free things */
if (!tty_hung_up_p(filp))
ch->count--;

- restore_flags(flags);
+ local_irq_restore(flags);

ch->blocked_open++;

@@ -1096,10 +1084,10 @@

current->state = TASK_RUNNING;
remove_wait_queue(&ch->open_wait, &wait);
- cli();
+ local_irq_save(flags);
if (!tty_hung_up_p(filp))
ch->count++;
- restore_flags(flags);
+ local_irq_restore(flags);

ch->blocked_open--;

@@ -1200,8 +1188,7 @@
the tty->termios struct otherwise let pc_close handle it.
-------------------------------------------------------------------- */

- save_flags(flags);
- cli();
+ local_irq_save(flags);

globalwinon(ch);
ch->statusflags = 0;
@@ -1228,7 +1215,7 @@
ch->asyncflags |= ASYNC_INITIALIZED;
memoff(ch);

- restore_flags(flags);
+ local_irq_restore(flags);

retval = block_til_ready(tty, filp, ch);
if (retval)
@@ -1242,15 +1229,14 @@
--------------------------------------------------------------- */
ch->tty = tty;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);

/* Enable Digi Data events */
bc->idata = 1;

memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

return 0;

@@ -1262,12 +1248,11 @@

unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);

pc_init();

- restore_flags(flags);
+ local_irq_restore(flags);

return(0);
}
@@ -1292,15 +1277,13 @@

del_timer_sync(&epca_timer);

- save_flags(flags);
- cli();
+ local_irq_save(flags);

if ((tty_unregister_driver(pc_driver)) ||
(tty_unregister_driver(pc_info)))
{
printk(KERN_WARNING "<Error> - DIGI : cleanup_module failed to un-register tty driver\n");
- restore_flags(flags);
- return;
+ goto out;
}
put_tty_driver(pc_driver);
put_tty_driver(pc_info);
@@ -1335,7 +1318,7 @@
pci_unregister_driver (&epca_driver);
#endif

- restore_flags(flags);
+out: local_irq_restore(flags);

}
module_exit(epca_module_exit);
@@ -1499,8 +1482,7 @@
tty_set_operations(pc_info, &info_ops);


- save_flags(flags);
- cli();
+ local_irq_save(flags);

for (crd = 0; crd < num_cards; crd++)
{ /* Begin for each card */
@@ -1635,7 +1617,7 @@
epca_timer.function = epcapoll;
mod_timer(&epca_timer, jiffies + HZ/25);

- restore_flags(flags);
+ local_irq_restore(flags);

return 0;

@@ -1943,8 +1925,7 @@
buffer empty) and acts on those events.
----------------------------------------------------------------------- */

- save_flags(flags);
- cli();
+ local_irq_save(flags);

for (crd = 0; crd < num_cards; crd++)
{ /* Begin for each card */
@@ -1984,7 +1965,7 @@

mod_timer(&epca_timer, jiffies + (HZ / 25));

- restore_flags(flags);
+ local_irq_restore(flags);
} /* End epcapoll */

/* --------------------- Begin doevent ------------------------ */
@@ -2762,12 +2743,11 @@
return(-EINVAL);
}

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);
mstat = bc->mstat;
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

if (mstat & ch->m_dtr)
mflag |= TIOCM_DTR;
@@ -2801,8 +2781,7 @@
return(-EINVAL);
}

- save_flags(flags);
- cli();
+ local_irq_save(flags);
/*
* I think this modemfake stuff is broken. It doesn't
* correctly reflect the behaviour desired by the TIOCM*
@@ -2834,7 +2813,7 @@

epcaparam(tty,ch);
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);
return 0;
}

@@ -2859,8 +2838,6 @@
return(-EINVAL);
}

- save_flags(flags);
-
/* -------------------------------------------------------------------
For POSIX compliance we need to add more ioctls. See tty_ioctl.c
in /usr/src/linux/drivers/char for a good example. In particular
@@ -2936,20 +2913,20 @@

case TIOCSDTR:
ch->omodem |= ch->m_dtr;
- cli();
+ local_irq_save(flags);
globalwinon(ch);
fepcmd(ch, SETMODEM, ch->m_dtr, 0, 10, 1);
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);
break;

case TIOCCDTR:
ch->omodem &= ~ch->m_dtr;
- cli();
+ local_irq_save(flags);
globalwinon(ch);
fepcmd(ch, SETMODEM, 0, ch->m_dtr, 10, 1);
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);
break;

case DIGI_GETA:
@@ -2990,7 +2967,7 @@
ch->dsr = ch->m_dsr;
}

- cli();
+ local_irq_save(flags);
globalwinon(ch);

/* -----------------------------------------------------------------
@@ -3000,12 +2977,12 @@

epcaparam(tty,ch);
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);
break;

case DIGI_GETFLOW:
case DIGI_GETAFLOW:
- cli();
+ local_irq_save(flags);
globalwinon(ch);
if ((cmd) == (DIGI_GETFLOW))
{
@@ -3018,7 +2995,7 @@
dflow.stopc = bc->stopca;
}
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

if (copy_to_user(argp, &dflow, sizeof(dflow)))
return -EFAULT;
@@ -3042,7 +3019,7 @@

if (dflow.startc != startc || dflow.stopc != stopc)
{ /* Begin if setflow toggled */
- cli();
+ local_irq_save(flags);
globalwinon(ch);

if ((cmd) == (DIGI_SETFLOW))
@@ -3062,7 +3039,7 @@
pc_start(tty);

memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

} /* End if setflow toggled */
break;
@@ -3092,8 +3069,7 @@
if ((ch = verifyChannel(tty)) != NULL)
{ /* Begin if channel valid */

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);
epcaparam(tty, ch);
memoff(ch);
@@ -3106,7 +3082,7 @@
(tty->termios->c_cflag & CLOCAL))
wake_up_interruptible(&ch->open_wait);

- restore_flags(flags);
+ local_irq_restore(flags);

} /* End if channel valid */

@@ -3163,8 +3139,7 @@
if ((ch = verifyChannel(tty)) != NULL)
{ /* Begin if valid channel */

- save_flags(flags);
- cli();
+ local_irq_save(flags);

if ((ch->statusflags & TXSTOPPED) == 0)
{ /* Begin if transmit stop requested */
@@ -3180,7 +3155,7 @@

} /* End if transmit stop requested */

- restore_flags(flags);
+ local_irq_restore(flags);

} /* End if valid channel */

@@ -3203,8 +3178,7 @@

unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);

/* Just in case output was resumed because of a change in Digi-flow */
if (ch->statusflags & TXSTOPPED)
@@ -3226,7 +3200,7 @@

} /* End transmit resume requested */

- restore_flags(flags);
+ local_irq_restore(flags);

} /* End if channel valid */

@@ -3257,8 +3231,7 @@
{ /* Begin if channel valid */


- save_flags(flags);
- cli();
+ local_irq_save(flags);

if ((ch->statusflags & RXSTOPPED) == 0)
{
@@ -3268,7 +3241,7 @@
ch->statusflags |= RXSTOPPED;
memoff(ch);
}
- restore_flags(flags);
+ local_irq_restore(flags);

} /* End if channel valid */

@@ -3294,8 +3267,7 @@


/* Just in case output was resumed because of a change in Digi-flow */
- save_flags(flags);
- cli();
+ local_irq_save(flags);

if (ch->statusflags & RXSTOPPED)
{
@@ -3307,7 +3279,7 @@
ch->statusflags &= ~RXSTOPPED;
memoff(ch);
}
- restore_flags(flags);
+ local_irq_restore(flags);

} /* End if channel valid */

@@ -3320,8 +3292,7 @@

unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);

/* --------------------------------------------------------------------
@@ -3335,7 +3306,7 @@
fepcmd(ch, SENDBREAK, msec, 0, 10, 0);
memoff(ch);

- restore_flags(flags);
+ local_irq_restore(flags);

} /* End digi_send_break */

@@ -3347,8 +3318,7 @@
volatile struct board_chan *bc = ch->brdchan;
unsigned long int flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);
ch->statusflags |= EMPTYWAIT;

@@ -3359,7 +3329,7 @@

bc->iempty = 1;
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

} /* End setup_empty_event */

2005-01-16 13:57:16

by James Nelson

[permalink] [raw]
Subject: [PATCH 2/13] esp: remove cli()/sti() in drivers/char/esp.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/esp.c linux-2.6.11-rc1-mm1/drivers/char/esp.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/esp.c 2005-01-16 07:17:19.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/esp.c 2005-01-16 07:32:19.292557341 -0500
@@ -212,14 +212,14 @@
if (serial_paranoia_check(info, tty->name, "rs_stop"))
return;

- save_flags(flags); cli();
+ local_irq_save(flags);
if (info->IER & UART_IER_THRI) {
info->IER &= ~UART_IER_THRI;
serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
serial_out(info, UART_ESI_CMD2, info->IER);
}

- restore_flags(flags);
+ local_irq_restore(flags);
}

static void rs_start(struct tty_struct *tty)
@@ -230,13 +230,13 @@
if (serial_paranoia_check(info, tty->name, "rs_start"))
return;

- save_flags(flags); cli();
+ local_irq_save(flags);
if (info->xmit_cnt && info->xmit_buf && !(info->IER & UART_IER_THRI)) {
info->IER |= UART_IER_THRI;
serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
serial_out(info, UART_ESI_CMD2, info->IER);
}
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*
@@ -298,6 +298,7 @@
struct esp_pio_buffer *pio_buf;
struct esp_pio_buffer *err_buf;
unsigned char status_mask;
+ unsigned long flags;

pio_buf = get_pio_buffer();

@@ -311,7 +312,7 @@
return;
}

- sti();
+ local_save_flags(flags); local_irq_enable();

status_mask = (info->read_status_mask >> 2) & 0x07;

@@ -329,7 +330,7 @@
(serial_in(info, UART_ESI_RWS) >> 3) & status_mask;
}

- cli();
+ local_irq_restore(flags);

/* make sure everything is still ok since interrupts were enabled */
tty = info->tty;
@@ -455,6 +456,7 @@
{
int i;
struct esp_pio_buffer *pio_buf;
+ unsigned long flags;

pio_buf = get_pio_buffer();

@@ -478,7 +480,7 @@
info->xmit_tail = (info->xmit_tail + space_avail) &
(ESP_XMIT_SIZE - 1);

- sti();
+ local_save_flags(flags); local_irq_enable();

for (i = 0; i < space_avail - 1; i += 2) {
outw(*((unsigned short *)(pio_buf->data + i)),
@@ -489,7 +491,7 @@
serial_out(info, UART_ESI_TX,
pio_buf->data[space_avail - 1]);

- cli();
+ local_irq_restore(flags);

if (info->xmit_cnt) {
serial_out(info, UART_ESI_CMD1, ESI_NO_COMMAND);
@@ -654,7 +656,7 @@
err_status = 0;
scratch = serial_in(info, UART_ESI_SID);

- cli();
+ local_irq_disable();

if (!info->tty) {
sti();
@@ -740,7 +742,7 @@
#ifdef SERIAL_DEBUG_INTR
printk("end.\n");
#endif
- sti();
+ local_irq_enable();
return IRQ_HANDLED;
}

@@ -859,7 +861,7 @@
int retval=0;
unsigned int num_chars;

- save_flags(flags); cli();
+ local_irq_save(flags);

if (info->flags & ASYNC_INITIALIZED)
goto out;
@@ -973,7 +975,7 @@

info->flags |= ASYNC_INITIALIZED;
retval = 0;
-out: restore_flags(flags);
+out: local_irq_restore(flags);
return retval;
}

@@ -993,7 +995,7 @@
info->irq);
#endif

- save_flags(flags); cli(); /* Disable interrupts */
+ local_irq_save(flags); /* Disable interrupts */

/*
* clear delta_msr_wait queue to avoid mem leaks: we may free the irq
@@ -1058,7 +1060,7 @@
set_bit(TTY_IO_ERROR, &info->tty->flags);

info->flags &= ~ASYNC_INITIALIZED;
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*
@@ -1172,7 +1174,7 @@
if (I_IXOFF(info->tty))
flow1 |= 0x81;

- save_flags(flags); cli();
+ local_irq_save(flags);
/* set baud */
serial_out(info, UART_ESI_CMD1, ESI_SET_BAUD);
serial_out(info, UART_ESI_CMD2, quot >> 8);
@@ -1219,7 +1221,7 @@
serial_out(info, UART_ESI_CMD2, info->config.flow_on >> 8);
serial_out(info, UART_ESI_CMD2, info->config.flow_on);

- restore_flags(flags);
+ local_irq_restore(flags);
}

static void rs_put_char(struct tty_struct *tty, unsigned char ch)
@@ -1233,16 +1235,14 @@
if (!tty || !info->xmit_buf)
return;

- save_flags(flags); cli();
- if (info->xmit_cnt >= ESP_XMIT_SIZE - 1) {
- restore_flags(flags);
- return;
- }
+ local_irq_save(flags);
+ if (info->xmit_cnt >= ESP_XMIT_SIZE - 1)
+ goto out;

info->xmit_buf[info->xmit_head++] = ch;
info->xmit_head &= ESP_XMIT_SIZE-1;
info->xmit_cnt++;
- restore_flags(flags);
+out: local_irq_restore(flags);
}

static void rs_flush_chars(struct tty_struct *tty)
@@ -1256,13 +1256,13 @@
if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf)
return;

- save_flags(flags); cli();
+ local_irq_save(flags);
if (!(info->IER & UART_IER_THRI)) {
info->IER |= UART_IER_THRI;
serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
serial_out(info, UART_ESI_CMD2, info->IER);
}
- restore_flags(flags);
+ local_irq_restore(flags);
}

static int rs_write(struct tty_struct * tty,
@@ -1305,7 +1305,7 @@
ret += c;
}

- save_flags(flags); cli();
+ local_irq_save(flags);

if (info->xmit_cnt && !tty->stopped && !(info->IER & UART_IER_THRI)) {
info->IER |= UART_IER_THRI;
@@ -1313,7 +1313,7 @@
serial_out(info, UART_ESI_CMD2, info->IER);
}

- restore_flags(flags);
+ local_irq_restore(flags);
return ret;
}

@@ -1345,9 +1345,9 @@

if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
return;
- cli();
+ local_irq_disable();
info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
- sti();
+ local_irq_enable();
tty_wakeup(tty);
}

@@ -1372,13 +1372,13 @@
if (serial_paranoia_check(info, tty->name, "rs_throttle"))
return;

- cli();
+ local_irq_disable();
info->IER &= ~UART_IER_RDI;
serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
serial_out(info, UART_ESI_CMD2, info->IER);
serial_out(info, UART_ESI_CMD1, ESI_SET_RX_TIMEOUT);
serial_out(info, UART_ESI_CMD2, 0x00);
- sti();
+ local_irq_enable();
}

static void rs_unthrottle(struct tty_struct * tty)
@@ -1394,13 +1394,13 @@
if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
return;

- cli();
+ local_irq_disable();
info->IER |= UART_IER_RDI;
serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
serial_out(info, UART_ESI_CMD2, info->IER);
serial_out(info, UART_ESI_CMD1, ESI_SET_RX_TIMEOUT);
serial_out(info, UART_ESI_CMD2, info->config.rx_timeout);
- sti();
+ local_irq_enable();
}

/*
@@ -1654,13 +1654,13 @@

info->config.flow_off = new_config.flow_off;
info->config.flow_on = new_config.flow_on;
- save_flags(flags); cli();
+ local_irq_save(flags);
serial_out(info, UART_ESI_CMD1, ESI_SET_FLOW_LVL);
serial_out(info, UART_ESI_CMD2, new_config.flow_off >> 8);
serial_out(info, UART_ESI_CMD2, new_config.flow_off);
serial_out(info, UART_ESI_CMD2, new_config.flow_on >> 8);
serial_out(info, UART_ESI_CMD2, new_config.flow_on);
- restore_flags(flags);
+ local_irq_restore(flags);
}

if ((new_config.rx_trigger != info->config.rx_trigger) ||
@@ -1669,7 +1669,7 @@

info->config.rx_trigger = new_config.rx_trigger;
info->config.tx_trigger = new_config.tx_trigger;
- save_flags(flags); cli();
+ local_irq_save(flags);
serial_out(info, UART_ESI_CMD1, ESI_SET_TRIGGER);
serial_out(info, UART_ESI_CMD2,
new_config.rx_trigger >> 8);
@@ -1677,14 +1677,14 @@
serial_out(info, UART_ESI_CMD2,
new_config.tx_trigger >> 8);
serial_out(info, UART_ESI_CMD2, new_config.tx_trigger);
- restore_flags(flags);
+ local_irq_restore(flags);
}

if (new_config.rx_timeout != info->config.rx_timeout) {
unsigned long flags;

info->config.rx_timeout = new_config.rx_timeout;
- save_flags(flags); cli();
+ local_irq_save(flags);

if (info->IER & UART_IER_RDI) {
serial_out(info, UART_ESI_CMD1,
@@ -1693,7 +1693,7 @@
new_config.rx_timeout);
}

- restore_flags(flags);
+ local_irq_restore(flags);
}

if (!(info->flags & ASYNC_INITIALIZED))
@@ -1717,10 +1717,10 @@
unsigned char status;
unsigned int result;

- cli();
+ local_irq_disable();
serial_out(info, UART_ESI_CMD1, ESI_GET_UART_STAT);
status = serial_in(info, UART_ESI_STAT1);
- sti();
+ local_irq_enable();
result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
return put_user(result,value);
}
@@ -1737,10 +1737,10 @@
return -EIO;

control = info->MCR;
- cli();
+ local_irq_disable();
serial_out(info, UART_ESI_CMD1, ESI_GET_UART_STAT);
status = serial_in(info, UART_ESI_STAT2);
- sti();
+ local_irq_enable();
return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0)
| ((control & UART_MCR_DTR) ? TIOCM_DTR : 0)
| ((status & UART_MSR_DCD) ? TIOCM_CAR : 0)
@@ -1759,7 +1759,7 @@
if (tty->flags & (1 << TTY_IO_ERROR))
return -EIO;

- cli();
+ local_irq_disable();

if (set & TIOCM_RTS)
info->MCR |= UART_MCR_RTS;
@@ -1774,7 +1774,7 @@
serial_out(info, UART_ESI_CMD1, ESI_WRITE_UART);
serial_out(info, UART_ESI_CMD2, UART_MCR);
serial_out(info, UART_ESI_CMD2, info->MCR);
- sti();
+ local_irq_enable();
return 0;
}

@@ -1789,7 +1789,7 @@
if (serial_paranoia_check(info, tty->name, "esp_break"))
return;

- save_flags(flags); cli();
+ local_irq_save(flags);
if (break_state == -1) {
serial_out(info, UART_ESI_CMD1, ESI_ISSUE_BREAK);
serial_out(info, UART_ESI_CMD2, 0x01);
@@ -1799,7 +1799,7 @@
serial_out(info, UART_ESI_CMD1, ESI_ISSUE_BREAK);
serial_out(info, UART_ESI_CMD2, 0x00);
}
- restore_flags(flags);
+ local_irq_restore(flags);
}

static int rs_ioctl(struct tty_struct *tty, struct file * file,
@@ -1849,17 +1849,17 @@
* Caller should use TIOCGICOUNT to see which one it was
*/
case TIOCMIWAIT:
- cli();
+ local_irq_disable();
cprev = info->icount; /* note the counters on entry */
- sti();
+ local_irq_enable();
while (1) {
interruptible_sleep_on(&info->delta_msr_wait);
/* see if a signal did it */
if (signal_pending(current))
return -ERESTARTSYS;
- cli();
+ local_irq_disable();
cnow = info->icount; /* atomic copy */
- sti();
+ local_irq_enable();
if (cnow.rng == cprev.rng &&
cnow.dsr == cprev.dsr &&
cnow.dcd == cprev.dcd &&
@@ -1886,9 +1886,9 @@
* RI where only 0->1 is counted.
*/
case TIOCGICOUNT:
- cli();
+ local_irq_disable();
cnow = info->icount;
- sti();
+ local_irq_enable();
p_cuser = argp;
if (put_user(cnow.cts, &p_cuser->cts) ||
put_user(cnow.dsr, &p_cuser->dsr) ||
@@ -1923,22 +1923,22 @@
if ((old_termios->c_cflag & CBAUD) &&
!(tty->termios->c_cflag & CBAUD)) {
info->MCR &= ~(UART_MCR_DTR|UART_MCR_RTS);
- cli();
+ local_irq_disable();
serial_out(info, UART_ESI_CMD1, ESI_WRITE_UART);
serial_out(info, UART_ESI_CMD2, UART_MCR);
serial_out(info, UART_ESI_CMD2, info->MCR);
- sti();
+ local_irq_enable();
}

/* Handle transition away from B0 status */
if (!(old_termios->c_cflag & CBAUD) &&
(tty->termios->c_cflag & CBAUD)) {
info->MCR |= (UART_MCR_DTR | UART_MCR_RTS);
- cli();
+ local_irq_disable();
serial_out(info, UART_ESI_CMD1, ESI_WRITE_UART);
serial_out(info, UART_ESI_CMD2, UART_MCR);
serial_out(info, UART_ESI_CMD2, info->MCR);
- sti();
+ local_irq_enable();
}

/* Handle turning of CRTSCTS */
@@ -1978,7 +1978,7 @@
if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
return;

- save_flags(flags); cli();
+ local_irq_save(flags);

if (tty_hung_up_p(filp)) {
DBG_CNT("before DEC-hung");
@@ -2058,7 +2058,7 @@
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&info->close_wait);
out:
- restore_flags(flags);
+ local_irq_restore(flags);
}

static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
@@ -2076,7 +2076,7 @@
if (!char_time)
char_time = 1;

- save_flags(flags); cli();
+ local_irq_save(flags);
serial_out(info, UART_ESI_CMD1, ESI_NO_COMMAND);
serial_out(info, UART_ESI_CMD1, ESI_GET_TX_AVAIL);

@@ -2094,7 +2094,7 @@
serial_out(info, UART_ESI_CMD1, ESI_GET_TX_AVAIL);
}

- restore_flags(flags);
+ local_irq_restore(flags);
set_current_state(TASK_RUNNING);
}

@@ -2174,15 +2174,13 @@
printk("block_til_ready before block: ttys%d, count = %d\n",
info->line, info->count);
#endif
- save_flags(flags);
- cli();
+ local_irq_save(flags);
if (!tty_hung_up_p(filp))
info->count--;
- restore_flags(flags);
+ local_irq_restore(flags);
info->blocked_open++;
while (1) {
- save_flags(flags);
- cli();
+ local_irq_save(flags);
if ((tty->termios->c_cflag & CBAUD)) {
unsigned int scratch;

@@ -2194,7 +2192,7 @@
serial_out(info, UART_ESI_CMD2,
scratch | UART_MCR_DTR | UART_MCR_RTS);
}
- restore_flags(flags);
+ local_irq_restore(flags);
set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) ||
!(info->flags & ASYNC_INITIALIZED)) {
@@ -2335,7 +2333,7 @@
if (!request_region(info->port, REGION_SIZE, "esp serial"))
return -EIO;

- save_flags(flags); cli();
+ local_irq_save(flags);

/*
* Check for ESP card
@@ -2372,7 +2370,7 @@
if (!port_detected)
release_region(info->port, REGION_SIZE);

- restore_flags(flags);
+ local_irq_restore(flags);
return (port_detected);
}

@@ -2569,12 +2567,11 @@
struct esp_pio_buffer *pio_buf;

/* printk("Unloading %s: version %s\n", serial_name, serial_version); */
- save_flags(flags);
- cli();
+ local_irq_save(flags);
if ((e1 = tty_unregister_driver(esp_driver)))
printk("SERIAL: failed to unregister serial driver (%d)\n",
e1);
- restore_flags(flags);
+ local_irq_restore(flags);
put_tty_driver(esp_driver);

while (ports) {

2005-01-16 13:58:44

by James Nelson

[permalink] [raw]
Subject: [PATCH 3/13] ftape: remove cli()/sti() in drivers/char/ftape/lowlevel/ftape-format.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/ftape/lowlevel/ftape-format.c linux-2.6.11-rc1-mm1/drivers/char/ftape/lowlevel/ftape-format.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/ftape/lowlevel/ftape-format.c 2004-12-24 16:34:45.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/ftape/lowlevel/ftape-format.c 2005-01-16 07:32:19.293557207 -0500
@@ -132,7 +132,7 @@
TRACE_CATCH(ftape_seek_head_to_track(track),);
TRACE_CATCH(ftape_command(QIC_LOGICAL_FORWARD),);
spin_lock_irqsave(&ftape_format_lock, flags);
- TRACE_CATCH(fdc_setup_formatting(head), restore_flags(flags));
+ TRACE_CATCH(fdc_setup_formatting(head),);
spin_unlock_irqrestore(&ftape_format_lock, flags);
TRACE_EXIT 0;
}

2005-01-16 13:58:49

by James Nelson

[permalink] [raw]
Subject: [PATCH 6/13] ip2: remove cli()/sti() in drivers/char/ip2main.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/ip2main.c linux-2.6.11-rc1-mm1/drivers/char/ip2main.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/ip2main.c 2005-01-16 07:17:19.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/ip2main.c 2005-01-16 07:32:19.311554798 -0500
@@ -2205,9 +2205,9 @@
* for masking). Caller should use TIOCGICOUNT to see which one it was
*/
case TIOCMIWAIT:
- save_flags(flags);cli();
+ local_irq_save(flags);
cprev = pCh->icount; /* note the counters on entry */
- restore_flags(flags);
+ local_irq_restore(flags);
i2QueueCommands(PTYPE_BYPASS, pCh, 100, 4,
CMD_DCD_REP, CMD_CTS_REP, CMD_DSR_REP, CMD_RI_REP);
init_waitqueue_entry(&wait, current);
@@ -2227,9 +2227,9 @@
rc = -ERESTARTSYS;
break;
}
- save_flags(flags);cli();
+ local_irq_save(flags);
cnow = pCh->icount; /* atomic copy */
- restore_flags(flags);
+ local_irq_restore(flags);
if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) {
rc = -EIO; /* no change => rc */
@@ -2267,9 +2267,9 @@
case TIOCGICOUNT:
ip2trace (CHANN, ITRC_IOCTL, 11, 1, rc );

- save_flags(flags);cli();
+ local_irq_save(flags);
cnow = pCh->icount;
- restore_flags(flags);
+ local_irq_restore(flags);
p_cuser = argp;
rc = put_user(cnow.cts, &p_cuser->cts);
rc = put_user(cnow.dsr, &p_cuser->dsr);

2005-01-16 14:03:38

by James Nelson

[permalink] [raw]
Subject: [PATCH 9/13] moxa: remove cli()/sti() in drivers/char/moxa.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/moxa.c linux-2.6.11-rc1-mm1/drivers/char/moxa.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/moxa.c 2004-12-24 16:35:28.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/moxa.c 2005-01-16 07:32:19.500529504 -0500
@@ -645,10 +645,9 @@
if (ch == NULL)
return (0);
port = ch->port;
- save_flags(flags);
- cli();
+ local_irq_save(flags);
len = MoxaPortWriteData(port, (unsigned char *) buf, count);
- restore_flags(flags);
+ local_irq_restore(flags);

/*********************************************
if ( !(ch->statusflags & LOWWAIT) &&
@@ -723,11 +722,10 @@
if (ch == NULL)
return;
port = ch->port;
- save_flags(flags);
- cli();
+ local_irq_save(flags);
moxaXmitBuff[0] = c;
MoxaPortWriteData(port, moxaXmitBuff, 1);
- restore_flags(flags);
+ local_irq_restore(flags);
/************************************************
if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) )
*************************************************/
@@ -1030,11 +1028,10 @@
printk("block_til_ready before block: ttys%d, count = %d\n",
ch->line, ch->count);
#endif
- save_flags(flags);
- cli();
+ local_irq_save(flags);
if (!tty_hung_up_p(filp))
ch->count--;
- restore_flags(flags);
+ local_irq_restore(flags);
ch->blocked_open++;
while (1) {
set_current_state(TASK_INTERRUPTIBLE);
@@ -1080,15 +1077,14 @@
struct moxa_str *ch = tty->driver_data;
unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
ch->statusflags |= EMPTYWAIT;
moxaEmptyTimer_on[ch->port] = 0;
del_timer(&moxaEmptyTimer[ch->port]);
moxaEmptyTimer[ch->port].expires = jiffies + HZ;
moxaEmptyTimer_on[ch->port] = 1;
add_timer(&moxaEmptyTimer[ch->port]);
- restore_flags(flags);
+ local_irq_restore(flags);
}

static void check_xmit_empty(unsigned long data)
@@ -1156,10 +1152,9 @@
charptr = tp->flip.char_buf_ptr;
flagptr = tp->flip.flag_buf_ptr;
rc = tp->flip.count;
- save_flags(flags);
- cli();
+ local_irq_save(flags);
count = MoxaPortReadData(ch->port, charptr, space);
- restore_flags(flags);
+ local_irq_restore(flags);
for (i = 0; i < count; i++)
*flagptr++ = 0;
charptr += count;

2005-01-16 14:00:59

by James Nelson

[permalink] [raw]
Subject: [PATCH 7/13] istallion: remove cli()/sti() in drivers/char/istallion.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/istallion.c linux-2.6.11-rc1-mm1/drivers/char/istallion.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/istallion.c 2004-12-24 16:35:00.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/istallion.c 2005-01-16 07:32:19.327552657 -0500
@@ -807,10 +807,9 @@
printk("init_module()\n");
#endif

- save_flags(flags);
- cli();
+ local_irq_save(flags);
stli_init();
- restore_flags(flags);
+ local_irq_restore(flags);

return(0);
}
@@ -831,8 +830,7 @@
printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle,
stli_drvversion);

- save_flags(flags);
- cli();
+ local_irq_save(flags);

/*
* Free up all allocated resources used by the ports. This includes
@@ -847,8 +845,7 @@
if (i) {
printk("STALLION: failed to un-register tty driver, "
"errno=%d\n", -i);
- restore_flags(flags);
- return;
+ goto out;
}
put_tty_driver(stli_serial);
for (i = 0; i < 4; i++) {
@@ -884,7 +881,7 @@
stli_brds[i] = (stlibrd_t *) NULL;
}

- restore_flags(flags);
+out: local_irq_restore(flags);
}

module_init(istallion_module_init);
@@ -1128,18 +1125,14 @@
if (portp == (stliport_t *) NULL)
return;

- save_flags(flags);
- cli();
- if (tty_hung_up_p(filp)) {
- restore_flags(flags);
- return;
- }
+ local_irq_save(flags);
+ if (tty_hung_up_p(filp))
+ goto out;
+
if ((tty->count == 1) && (portp->refcount != 1))
portp->refcount = 1;
- if (portp->refcount-- > 1) {
- restore_flags(flags);
- return;
- }
+ if (portp->refcount-- > 1)
+ goto out;

portp->flags |= ASYNC_CLOSING;

@@ -1185,7 +1178,7 @@

portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&portp->close_wait);
- restore_flags(flags);
+out: local_irq_restore(flags);
}

/*****************************************************************************/
@@ -1266,8 +1259,7 @@
/*
* Send a message to the slave to open this port.
*/
- save_flags(flags);
- cli();
+ local_irq_save(flags);

/*
* Slave is already closing this port. This can happen if a hangup
@@ -1277,7 +1269,7 @@
*/
while (test_bit(ST_CLOSING, &portp->state)) {
if (signal_pending(current)) {
- restore_flags(flags);
+ local_irq_restore(flags);
return(-ERESTARTSYS);
}
interruptible_sleep_on(&portp->raw_wait);
@@ -1299,7 +1291,7 @@
EBRDDISABLE(brdp);

if (wait == 0) {
- restore_flags(flags);
+ local_irq_restore(flags);
return(0);
}

@@ -1316,7 +1308,7 @@
}
interruptible_sleep_on(&portp->raw_wait);
}
- restore_flags(flags);
+ local_irq_restore(flags);

if ((rc == 0) && (portp->rc != 0))
rc = -EIO;
@@ -1344,8 +1336,7 @@
(int) brdp, (int) portp, (int) arg, wait);
#endif

- save_flags(flags);
- cli();
+ local_irq_save(flags);

/*
* Slave is already closing this port. This can happen if a hangup
@@ -1354,7 +1345,7 @@
if (wait) {
while (test_bit(ST_CLOSING, &portp->state)) {
if (signal_pending(current)) {
- restore_flags(flags);
+ local_irq_restore(flags);
return(-ERESTARTSYS);
}
interruptible_sleep_on(&portp->raw_wait);
@@ -1376,7 +1367,7 @@

set_bit(ST_CLOSING, &portp->state);
if (wait == 0) {
- restore_flags(flags);
+ local_irq_restore(flags);
return(0);
}

@@ -1392,7 +1383,7 @@
}
interruptible_sleep_on(&portp->raw_wait);
}
- restore_flags(flags);
+ local_irq_restore(flags);

if ((rc == 0) && (portp->rc != 0))
rc = -EIO;
@@ -1418,11 +1409,10 @@
(int) arg, size, copyback);
#endif

- save_flags(flags);
- cli();
+ local_irq_save(flags);
while (test_bit(ST_CMDING, &portp->state)) {
if (signal_pending(current)) {
- restore_flags(flags);
+ local_irq_restore(flags);
return(-ERESTARTSYS);
}
interruptible_sleep_on(&portp->raw_wait);
@@ -1432,12 +1422,12 @@

while (test_bit(ST_CMDING, &portp->state)) {
if (signal_pending(current)) {
- restore_flags(flags);
+ local_irq_restore(flags);
return(-ERESTARTSYS);
}
interruptible_sleep_on(&portp->raw_wait);
}
- restore_flags(flags);
+ local_irq_restore(flags);

if (portp->rc != 0)
return(-EIO);
@@ -1497,8 +1487,7 @@
if (portp->tty->termios->c_cflag & CLOCAL)
doclocal++;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
portp->openwaitcnt++;
if (! tty_hung_up_p(filp))
portp->refcount--;
@@ -1530,7 +1519,7 @@
if (! tty_hung_up_p(filp))
portp->refcount++;
portp->openwaitcnt--;
- restore_flags(flags);
+ local_irq_restore(flags);

return(rc);
}
@@ -1577,8 +1566,7 @@
/*
* All data is now local, shove as much as possible into shared memory.
*/
- save_flags(flags);
- cli();
+ local_irq_save(flags);
EBRDENABLE(brdp);
ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr);
head = (unsigned int) ap->txq.head;
@@ -1624,7 +1612,7 @@
set_bit(ST_TXBUSY, &portp->state);
EBRDDISABLE(brdp);

- restore_flags(flags);
+ local_irq_restore(flags);

return(count);
}
@@ -1706,8 +1694,7 @@
if (brdp == (stlibrd_t *) NULL)
return;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
EBRDENABLE(brdp);

ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr);
@@ -1756,7 +1743,7 @@
set_bit(ST_TXBUSY, &portp->state);

EBRDDISABLE(brdp);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -1791,8 +1778,7 @@
if (brdp == (stlibrd_t *) NULL)
return(0);

- save_flags(flags);
- cli();
+ local_irq_save(flags);
EBRDENABLE(brdp);
rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq;
head = (unsigned int) rp->head;
@@ -1802,7 +1788,7 @@
len = (head >= tail) ? (portp->txsize - (head - tail)) : (tail - head);
len--;
EBRDDISABLE(brdp);
- restore_flags(flags);
+ local_irq_restore(flags);

if (tty == stli_txcooktty) {
stli_txcookrealsize = len;
@@ -1846,8 +1832,7 @@
if (brdp == (stlibrd_t *) NULL)
return(0);

- save_flags(flags);
- cli();
+ local_irq_save(flags);
EBRDENABLE(brdp);
rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq;
head = (unsigned int) rp->head;
@@ -1858,7 +1843,7 @@
if ((len == 0) && test_bit(ST_TXBUSY, &portp->state))
len = 1;
EBRDDISABLE(brdp);
- restore_flags(flags);
+ local_irq_restore(flags);

return(len);
}
@@ -2303,8 +2288,7 @@

portp->flags &= ~ASYNC_INITIALIZED;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
if (! test_bit(ST_CLOSING, &portp->state))
stli_rawclose(brdp, portp, 0, 0);
if (tty->termios->c_cflag & HUPCL) {
@@ -2318,7 +2302,7 @@
&portp->asig, sizeof(asysigs_t), 0);
}
}
- restore_flags(flags);
+ local_irq_restore(flags);

clear_bit(ST_TXBUSY, &portp->state);
clear_bit(ST_RXSTOP, &portp->state);
@@ -2359,8 +2343,7 @@
if (brdp == (stlibrd_t *) NULL)
return;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
if (tty == stli_txcooktty) {
stli_txcooktty = (struct tty_struct *) NULL;
stli_txcooksize = 0;
@@ -2377,7 +2360,7 @@
stli_sendcmd(brdp, portp, A_FLUSH, &ftype,
sizeof(unsigned long), 0);
}
- restore_flags(flags);
+ local_irq_restore(flags);

wake_up_interruptible(&tty->write_wait);
if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
@@ -2653,14 +2636,12 @@
(int) arg, size, copyback);
#endif

- save_flags(flags);
- cli();
+ local_irq_save(flags);

if (test_bit(ST_CMDING, &portp->state)) {
printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n",
(int) cmd);
- restore_flags(flags);
- return;
+ goto out;
}

EBRDENABLE(brdp);
@@ -2680,7 +2661,7 @@
*bits |= portp->portbit;
set_bit(ST_CMDING, &portp->state);
EBRDDISABLE(brdp);
- restore_flags(flags);
+out: local_irq_restore(flags);
}

/*****************************************************************************/
@@ -4195,8 +4176,7 @@

rc = 0;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
EBRDENABLE(brdp);
hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
nrdevs = hdrp->nrdevs;
@@ -4273,7 +4253,7 @@

stli_donestartup:
EBRDDISABLE(brdp);
- restore_flags(flags);
+ local_irq_restore(flags);

if (rc == 0)
brdp->state |= BST_STARTED;
@@ -4775,8 +4755,7 @@

size = MIN(count, (brdp->memsize - fp->f_pos));

- save_flags(flags);
- cli();
+ local_irq_save(flags);
EBRDENABLE(brdp);
while (size > 0) {
memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos);
@@ -4791,7 +4770,7 @@
}
out:
EBRDDISABLE(brdp);
- restore_flags(flags);
+ local_irq_restore(flags);

return(count);
}
@@ -4831,8 +4810,7 @@
chbuf = (char __user *) buf;
size = MIN(count, (brdp->memsize - fp->f_pos));

- save_flags(flags);
- cli();
+ local_irq_save(flags);
EBRDENABLE(brdp);
while (size > 0) {
memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos);
@@ -4847,7 +4825,7 @@
}
out:
EBRDDISABLE(brdp);
- restore_flags(flags);
+ local_irq_restore(flags);

return(count);
}
@@ -4950,8 +4928,7 @@
stli_comstats.state = portp->state;
stli_comstats.flags = portp->flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
if (portp->tty != (struct tty_struct *) NULL) {
if (portp->tty->driver_data == portp) {
stli_comstats.ttystate = portp->tty->flags;
@@ -4964,7 +4941,7 @@
}
}
}
- restore_flags(flags);
+ local_irq_restore(flags);

stli_comstats.txtotal = stli_cdkstats.txchars;
stli_comstats.rxtotal = stli_cdkstats.rxchars + stli_cdkstats.ringover;

2005-01-16 14:05:33

by James Nelson

[permalink] [raw]
Subject: [PATCH 10/13] pcxx: remove cli()/sti() in drivers/char/pcxx.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/pcxx.c linux-2.6.11-rc1-mm1/drivers/char/pcxx.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/pcxx.c 2004-12-24 16:35:00.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/pcxx.c 2005-01-16 07:32:19.508528433 -0500
@@ -209,8 +209,7 @@

printk(KERN_NOTICE "Unloading PC/Xx version %s\n", VERSION);

- save_flags(flags);
- cli();
+ local_irq_save(flags);
del_timer_sync(&pcxx_timer);

if ((e1 = tty_unregister_driver(pcxe_driver)))
@@ -219,7 +218,7 @@
put_tty_driver(pcxe_driver);
cleanup_board_resources();
kfree(digi_channels);
- restore_flags(flags);
+ local_irq_restore(flags);
}

static inline struct channel *chan(register struct tty_struct *tty)
@@ -323,12 +322,12 @@
info->blocked_open++;

for (;;) {
- cli();
+ local_irq_disable();
globalwinon(info);
info->omodem |= DTR|RTS;
fepcmd(info, SETMODEM, DTR|RTS, 0, 10, 1);
memoff(info);
- sti();
+ local_irq_enable();
set_current_state(TASK_INTERRUPTIBLE);
if(tty_hung_up_p(filp) || (info->asyncflags & ASYNC_INITIALIZED) == 0) {
if(info->asyncflags & ASYNC_HUP_NOTIFY)
@@ -404,8 +403,7 @@
return -ERESTARTSYS;
}

- save_flags(flags);
- cli();
+ local_irq_save(flags);
ch->count++;
tty->driver_data = ch;
ch->tty = tty;
@@ -428,7 +426,7 @@
memoff(ch);
ch->asyncflags |= ASYNC_INITIALIZED;
}
- restore_flags(flags);
+ local_irq_restore(flags);

if(ch->asyncflags & ASYNC_CLOSING) {
interruptible_sleep_on(&ch->close_wait);
@@ -463,8 +461,7 @@
if (!(info->asyncflags & ASYNC_INITIALIZED))
return;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(info);

bc = info->brdchan;
@@ -483,7 +480,7 @@

memoff(info);
info->asyncflags &= ~ASYNC_INITIALIZED;
- restore_flags(flags);
+ local_irq_restore(flags);
}


@@ -493,14 +490,12 @@

if ((info=chan(tty))!=NULL) {
unsigned long flags;
- save_flags(flags);
- cli();
+ local_irq_save(flags);

- if(tty_hung_up_p(filp)) {
+ if(tty_hung_up_p(filp))
/* flag that somebody is done with this module */
- restore_flags(flags);
- return;
- }
+ goto out;
+
/* this check is in serial.c, it won't hurt to do it here too */
if ((tty->count == 1) && (info->count != 1)) {
/*
@@ -513,10 +508,9 @@
printk("pcxe_close: bad serial port count; tty->count is 1, info->count is %d\n", info->count);
info->count = 1;
}
- if (info->count-- > 1) {
- restore_flags(flags);
- return;
- }
+ if (info->count-- > 1)
+ goto out;
+
if (info->count < 0) {
info->count = 0;
}
@@ -544,7 +538,7 @@
}
info->asyncflags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&info->close_wait);
- restore_flags(flags);
+out: local_irq_restore(flags);
}
}

@@ -556,15 +550,14 @@
if ((ch=chan(tty))!=NULL) {
unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
shutdown(ch);
ch->event = 0;
ch->count = 0;
ch->tty = NULL;
ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
wake_up_interruptible(&ch->open_wait);
- restore_flags(flags);
+ local_irq_restore(flags);
}
}

@@ -590,8 +583,7 @@
*/

total = 0;
- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);
head = bc->tin & (size - 1);
tail = bc->tout;
@@ -629,7 +621,7 @@
bc->ilow = 1;
}
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

return(total);
}
@@ -653,8 +645,7 @@
unsigned int head, tail;
unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);

bc = ch->brdchan;
@@ -672,7 +663,7 @@
bc->ilow = 1;
}
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);
}

return remain;
@@ -691,8 +682,7 @@
if ((ch=chan(tty))==NULL)
return(0);

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);

bc = ch->brdchan;
@@ -718,7 +708,7 @@
}

memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

return(chars);
}
@@ -734,8 +724,7 @@
if ((ch=chan(tty))==NULL)
return;

- save_flags(flags);
- cli();
+ local_irq_save(flags);

globalwinon(ch);
bc = ch->brdchan;
@@ -743,7 +732,7 @@
fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0);

memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

tty_wakeup(tty);
}
@@ -755,11 +744,10 @@
if ((ch=chan(tty))!=NULL) {
unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT))
setup_empty_event(tty,ch);
- restore_flags(flags);
+ local_irq_restore(flags);
}
}

@@ -1512,8 +1500,7 @@
struct channel *ch;
struct board_info *bd;

- save_flags(flags);
- cli();
+ local_irq_save(flags);

for(crd=0; crd < numcards; crd++) {
bd = &boards[crd];
@@ -1536,7 +1523,7 @@
}

mod_timer(&pcxx_timer, jiffies + HZ/25);
- restore_flags(flags);
+ local_irq_restore(flags);
}

static void doevent(int crd)
@@ -1940,12 +1927,11 @@
return(-EINVAL);
}

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);
mstat = bc->mstat;
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

if(mstat & DTR)
mflag |= TIOCM_DTR;
@@ -1978,8 +1964,7 @@
return(-EINVAL);
}

- save_flags(flags);
- cli();
+ local_irq_save(flags);
/*
* I think this modemfake stuff is broken. It doesn't
* correctly reflect the behaviour desired by the TIOCM*
@@ -2005,7 +1990,7 @@
globalwinon(ch);
pcxxparam(tty,ch);
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);
return 0;
}

@@ -2028,8 +2013,6 @@
return(-EINVAL);
}

- save_flags(flags);
-
switch(cmd) {
case TCSBRK: /* SVID version: non-zero arg --> no break */
retval = tty_check_change(tty);
@@ -2074,21 +2057,21 @@
return pcxe_tiocmset(tty, file, mstat, ~mstat);

case TIOCSDTR:
- cli();
+ local_irq_save(flags);
ch->omodem |= DTR;
globalwinon(ch);
fepcmd(ch, SETMODEM, DTR, 0, 10, 1);
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);
break;

case TIOCCDTR:
ch->omodem &= ~DTR;
- cli();
+ local_irq_save(flags);
globalwinon(ch);
fepcmd(ch, SETMODEM, 0, DTR, 10, 1);
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);
break;

case DIGI_GETA:
@@ -2123,16 +2106,16 @@
ch->dsr = DSR;
}

- cli();
+ local_irq_save(flags);
globalwinon(ch);
pcxxparam(tty,ch);
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);
break;

case DIGI_GETFLOW:
case DIGI_GETAFLOW:
- cli();
+ local_irq_save(flags);
globalwinon(ch);
if(cmd == DIGI_GETFLOW) {
dflow.startc = bc->startc;
@@ -2142,7 +2125,7 @@
dflow.stopc = bc->stopca;
}
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);

if (copy_to_user((char*)arg, &dflow, sizeof(dflow)))
return -EFAULT;
@@ -2162,7 +2145,7 @@
return -EFAULT;

if(dflow.startc != startc || dflow.stopc != stopc) {
- cli();
+ local_irq_save(flags);
globalwinon(ch);

if(cmd == DIGI_SETFLOW) {
@@ -2179,7 +2162,7 @@
pcxe_start(tty);

memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);
}
break;

@@ -2196,8 +2179,7 @@

if ((info=chan(tty))!=NULL) {
unsigned long flags;
- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(info);
pcxxparam(tty,info);
memoff(info);
@@ -2208,7 +2190,7 @@
if(!(old_termios->c_cflag & CLOCAL) &&
(tty->termios->c_cflag & CLOCAL))
wake_up_interruptible(&info->open_wait);
- restore_flags(flags);
+ local_irq_restore(flags);
}
}

@@ -2237,15 +2219,14 @@

if ((info=chan(tty))!=NULL) {
unsigned long flags;
- save_flags(flags);
- cli();
+ local_irq_save(flags);
if ((info->statusflags & TXSTOPPED) == 0) {
globalwinon(info);
fepcmd(info, PAUSETX, 0, 0, 0, 0);
info->statusflags |= TXSTOPPED;
memoff(info);
}
- restore_flags(flags);
+ local_irq_restore(flags);
}
}

@@ -2255,15 +2236,14 @@

if ((info=chan(tty))!=NULL) {
unsigned long flags;
- save_flags(flags);
- cli();
+ local_irq_save(flags);
if ((info->statusflags & RXSTOPPED) == 0) {
globalwinon(info);
fepcmd(info, PAUSERX, 0, 0, 0, 0);
info->statusflags |= RXSTOPPED;
memoff(info);
}
- restore_flags(flags);
+ local_irq_restore(flags);
}
}

@@ -2275,8 +2255,7 @@
unsigned long flags;

/* Just in case output was resumed because of a change in Digi-flow */
- save_flags(flags);
- cli();
+ local_irq_save(flags);
if(info->statusflags & RXSTOPPED) {
volatile struct board_chan *bc;
globalwinon(info);
@@ -2285,7 +2264,7 @@
info->statusflags &= ~RXSTOPPED;
memoff(info);
}
- restore_flags(flags);
+ local_irq_restore(flags);
}
}

@@ -2297,8 +2276,7 @@
if ((info=chan(tty))!=NULL) {
unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
/* Just in case output was resumed because of a change in Digi-flow */
if(info->statusflags & TXSTOPPED) {
volatile struct board_chan *bc;
@@ -2310,7 +2288,7 @@
info->statusflags &= ~TXSTOPPED;
memoff(info);
}
- restore_flags(flags);
+ local_irq_restore(flags);
}
}

@@ -2319,8 +2297,7 @@
{
unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);

/*
@@ -2334,7 +2311,7 @@
fepcmd(ch, SENDBREAK, msec, 0, 10, 0);
memoff(ch);

- restore_flags(flags);
+ local_irq_restore(flags);
}

static void setup_empty_event(struct tty_struct *tty, struct channel *ch)
@@ -2342,12 +2319,11 @@
volatile struct board_chan *bc;
unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
globalwinon(ch);
ch->statusflags |= EMPTYWAIT;
bc = ch->brdchan;
bc->iempty = 1;
memoff(ch);
- restore_flags(flags);
+ local_irq_restore(flags);
}

2005-01-16 14:09:11

by James Nelson

[permalink] [raw]
Subject: [PATCH 11/13] riscom8: remove cli()/sti() in drivers/char/riscom8.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/riscom8.c linux-2.6.11-rc1-mm1/drivers/char/riscom8.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/riscom8.c 2004-12-24 16:34:44.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/riscom8.c 2005-01-16 07:32:19.510528165 -0500
@@ -232,13 +232,13 @@
{
unsigned long flags;

- save_flags(flags); cli();
+ local_irq_save(flags);
rc_out(bp, RC_CTOUT, 0); /* Clear timeout */
rc_wait_CCR(bp); /* Wait for CCR ready */
rc_out(bp, CD180_CCR, CCR_HARDRESET); /* Reset CD180 chip */
- sti();
+ local_irq_enable();
rc_long_delay(HZ/20); /* Delay 0.05 sec */
- cli();
+ local_irq_disable();
rc_out(bp, CD180_GIVR, RC_ID); /* Set ID for this chip */
rc_out(bp, CD180_GICR, 0); /* Clear all bits */
rc_out(bp, CD180_PILR1, RC_ACK_MINT); /* Prio for modem intr */
@@ -249,7 +249,7 @@
rc_out(bp, CD180_PPRH, (RC_OSCFREQ/(1000000/RISCOM_TPS)) >> 8);
rc_out(bp, CD180_PPRL, (RC_OSCFREQ/(1000000/RISCOM_TPS)) & 0xff);

- restore_flags(flags);
+ local_irq_restore(flags);
}

/* Main probing routine, also sets irq. */
@@ -861,7 +861,7 @@
port->xmit_buf = (unsigned char *) tmp;
}

- save_flags(flags); cli();
+ local_irq_save(flags);

if (port->tty)
clear_bit(TTY_IO_ERROR, &port->tty->flags);
@@ -873,7 +873,7 @@
rc_change_speed(bp, port);
port->flags |= ASYNC_INITIALIZED;

- restore_flags(flags);
+ local_irq_restore(flags);
return 0;
}

@@ -984,19 +984,19 @@
*/
retval = 0;
add_wait_queue(&port->open_wait, &wait);
- cli();
+ local_irq_disable();
if (!tty_hung_up_p(filp))
port->count--;
- sti();
+ local_irq_enable();
port->blocked_open++;
while (1) {
- cli();
+ local_irq_disable();
rc_out(bp, CD180_CAR, port_No(port));
CD = rc_in(bp, CD180_MSVR) & MSVR_CD;
rc_out(bp, CD180_MSVR, MSVR_RTS);
bp->DTR &= ~(1u << port_No(port));
rc_out(bp, RC_DTR, bp->DTR);
- sti();
+ local_irq_enable();
set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) ||
!(port->flags & ASYNC_INITIALIZED)) {
@@ -1069,7 +1069,7 @@
if (!port || rc_paranoia_check(port, tty->name, "close"))
return;

- save_flags(flags); cli();
+ local_irq_save(flags);
if (tty_hung_up_p(filp))
goto out;

@@ -1136,7 +1136,7 @@
}
port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&port->close_wait);
-out: restore_flags(flags);
+out: local_irq_restore(flags);
}

static int rc_write(struct tty_struct * tty,
@@ -1155,34 +1155,34 @@
if (!tty || !port->xmit_buf || !tmp_buf)
return 0;

- save_flags(flags);
+ local_save_flags(flags);
while (1) {
- cli();
+ local_irq_disable();
c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
SERIAL_XMIT_SIZE - port->xmit_head));
if (c <= 0) {
- restore_flags(flags);
+ local_irq_restore(flags);
break;
}

memcpy(port->xmit_buf + port->xmit_head, buf, c);
port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
port->xmit_cnt += c;
- restore_flags(flags);
+ local_irq_restore(flags);

buf += c;
count -= c;
total += c;
}

- cli();
+ local_irq_disable();
if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped &&
!(port->IER & IER_TXRDY)) {
port->IER |= IER_TXRDY;
rc_out(bp, CD180_CAR, port_No(port));
rc_out(bp, CD180_IER, port->IER);
}
- restore_flags(flags);
+ local_irq_restore(flags);

return total;
}
@@ -1198,7 +1198,7 @@
if (!tty || !port->xmit_buf)
return;

- save_flags(flags); cli();
+ local_irq_save(flags);

if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
goto out;
@@ -1206,7 +1206,7 @@
port->xmit_buf[port->xmit_head++] = ch;
port->xmit_head &= SERIAL_XMIT_SIZE - 1;
port->xmit_cnt++;
-out: restore_flags(flags);
+out: local_irq_restore(flags);
}

static void rc_flush_chars(struct tty_struct * tty)
@@ -1221,11 +1221,11 @@
!port->xmit_buf)
return;

- save_flags(flags); cli();
+ local_irq_save(flags);
port->IER |= IER_TXRDY;
rc_out(port_Board(port), CD180_CAR, port_No(port));
rc_out(port_Board(port), CD180_IER, port->IER);
- restore_flags(flags);
+ local_irq_restore(flags);
}

static int rc_write_room(struct tty_struct * tty)
@@ -1260,9 +1260,9 @@
if (rc_paranoia_check(port, tty->name, "rc_flush_buffer"))
return;

- save_flags(flags); cli();
+ local_irq_save(flags);
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
- restore_flags(flags);
+ local_irq_restore(flags);

wake_up_interruptible(&tty->write_wait);
tty_wakeup(tty);
@@ -1280,11 +1280,11 @@
return -ENODEV;

bp = port_Board(port);
- save_flags(flags); cli();
+ local_irq_save(flags);
rc_out(bp, CD180_CAR, port_No(port));
status = rc_in(bp, CD180_MSVR);
result = rc_in(bp, RC_RI) & (1u << port_No(port)) ? 0 : TIOCM_RNG;
- restore_flags(flags);
+ local_irq_restore(flags);
result |= ((status & MSVR_RTS) ? TIOCM_RTS : 0)
| ((status & MSVR_DTR) ? TIOCM_DTR : 0)
| ((status & MSVR_CD) ? TIOCM_CAR : 0)
@@ -1305,7 +1305,7 @@

bp = port_Board(port);

- save_flags(flags); cli();
+ local_irq_save(flags);
if (set & TIOCM_RTS)
port->MSVR |= MSVR_RTS;
if (set & TIOCM_DTR)
@@ -1319,7 +1319,7 @@
rc_out(bp, CD180_CAR, port_No(port));
rc_out(bp, CD180_MSVR, port->MSVR);
rc_out(bp, RC_DTR, bp->DTR);
- restore_flags(flags);
+ local_irq_restore(flags);
return 0;
}

@@ -1328,7 +1328,7 @@
struct riscom_board *bp = port_Board(port);
unsigned long flags;

- save_flags(flags); cli();
+ local_irq_save(flags);
port->break_length = RISCOM_TPS / HZ * length;
port->COR2 |= COR2_ETC;
port->IER |= IER_TXRDY;
@@ -1338,7 +1338,7 @@
rc_wait_CCR(bp);
rc_out(bp, CD180_CCR, CCR_CORCHG2);
rc_wait_CCR(bp);
- restore_flags(flags);
+ local_irq_restore(flags);
}

static inline int rc_set_serial_info(struct riscom_port * port,
@@ -1381,9 +1381,9 @@
port->closing_wait = tmp.closing_wait;
}
if (change_speed) {
- save_flags(flags); cli();
+ local_irq_save(flags);
rc_change_speed(bp, port);
- restore_flags(flags);
+ local_irq_restore(flags);
}
return 0;
}
@@ -1464,7 +1464,7 @@

bp = port_Board(port);

- save_flags(flags); cli();
+ local_irq_save(flags);
port->MSVR &= ~MSVR_RTS;
rc_out(bp, CD180_CAR, port_No(port));
if (I_IXOFF(tty)) {
@@ -1473,7 +1473,7 @@
rc_wait_CCR(bp);
}
rc_out(bp, CD180_MSVR, port->MSVR);
- restore_flags(flags);
+ local_irq_restore(flags);
}

static void rc_unthrottle(struct tty_struct * tty)
@@ -1487,7 +1487,7 @@

bp = port_Board(port);

- save_flags(flags); cli();
+ local_irq_save(flags);
port->MSVR |= MSVR_RTS;
rc_out(bp, CD180_CAR, port_No(port));
if (I_IXOFF(tty)) {
@@ -1496,7 +1496,7 @@
rc_wait_CCR(bp);
}
rc_out(bp, CD180_MSVR, port->MSVR);
- restore_flags(flags);
+ local_irq_restore(flags);
}

static void rc_stop(struct tty_struct * tty)
@@ -1510,11 +1510,11 @@

bp = port_Board(port);

- save_flags(flags); cli();
+ local_irq_save(flags);
port->IER &= ~IER_TXRDY;
rc_out(bp, CD180_CAR, port_No(port));
rc_out(bp, CD180_IER, port->IER);
- restore_flags(flags);
+ local_irq_restore(flags);
}

static void rc_start(struct tty_struct * tty)
@@ -1528,13 +1528,13 @@

bp = port_Board(port);

- save_flags(flags); cli();
+ local_irq_save(flags);
if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) {
port->IER |= IER_TXRDY;
rc_out(bp, CD180_CAR, port_No(port));
rc_out(bp, CD180_IER, port->IER);
}
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*
@@ -1586,9 +1586,9 @@
tty->termios->c_iflag == old_termios->c_iflag)
return;

- save_flags(flags); cli();
+ local_irq_save(flags);
rc_change_speed(port_Board(port), port);
- restore_flags(flags);
+ local_irq_restore(flags);

if ((old_termios->c_cflag & CRTSCTS) &&
!(tty->termios->c_cflag & CRTSCTS)) {
@@ -1684,12 +1684,11 @@
{
unsigned long flags;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
free_page((unsigned long)tmp_buf);
tty_unregister_driver(riscom_driver);
put_tty_driver(riscom_driver);
- restore_flags(flags);
+ local_irq_restore(flags);
}

#ifndef MODULE

2005-01-16 14:09:10

by James Nelson

[permalink] [raw]
Subject: [PATCH 12/13] serial_tx3912: remove cli()/sti() in drivers/char/serial_tx3912.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/serial_tx3912.c linux-2.6.11-rc1-mm1/drivers/char/serial_tx3912.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/serial_tx3912.c 2004-12-24 16:34:57.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/serial_tx3912.c 2005-01-16 07:32:19.514527630 -0500
@@ -222,7 +222,7 @@
unsigned long flags;
unsigned long ints;

- save_and_cli(flags);
+ local_irq_save(flags);

port = (struct rs_port *)dev_id;
rs_dprintk (TX3912_UART_DEBUG_INTERRUPTS, "rs_interrupt (port %p, shift %d)...", port, intshift);
@@ -241,10 +241,8 @@
INTTYPE(UART_PARITYERR_INT) |
INTTYPE(UART_RX_INT)) << intshift);

- if (!port || !port->gs.tty) {
- restore_flags(flags);
- return;
- }
+ if (!port || !port->gs.tty)
+ goto out;

/* RX Receiver Holding Register Overrun */
if (ints & INTTYPE(UART_RXOVERRUN_INT)) {
@@ -275,7 +273,7 @@
receive_char_pio(port);
}

- restore_flags(flags);
+out: local_irq_restore(flags);

rs_dprintk (TX3912_UART_DEBUG_INTERRUPTS, "end.\n");
}
@@ -288,7 +286,7 @@
unsigned long flags;
unsigned long ints;

- save_and_cli(flags);
+ local_irq_save(flags);

port = (struct rs_port *)dev_id;
rs_dprintk (TX3912_UART_DEBUG_INTERRUPTS, "rs_interrupt (port %p, shift %d)...", port, intshift);
@@ -296,10 +294,8 @@
/* Get the interrrupts we have enabled */
int2status = IntStatus2 & IntEnable2;

- if (!port || !port->gs.tty) {
- restore_flags(flags);
- return;
- }
+ if (!port || !port->gs.tty)
+ goto out;

/* Get interrupts in easy to use form */
ints = int2status >> intshift;
@@ -324,7 +320,7 @@
check_modem_status();
*/

- restore_flags(flags);
+out: local_irq_restore(flags);

rs_dprintk (TX3912_UART_DEBUG_INTERRUPTS, "end.\n");
}
@@ -352,7 +348,7 @@
struct rs_port *port = ptr;
unsigned long flags;

- save_and_cli(flags);
+ local_irq_save(flags);
port->gs.flags &= ~GS_TX_INTEN;

IntEnable2 &= ~((INTTYPE(UART_TX_INT) |
@@ -363,7 +359,7 @@
INTTYPE(UART_EMPTY_INT) |
INTTYPE(UART_TXOVERRUN_INT)) << port->intshift;

- restore_flags(flags);
+ local_irq_restore(flags);
}

static void rs_enable_tx_interrupts (void * ptr)
@@ -371,7 +367,7 @@
struct rs_port *port = ptr;
unsigned long flags;

- save_and_cli(flags);
+ local_irq_save(flags);

IntClear2 = (INTTYPE(UART_TX_INT) |
INTTYPE(UART_EMPTY_INT) |
@@ -384,7 +380,7 @@
/* Send a char to start TX interrupts happening */
transmit_char_pio(port);

- restore_flags(flags);
+ local_irq_restore(flags);
}

static void rs_disable_rx_interrupts (void * ptr)
@@ -392,7 +388,7 @@
struct rs_port *port = ptr;
unsigned long flags;

- save_and_cli(flags);
+ local_irq_save(flags);

IntEnable2 &= ~((INTTYPE(UART_RX_INT) |
INTTYPE(UART_RXOVERRUN_INT) |
@@ -406,7 +402,7 @@
INTTYPE(UART_BREAK_INT) |
INTTYPE(UART_PARITYERR_INT)) << port->intshift;

- restore_flags(flags);
+ local_irq_restore(flags);
}

static void rs_enable_rx_interrupts (void * ptr)
@@ -414,7 +410,7 @@
struct rs_port *port = ptr;
unsigned long flags;

- save_and_cli(flags);
+ local_irq_save(flags);

IntEnable2 |= (INTTYPE(UART_RX_INT) |
INTTYPE(UART_RXOVERRUN_INT) |
@@ -433,7 +429,7 @@
INTTYPE(UART_BREAK_INT) |
INTTYPE(UART_PARITYERR_INT)) << port->intshift;

- restore_flags(flags);
+ local_irq_restore(flags);
}


2005-01-16 14:13:16

by James Nelson

[permalink] [raw]
Subject: [PATCH 13/13] stallion: remove cli()/sti() in drivers/char/stallion.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/stallion.c linux-2.6.11-rc1-mm1/drivers/char/stallion.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/stallion.c 2004-12-24 16:35:23.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/stallion.c 2005-01-16 07:32:19.543523749 -0500
@@ -749,10 +749,9 @@
printk("init_module()\n");
#endif

- save_flags(flags);
- cli();
+ local_irq_save_(flags);
stl_init();
- restore_flags(flags);
+ local_irq_restore(flags);

return(0);
}
@@ -774,8 +773,7 @@
printk(KERN_INFO "Unloading %s: version %s\n", stl_drvtitle,
stl_drvversion);

- save_flags(flags);
- cli();
+ local_irq_save(flags);

/*
* Free up all allocated resources used by the ports. This includes
@@ -788,8 +786,7 @@
if (i) {
printk("STALLION: failed to un-register tty driver, "
"errno=%d\n", -i);
- restore_flags(flags);
- return;
+ goto out;
}
for (i = 0; i < 4; i++) {
devfs_remove("staliomem/%d", i);
@@ -835,7 +832,7 @@
for (i = 0; (i < stl_numintrs); i++)
free_irq(stl_gotintrs[i], NULL);

- restore_flags(flags);
+out: local_irq_restore(flags);
}

module_init(stallion_module_init);
@@ -1106,8 +1103,7 @@
if (portp->tty->termios->c_cflag & CLOCAL)
doclocal++;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
portp->openwaitcnt++;
if (! tty_hung_up_p(filp))
portp->refcount--;
@@ -1136,7 +1132,7 @@
if (! tty_hung_up_p(filp))
portp->refcount++;
portp->openwaitcnt--;
- restore_flags(flags);
+ local_irq_restore(flags);

return(rc);
}
@@ -1156,18 +1152,14 @@
if (portp == (stlport_t *) NULL)
return;

- save_flags(flags);
- cli();
- if (tty_hung_up_p(filp)) {
- restore_flags(flags);
- return;
- }
+ local_irq_save(flags);
+ if (tty_hung_up_p(filp))
+ goto out;
+
if ((tty->count == 1) && (portp->refcount != 1))
portp->refcount = 1;
- if (portp->refcount-- > 1) {
- restore_flags(flags);
- return;
- }
+ if (portp->refcount-- > 1)
+ goto out;

portp->refcount = 0;
portp->flags |= ASYNC_CLOSING;
@@ -1210,7 +1202,7 @@

portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&portp->close_wait);
- restore_flags(flags);
+out: local_irq_restore(flags);
}

/*****************************************************************************/
@@ -2934,8 +2926,7 @@
portp->stats.lflags = 0;
portp->stats.rxbuffered = 0;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
if (portp->tty != (struct tty_struct *) NULL) {
if (portp->tty->driver_data == portp) {
portp->stats.ttystate = portp->tty->flags;
@@ -2948,7 +2939,7 @@
}
}
}
- restore_flags(flags);
+ local_irq_restore(flags);

head = portp->tx.head;
tail = portp->tx.tail;
@@ -3480,8 +3471,7 @@
tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]);
#endif

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_cd1400setreg(portp, CAR, (portp->portnr & 0x3));
srer = stl_cd1400getreg(portp, SRER);
@@ -3518,7 +3508,7 @@
portp->sigs &= ~TIOCM_CD;
stl_cd1400setreg(portp, SRER, ((srer & ~sreroff) | sreron));
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -3544,8 +3534,7 @@
if (rts > 0)
msvr2 = MSVR2_RTS;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
if (rts >= 0)
@@ -3553,7 +3542,7 @@
if (dtr >= 0)
stl_cd1400setreg(portp, MSVR1, msvr1);
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -3572,14 +3561,13 @@
printk("stl_cd1400getsignals(portp=%x)\n", (int) portp);
#endif

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
msvr1 = stl_cd1400getreg(portp, MSVR1);
msvr2 = stl_cd1400getreg(portp, MSVR2);
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);

sigs = 0;
sigs |= (msvr1 & MSVR1_DCD) ? TIOCM_CD : 0;
@@ -3621,15 +3609,14 @@
else if (rx > 0)
ccr |= CCR_RXENABLE;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
stl_cd1400ccrwait(portp);
stl_cd1400setreg(portp, CCR, ccr);
stl_cd1400ccrwait(portp);
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -3661,8 +3648,7 @@
else if (rx > 0)
sreron |= SRER_RXDATA;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
stl_cd1400setreg(portp, SRER,
@@ -3670,7 +3656,7 @@
BRDDISABLE(portp->brdnr);
if (tx > 0)
set_bit(ASYI_TXBUSY, &portp->istate);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -3686,13 +3672,12 @@
#ifdef DEBUG
printk("stl_cd1400disableintrs(portp=%x)\n", (int) portp);
#endif
- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
stl_cd1400setreg(portp, SRER, 0);
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -3705,8 +3690,7 @@
printk("stl_cd1400sendbreak(portp=%x,len=%d)\n", (int) portp, len);
#endif

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
stl_cd1400setreg(portp, SRER,
@@ -3716,7 +3700,7 @@
portp->brklen = len;
if (len == 1)
portp->stats.txbreaks++;
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -3740,8 +3724,7 @@
if (tty == (struct tty_struct *) NULL)
return;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));

@@ -3781,7 +3764,7 @@
}

BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -3805,8 +3788,7 @@
if (tty == (struct tty_struct *) NULL)
return;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
if (state) {
@@ -3821,7 +3803,7 @@
stl_cd1400ccrwait(portp);
}
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -3837,8 +3819,7 @@
if (portp == (stlport_t *) NULL)
return;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
stl_cd1400ccrwait(portp);
@@ -3846,7 +3827,7 @@
stl_cd1400ccrwait(portp);
portp->tx.tail = portp->tx.head;
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -4496,8 +4477,7 @@
tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]);
#endif

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_sc26198setreg(portp, IMR, 0);
stl_sc26198updatereg(portp, MR0, mr0);
@@ -4524,7 +4504,7 @@
portp->imr = (portp->imr & ~imroff) | imron;
stl_sc26198setreg(portp, IMR, portp->imr);
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -4554,13 +4534,12 @@
else if (rts > 0)
iopioron |= IPR_RTS;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_sc26198setreg(portp, IOPIOR,
((stl_sc26198getreg(portp, IOPIOR) & ~iopioroff) | iopioron));
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -4579,12 +4558,11 @@
printk("stl_sc26198getsignals(portp=%x)\n", (int) portp);
#endif

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
ipr = stl_sc26198getreg(portp, IPR);
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);

sigs = 0;
sigs |= (ipr & IPR_DCD) ? 0 : TIOCM_CD;
@@ -4621,13 +4599,12 @@
else if (rx > 0)
ccr |= CR_RXENABLE;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_sc26198setreg(portp, SCCR, ccr);
BRDDISABLE(portp->brdnr);
portp->crenable = ccr;
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -4656,15 +4633,14 @@
else if (rx > 0)
imr |= IR_RXRDY | IR_RXBREAK | IR_RXWATCHDOG;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_sc26198setreg(portp, IMR, imr);
BRDDISABLE(portp->brdnr);
portp->imr = imr;
if (tx > 0)
set_bit(ASYI_TXBUSY, &portp->istate);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -4681,13 +4657,12 @@
printk("stl_sc26198disableintrs(portp=%x)\n", (int) portp);
#endif

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
portp->imr = 0;
stl_sc26198setreg(portp, IMR, 0);
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -4700,8 +4675,7 @@
printk("stl_sc26198sendbreak(portp=%x,len=%d)\n", (int) portp, len);
#endif

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
if (len == 1) {
stl_sc26198setreg(portp, SCCR, CR_TXSTARTBREAK);
@@ -4710,7 +4684,7 @@
stl_sc26198setreg(portp, SCCR, CR_TXSTOPBREAK);
}
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -4735,8 +4709,7 @@
if (tty == (struct tty_struct *) NULL)
return;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);

if (state) {
@@ -4782,7 +4755,7 @@
}

BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -4807,8 +4780,7 @@
if (tty == (struct tty_struct *) NULL)
return;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
if (state) {
mr0 = stl_sc26198getreg(portp, MR0);
@@ -4828,7 +4800,7 @@
stl_sc26198setreg(portp, MR0, mr0);
}
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -4844,14 +4816,13 @@
if (portp == (stlport_t *) NULL)
return;

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
stl_sc26198setreg(portp, SCCR, CR_TXRESET);
stl_sc26198setreg(portp, SCCR, portp->crenable);
BRDDISABLE(portp->brdnr);
portp->tx.tail = portp->tx.head;
- restore_flags(flags);
+ local_irq_restore(flags);
}

/*****************************************************************************/
@@ -4878,12 +4849,11 @@
if (test_bit(ASYI_TXBUSY, &portp->istate))
return(1);

- save_flags(flags);
- cli();
+ local_irq_save(flags);
BRDENABLE(portp->brdnr, portp->pagenr);
sr = stl_sc26198getreg(portp, SR);
BRDDISABLE(portp->brdnr);
- restore_flags(flags);
+ local_irq_restore(flags);

return((sr & SR_TXEMPTY) ? 0 : 1);
}

2005-01-16 14:00:58

by James Nelson

[permalink] [raw]
Subject: [PATCH 8/13] ite_gpio: remove cli()/sti() in drivers/char/ite_gpio.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/ite_gpio.c linux-2.6.11-rc1-mm1/drivers/char/ite_gpio.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/ite_gpio.c 2004-12-24 16:35:15.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/ite_gpio.c 2005-01-16 07:32:19.328552523 -0500
@@ -218,11 +218,10 @@
if (ite_gpio_irq_pending[i]==1)
return -EFAULT;

- save_flags (flags);
- cli();
+ local_irq_save(flags);
ite_gpio_irq_pending[i] = 1;
ret = interruptible_sleep_on_timeout(&ite_gpio_wait[i], 3*HZ);
- restore_flags (flags);
+ local_irq_restore(flags);
ite_gpio_irq_pending[i] = 0;

return ret;

2005-01-16 13:58:49

by James Nelson

[permalink] [raw]
Subject: [PATCH 5/13] generic_serial: remove cli()/sti() in drivers/char/generic_serial.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/generic_serial.c linux-2.6.11-rc1-mm1/drivers/char/generic_serial.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/generic_serial.c 2005-01-16 07:19:12.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/generic_serial.c 2005-01-16 07:32:19.299556404 -0500
@@ -53,8 +53,8 @@
#define RELEASEIT up (&port->port_write_sem);
#else
#define DECL unsigned long flags;
-#define LOCKIT save_flags (flags);cli ()
-#define RELEASEIT restore_flags (flags)
+#define LOCKIT local_irq_save (flags)
+#define RELEASEIT local_irq_restore (flags)
#endif

#define RS_EVENT_WRITE_WAKEUP 1
@@ -211,7 +211,7 @@

local_save_flags(flags);
while (1) {
- cli();
+ local_irq_disable();
c = count;

/* This is safe because we "OWN" the "head". Noone else can

2005-01-16 13:58:49

by James Nelson

[permalink] [raw]
Subject: [PATCH 4/13] ftape: remove cli()/sti() in drivers/char/ftape/lowlevel/ftape-io.c

Signed-off-by: James Nelson <[email protected]>

diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/ftape/lowlevel/ftape-io.c linux-2.6.11-rc1-mm1/drivers/char/ftape/lowlevel/ftape-io.c
--- linux-2.6.11-rc1-mm1-original/drivers/char/ftape/lowlevel/ftape-io.c 2005-01-16 07:17:19.000000000 -0500
+++ linux-2.6.11-rc1-mm1/drivers/char/ftape/lowlevel/ftape-io.c 2005-01-16 07:32:19.293557207 -0500
@@ -95,15 +95,15 @@

TRACE(ft_t_any, "%d msec, %d ticks", time/1000, ticks);
timeout = ticks;
- save_flags(flags);
- sti();
+ local_save_flags(flags);
+ local_irq_enable();
msleep_interruptible(jiffies_to_msecs(timeout));
/* Mmm. Isn't current->blocked == 0xffffffff ?
*/
if (signal_pending(current)) {
TRACE(ft_t_err, "awoken by non-blocked signal :-(");
}
- restore_flags(flags);
+ local_irq_restore(flags);
}
TRACE_EXIT;
}

2005-01-16 19:33:25

by Randy.Dunlap

[permalink] [raw]
Subject: Re: [PATCH 0/13] remove cli()/sti() in drivers/char/*

James Nelson wrote:
> This series of patches removes the last cli()/sti()/save_flags()/restore_flags()
> function calls in drivers/char.

to what end?

I guess I don't get it. What makes these drivers SMP-safe now?

Or is this series of patches only done to kill off the use
of deprecated functions? If that's the case, they could
easily give someone the (false) expectation that the drivers
are SMP-safe, couldn't they? Well, ftape (for one) is still
marked as BROKEN_ON_SMP, but will people know why it's
marked that way?

Have you read Documentation/cli-sti-removal.txt ?

--
~Randy

2005-01-16 20:13:40

by James Nelson

[permalink] [raw]
Subject: Re: [PATCH 0/13] remove cli()/sti() in drivers/char/*

Randy.Dunlap wrote:
> James Nelson wrote:
>
>> This series of patches removes the last
>> cli()/sti()/save_flags()/restore_flags()
>> function calls in drivers/char.
>
>
> to what end?
>
> I guess I don't get it. What makes these drivers SMP-safe now?
>
> Or is this series of patches only done to kill off the use
> of deprecated functions? If that's the case, they could
> easily give someone the (false) expectation that the drivers
> are SMP-safe, couldn't they? Well, ftape (for one) is still
> marked as BROKEN_ON_SMP, but will people know why it's
> marked that way?
>
> Have you read Documentation/cli-sti-removal.txt ?
>
I have. This is just to get rid of the deprecated functions - most of this stuff
is already marked BROKEN_ON_SMP (stallion, serial_tx3912, epca, esp, istallion,
riscom8, ftape, pcxx and moxa), and ite_gpio.c is a driver for a UP system board.

Maybe later (when I have more of an understanding of serial_core, and major driver
overhaul) I can tackle actually fixing them, but right now, I'm just doing cleanup
work.

Jim

2005-01-16 21:05:28

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 0/13] remove cli()/sti() in drivers/char/*

James Nelson <[email protected]> wrote:
>
> This series of patches removes the last cli()/sti()/save_flags()/restore_flags()
> function calls in drivers/char.

I don't see much point in this, really. Those cli() calls are a big fat
sign saying "broken on smp" and they now generate compile-time warnings
emphasising that. These drivers still need to be fixed up - we may las
well leave them as-is until someone gets onto doing that.

2005-01-16 22:18:45

by Alan

[permalink] [raw]
Subject: Re: [PATCH 0/13] remove cli()/sti() in drivers/char/*

On Sul, 2005-01-16 at 21:04, Andrew Morton wrote:
> James Nelson <[email protected]> wrote:
> >
> > This series of patches removes the last cli()/sti()/save_flags()/restore_flags()
> > function calls in drivers/char.
>
> I don't see much point in this, really. Those cli() calls are a big fat
> sign saying "broken on smp" and they now generate compile-time warnings
> emphasising that. These drivers still need to be fixed up - we may las
> well leave them as-is until someone gets onto doing that.

Please drop all the serial ones. I'm slowly working through the serial
drivers that are relevant to any kind of users and fixing them up or
importing fixes from vendor branches as appropriate.

Simple substitions don't work here, and in some cases even simple tty
device locks because many cards are chip level interfaces not port
level.

Alan

2005-01-16 22:18:44

by Alan

[permalink] [raw]
Subject: Re: [PATCH 3/13] ftape: remove cli()/sti() in drivers/char/ftape/lowlevel/ftape-format.c

On Sul, 2005-01-16 at 13:52, James Nelson wrote:
> Signed-off-by: James Nelson <[email protected]>
>
> diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/ftape/lowlevel/ftape-format.c linux-2.6.11-rc1-mm1/drivers/char/ftape/lowlevel/ftape-format.c
> --- linux-2.6.11-rc1-mm1-original/drivers/char/ftape/lowlevel/ftape-format.c 2004-12-24 16:34:45.000000000 -0500
> +++ linux-2.6.11-rc1-mm1/drivers/char/ftape/lowlevel/ftape-format.c 2005-01-16 07:32:19.293557207 -0500
> @@ -132,7 +132,7 @@
> TRACE_CATCH(ftape_seek_head_to_track(track),);
> TRACE_CATCH(ftape_command(QIC_LOGICAL_FORWARD),);
> spin_lock_irqsave(&ftape_format_lock, flags);
> - TRACE_CATCH(fdc_setup_formatting(head), restore_flags(flags));
> + TRACE_CATCH(fdc_setup_formatting(head),);
> spin_unlock_irqrestore(&ftape_format_lock, flags);

This is wrong (the original is too). TRACE_CATCH expands into code
including a return so you need to replace the retore_flags(flags) with a
copy of the spin_unlock_irqrestore line below

2005-01-16 22:23:46

by Alan

[permalink] [raw]
Subject: Re: [PATCH 4/13] ftape: remove cli()/sti() in drivers/char/ftape/lowlevel/ftape-io.c

On Sul, 2005-01-16 at 13:52, James Nelson wrote:
> Signed-off-by: James Nelson <[email protected]>
>
> diff -urN --exclude='*~' linux-2.6.11-rc1-mm1-original/drivers/char/ftape/lowlevel/ftape-io.c linux-2.6.11-rc1-mm1/drivers/char/ftape/lowlevel/ftape-io.c
> --- linux-2.6.11-rc1-mm1-original/drivers/char/ftape/lowlevel/ftape-io.c 2005-01-16 07:17:19.000000000 -0500
> +++ linux-2.6.11-rc1-mm1/drivers/char/ftape/lowlevel/ftape-io.c 2005-01-16 07:32:19.293557207 -0500
> @@ -95,15 +95,15 @@
>
> TRACE(ft_t_any, "%d msec, %d ticks", time/1000, ticks);
> timeout = ticks;
> - save_flags(flags);
> - sti();
> + local_save_flags(flags);
> + local_irq_enable();
> msleep_interruptible(jiffies_to_msecs(timeout));

This doesn't deal with SMP - please reject

2005-01-16 22:35:17

by James Nelson

[permalink] [raw]
Subject: Re: [PATCH 0/13] remove cli()/sti() in drivers/char/*

Alan Cox wrote:
> On Sul, 2005-01-16 at 21:04, Andrew Morton wrote:
>
>>James Nelson <[email protected]> wrote:
>>
>>>This series of patches removes the last cli()/sti()/save_flags()/restore_flags()
>>> function calls in drivers/char.
>>
>>I don't see much point in this, really. Those cli() calls are a big fat
>>sign saying "broken on smp" and they now generate compile-time warnings
>>emphasising that. These drivers still need to be fixed up - we may las
>>well leave them as-is until someone gets onto doing that.
>
>
> Please drop all the serial ones. I'm slowly working through the serial
> drivers that are relevant to any kind of users and fixing them up or
> importing fixes from vendor branches as appropriate.
>
> Simple substitions don't work here, and in some cases even simple tty
> device locks because many cards are chip level interfaces not port
> level.
>
> Alan
>
>

Right. Please disregard this set of patches - I think I'm done flogging this
directory for awhile :)