Commit a44b508a authored by Roberta Dobrescu's avatar Roberta Dobrescu Committed by Greg Kroah-Hartman

staging: dgnc: dgnc_tty.c: Replace non-standard spinlock's macros

This patch replaces non-standard spinlock's macros.
It is done using coccinelle and the following semantic patch:

@@
expression x;
@@

- DGNC_SPINLOCK_INIT(x)
+ spin_lock_init(&x)

@@
expression x, y;
@@

- DGNC_LOCK(x, y)
+ spin_lock_irqsave(&x, y)

@@
expression x, y;
@@

- DGNC_UNLOCK(x, y)
+ spin_unlock_irqrestore(&x, y)

@used_by_lock exists@
typedef ulong;
symbol lock_flags;
position p1, p2;
@@

(
 ulong lock_flags@p1;
|
 unsigned long lock_flags@p2;
)
...
(
 spin_lock_irqsave(..., lock_flags)
|
 spin_unlock_irqrestore(..., lock_flags)
)

@@
position used_by_lock.p1, used_by_lock.p2;
@@

(
- ulong lock_flags@p1;
+ unsigned long flags;
|
- unsigned long lock_flags@p2;
+ unsigned long flags;
)
<...
- lock_flags
+ flags
...>
Signed-off-by: default avatarRoberta Dobrescu <roberta.dobrescu@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9a03d7c8
...@@ -342,7 +342,7 @@ int dgnc_tty_init(struct dgnc_board *brd) ...@@ -342,7 +342,7 @@ int dgnc_tty_init(struct dgnc_board *brd)
if (!brd->channels[i]) if (!brd->channels[i])
continue; continue;
DGNC_SPINLOCK_INIT(ch->ch_lock); spin_lock_init(&ch->ch_lock);
/* Store all our magic numbers */ /* Store all our magic numbers */
ch->magic = DGNC_CHANNEL_MAGIC; ch->magic = DGNC_CHANNEL_MAGIC;
...@@ -631,7 +631,7 @@ void dgnc_input(struct channel_t *ch) ...@@ -631,7 +631,7 @@ void dgnc_input(struct channel_t *ch)
ushort head; ushort head;
ushort tail; ushort tail;
int data_len; int data_len;
ulong lock_flags; unsigned long flags;
int flip_len; int flip_len;
int len = 0; int len = 0;
int n = 0; int n = 0;
...@@ -647,7 +647,7 @@ void dgnc_input(struct channel_t *ch) ...@@ -647,7 +647,7 @@ void dgnc_input(struct channel_t *ch)
if (!bd || bd->magic != DGNC_BOARD_MAGIC) if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return; return;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
/* /*
* Figure the number of characters in the buffer. * Figure the number of characters in the buffer.
...@@ -659,7 +659,7 @@ void dgnc_input(struct channel_t *ch) ...@@ -659,7 +659,7 @@ void dgnc_input(struct channel_t *ch)
data_len = (head - tail) & rmask; data_len = (head - tail) & rmask;
if (data_len == 0) { if (data_len == 0) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return; return;
} }
...@@ -675,7 +675,7 @@ void dgnc_input(struct channel_t *ch) ...@@ -675,7 +675,7 @@ void dgnc_input(struct channel_t *ch)
/* Force queue flow control to be released, if needed */ /* Force queue flow control to be released, if needed */
dgnc_check_queue_flow_control(ch); dgnc_check_queue_flow_control(ch);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return; return;
} }
...@@ -683,7 +683,7 @@ void dgnc_input(struct channel_t *ch) ...@@ -683,7 +683,7 @@ void dgnc_input(struct channel_t *ch)
* If we are throttled, simply don't read any data. * If we are throttled, simply don't read any data.
*/ */
if (ch->ch_flags & CH_FORCED_STOPI) { if (ch->ch_flags & CH_FORCED_STOPI) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return; return;
} }
...@@ -724,7 +724,7 @@ void dgnc_input(struct channel_t *ch) ...@@ -724,7 +724,7 @@ void dgnc_input(struct channel_t *ch)
} }
if (len <= 0) { if (len <= 0) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
if (ld) if (ld)
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
return; return;
...@@ -791,7 +791,7 @@ void dgnc_input(struct channel_t *ch) ...@@ -791,7 +791,7 @@ void dgnc_input(struct channel_t *ch)
ch->ch_r_tail = tail & rmask; ch->ch_r_tail = tail & rmask;
ch->ch_e_tail = tail & rmask; ch->ch_e_tail = tail & rmask;
dgnc_check_queue_flow_control(ch); dgnc_check_queue_flow_control(ch);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
/* Tell the tty layer its okay to "eat" the data now */ /* Tell the tty layer its okay to "eat" the data now */
tty_flip_buffer_push(tp->port); tty_flip_buffer_push(tp->port);
...@@ -1052,12 +1052,12 @@ void dgnc_check_queue_flow_control(struct channel_t *ch) ...@@ -1052,12 +1052,12 @@ void dgnc_check_queue_flow_control(struct channel_t *ch)
void dgnc_wakeup_writes(struct channel_t *ch) void dgnc_wakeup_writes(struct channel_t *ch)
{ {
int qlen = 0; int qlen = 0;
ulong lock_flags; unsigned long flags;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return; return;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
/* /*
* If channel now has space, wake up anyone waiting on the condition. * If channel now has space, wake up anyone waiting on the condition.
...@@ -1067,16 +1067,16 @@ void dgnc_wakeup_writes(struct channel_t *ch) ...@@ -1067,16 +1067,16 @@ void dgnc_wakeup_writes(struct channel_t *ch)
qlen += WQUEUESIZE; qlen += WQUEUESIZE;
if (qlen >= (WQUEUESIZE - 256)) { if (qlen >= (WQUEUESIZE - 256)) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return; return;
} }
if (ch->ch_tun.un_flags & UN_ISOPEN) { if (ch->ch_tun.un_flags & UN_ISOPEN) {
if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
ch->ch_tun.un_tty->ldisc->ops->write_wakeup) { ch->ch_tun.un_tty->ldisc->ops->write_wakeup) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
(ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty);
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
} }
wake_up_interruptible(&ch->ch_tun.un_tty->write_wait); wake_up_interruptible(&ch->ch_tun.un_tty->write_wait);
...@@ -1115,9 +1115,9 @@ void dgnc_wakeup_writes(struct channel_t *ch) ...@@ -1115,9 +1115,9 @@ void dgnc_wakeup_writes(struct channel_t *ch)
if (ch->ch_pun.un_flags & UN_ISOPEN) { if (ch->ch_pun.un_flags & UN_ISOPEN) {
if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
ch->ch_pun.un_tty->ldisc->ops->write_wakeup) { ch->ch_pun.un_tty->ldisc->ops->write_wakeup) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
(ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty);
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
} }
wake_up_interruptible(&ch->ch_pun.un_tty->write_wait); wake_up_interruptible(&ch->ch_pun.un_tty->write_wait);
...@@ -1135,7 +1135,7 @@ void dgnc_wakeup_writes(struct channel_t *ch) ...@@ -1135,7 +1135,7 @@ void dgnc_wakeup_writes(struct channel_t *ch)
wake_up_interruptible(&ch->ch_pun.un_flags_wait); wake_up_interruptible(&ch->ch_pun.un_flags_wait);
} }
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
} }
...@@ -1158,7 +1158,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) ...@@ -1158,7 +1158,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
uint major = 0; uint major = 0;
uint minor = 0; uint minor = 0;
int rc = 0; int rc = 0;
ulong lock_flags; unsigned long flags;
rc = 0; rc = 0;
...@@ -1183,25 +1183,25 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) ...@@ -1183,25 +1183,25 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
if (rc) if (rc)
return rc; return rc;
DGNC_LOCK(brd->bd_lock, lock_flags); spin_lock_irqsave(&brd->bd_lock, flags);
/* If opened device is greater than our number of ports, bail. */ /* If opened device is greater than our number of ports, bail. */
if (PORT_NUM(minor) > brd->nasync) { if (PORT_NUM(minor) > brd->nasync) {
DGNC_UNLOCK(brd->bd_lock, lock_flags); spin_unlock_irqrestore(&brd->bd_lock, flags);
return -ENXIO; return -ENXIO;
} }
ch = brd->channels[PORT_NUM(minor)]; ch = brd->channels[PORT_NUM(minor)];
if (!ch) { if (!ch) {
DGNC_UNLOCK(brd->bd_lock, lock_flags); spin_unlock_irqrestore(&brd->bd_lock, flags);
return -ENXIO; return -ENXIO;
} }
/* Drop board lock */ /* Drop board lock */
DGNC_UNLOCK(brd->bd_lock, lock_flags); spin_unlock_irqrestore(&brd->bd_lock, flags);
/* Grab channel lock */ /* Grab channel lock */
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
/* Figure out our type */ /* Figure out our type */
if (!IS_PRINT(minor)) { if (!IS_PRINT(minor)) {
...@@ -1211,7 +1211,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) ...@@ -1211,7 +1211,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
un = &brd->channels[PORT_NUM(minor)]->ch_pun; un = &brd->channels[PORT_NUM(minor)]->ch_pun;
un->un_type = DGNC_PRINT; un->un_type = DGNC_PRINT;
} else { } else {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return -ENXIO; return -ENXIO;
} }
...@@ -1220,7 +1220,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) ...@@ -1220,7 +1220,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
* where we simply cannot safely keep going, wait until the * where we simply cannot safely keep going, wait until the
* state clears. * state clears.
*/ */
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = wait_event_interruptible(ch->ch_flags_wait, ((ch->ch_flags & CH_OPENING) == 0)); rc = wait_event_interruptible(ch->ch_flags_wait, ((ch->ch_flags & CH_OPENING) == 0));
...@@ -1242,7 +1242,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) ...@@ -1242,7 +1242,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
if (rc) if (rc)
return -EINTR; return -EINTR;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
/* Store our unit into driver_data, so we always have it available. */ /* Store our unit into driver_data, so we always have it available. */
...@@ -1267,7 +1267,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) ...@@ -1267,7 +1267,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
ch->ch_flags |= (CH_OPENING); ch->ch_flags |= (CH_OPENING);
/* Drop locks, as malloc with GFP_KERNEL can sleep */ /* Drop locks, as malloc with GFP_KERNEL can sleep */
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
if (!ch->ch_rqueue) if (!ch->ch_rqueue)
ch->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL); ch->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL);
...@@ -1276,7 +1276,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) ...@@ -1276,7 +1276,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
if (!ch->ch_wqueue) if (!ch->ch_wqueue)
ch->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL); ch->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL);
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_flags &= ~(CH_OPENING); ch->ch_flags &= ~(CH_OPENING);
wake_up_interruptible(&ch->ch_flags_wait); wake_up_interruptible(&ch->ch_flags_wait);
...@@ -1335,16 +1335,16 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) ...@@ -1335,16 +1335,16 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
* follow protocol for opening port * follow protocol for opening port
*/ */
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = dgnc_block_til_ready(tty, file, ch); rc = dgnc_block_til_ready(tty, file, ch);
/* No going back now, increment our unit and channel counters */ /* No going back now, increment our unit and channel counters */
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_open_count++; ch->ch_open_count++;
un->un_open_count++; un->un_open_count++;
un->un_flags |= (UN_ISOPEN); un->un_flags |= (UN_ISOPEN);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return rc; return rc;
} }
...@@ -1359,7 +1359,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc ...@@ -1359,7 +1359,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc
{ {
int retval = 0; int retval = 0;
struct un_t *un = NULL; struct un_t *un = NULL;
ulong lock_flags; unsigned long flags;
uint old_flags = 0; uint old_flags = 0;
int sleep_on_un_flags = 0; int sleep_on_un_flags = 0;
...@@ -1371,7 +1371,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc ...@@ -1371,7 +1371,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc
if (!un || un->magic != DGNC_UNIT_MAGIC) if (!un || un->magic != DGNC_UNIT_MAGIC)
return -ENXIO; return -ENXIO;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_wopen++; ch->ch_wopen++;
...@@ -1451,7 +1451,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc ...@@ -1451,7 +1451,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc
* eventually goes active. * eventually goes active.
*/ */
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
/* /*
* Wait for something in the flags to change from the current value. * Wait for something in the flags to change from the current value.
...@@ -1467,12 +1467,12 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc ...@@ -1467,12 +1467,12 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc
* We got woken up for some reason. * We got woken up for some reason.
* Before looping around, grab our channel lock. * Before looping around, grab our channel lock.
*/ */
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
} }
ch->ch_wopen--; ch->ch_wopen--;
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
if (retval) if (retval)
return retval; return retval;
...@@ -1513,7 +1513,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) ...@@ -1513,7 +1513,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file)
struct dgnc_board *bd; struct dgnc_board *bd;
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
ulong lock_flags; unsigned long flags;
int rc = 0; int rc = 0;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
...@@ -1533,7 +1533,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) ...@@ -1533,7 +1533,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file)
ts = &tty->termios; ts = &tty->termios;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
/* /*
* Determine if this is the last close or not - and if we agree about * Determine if this is the last close or not - and if we agree about
...@@ -1559,7 +1559,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) ...@@ -1559,7 +1559,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file)
ch->ch_open_count--; ch->ch_open_count--;
if (ch->ch_open_count && un->un_open_count) { if (ch->ch_open_count && un->un_open_count) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return; return;
} }
...@@ -1586,7 +1586,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) ...@@ -1586,7 +1586,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file)
ch->ch_flags &= ~CH_PRON; ch->ch_flags &= ~CH_PRON;
} }
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
/* wait for output to drain */ /* wait for output to drain */
/* This will also return if we take an interrupt */ /* This will also return if we take an interrupt */
...@@ -1595,7 +1595,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) ...@@ -1595,7 +1595,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file)
dgnc_tty_flush_buffer(tty); dgnc_tty_flush_buffer(tty);
tty_ldisc_flush(tty); tty_ldisc_flush(tty);
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
tty->closing = 0; tty->closing = 0;
...@@ -1613,9 +1613,10 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) ...@@ -1613,9 +1613,10 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file)
* have been dropped for modems to see it. * have been dropped for modems to see it.
*/ */
if (ch->ch_close_delay) { if (ch->ch_close_delay) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock,
flags);
dgnc_ms_sleep(ch->ch_close_delay); dgnc_ms_sleep(ch->ch_close_delay);
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
} }
} }
...@@ -1640,7 +1641,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) ...@@ -1640,7 +1641,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file)
wake_up_interruptible(&ch->ch_flags_wait); wake_up_interruptible(&ch->ch_flags_wait);
wake_up_interruptible(&un->un_flags_wait); wake_up_interruptible(&un->un_flags_wait);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
} }
...@@ -1660,7 +1661,7 @@ static int dgnc_tty_chars_in_buffer(struct tty_struct *tty) ...@@ -1660,7 +1661,7 @@ static int dgnc_tty_chars_in_buffer(struct tty_struct *tty)
ushort ttail; ushort ttail;
uint tmask; uint tmask;
uint chars = 0; uint chars = 0;
ulong lock_flags = 0; unsigned long flags;
if (tty == NULL) if (tty == NULL)
return 0; return 0;
...@@ -1673,13 +1674,13 @@ static int dgnc_tty_chars_in_buffer(struct tty_struct *tty) ...@@ -1673,13 +1674,13 @@ static int dgnc_tty_chars_in_buffer(struct tty_struct *tty)
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return 0; return 0;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
tmask = WQUEUEMASK; tmask = WQUEUEMASK;
thead = ch->ch_w_head & tmask; thead = ch->ch_w_head & tmask;
ttail = ch->ch_w_tail & tmask; ttail = ch->ch_w_tail & tmask;
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
if (ttail == thead) { if (ttail == thead) {
chars = 0; chars = 0;
...@@ -1763,7 +1764,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty) ...@@ -1763,7 +1764,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty)
ushort tail; ushort tail;
ushort tmask; ushort tmask;
int ret = 0; int ret = 0;
ulong lock_flags = 0; unsigned long flags;
if (tty == NULL || dgnc_TmpWriteBuf == NULL) if (tty == NULL || dgnc_TmpWriteBuf == NULL)
return 0; return 0;
...@@ -1776,7 +1777,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty) ...@@ -1776,7 +1777,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty)
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return 0; return 0;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
tmask = WQUEUEMASK; tmask = WQUEUEMASK;
head = (ch->ch_w_head) & tmask; head = (ch->ch_w_head) & tmask;
...@@ -1805,7 +1806,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty) ...@@ -1805,7 +1806,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty)
if (ret < 0) if (ret < 0)
ret = 0; ret = 0;
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return ret; return ret;
} }
...@@ -1841,7 +1842,7 @@ static int dgnc_tty_write(struct tty_struct *tty, ...@@ -1841,7 +1842,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
struct un_t *un = NULL; struct un_t *un = NULL;
int bufcount = 0, n = 0; int bufcount = 0, n = 0;
int orig_count = 0; int orig_count = 0;
ulong lock_flags; unsigned long flags;
ushort head; ushort head;
ushort tail; ushort tail;
ushort tmask; ushort tmask;
...@@ -1869,7 +1870,7 @@ static int dgnc_tty_write(struct tty_struct *tty, ...@@ -1869,7 +1870,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
*/ */
orig_count = count; orig_count = count;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
/* Get our space available for the channel from the board */ /* Get our space available for the channel from the board */
tmask = WQUEUEMASK; tmask = WQUEUEMASK;
...@@ -1896,7 +1897,7 @@ static int dgnc_tty_write(struct tty_struct *tty, ...@@ -1896,7 +1897,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
* Bail if no space left. * Bail if no space left.
*/ */
if (count <= 0) { if (count <= 0) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
} }
...@@ -1926,7 +1927,7 @@ static int dgnc_tty_write(struct tty_struct *tty, ...@@ -1926,7 +1927,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
* If there is nothing left to copy, or I can't handle any more data, leave. * If there is nothing left to copy, or I can't handle any more data, leave.
*/ */
if (count <= 0) { if (count <= 0) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
} }
...@@ -1934,7 +1935,7 @@ static int dgnc_tty_write(struct tty_struct *tty, ...@@ -1934,7 +1935,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
count = min(count, WRITEBUFLEN); count = min(count, WRITEBUFLEN);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
/* /*
* If data is coming from user space, copy it into a temporary * If data is coming from user space, copy it into a temporary
...@@ -1956,7 +1957,7 @@ static int dgnc_tty_write(struct tty_struct *tty, ...@@ -1956,7 +1957,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
return -EFAULT; return -EFAULT;
} }
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
buf = dgnc_TmpWriteBuf; buf = dgnc_TmpWriteBuf;
...@@ -2001,10 +2002,10 @@ static int dgnc_tty_write(struct tty_struct *tty, ...@@ -2001,10 +2002,10 @@ static int dgnc_tty_write(struct tty_struct *tty,
} }
if (from_user) { if (from_user) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
up(&dgnc_TmpWriteSem); up(&dgnc_TmpWriteSem);
} else { } else {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
} }
if (count) { if (count) {
...@@ -2029,7 +2030,7 @@ static int dgnc_tty_tiocmget(struct tty_struct *tty) ...@@ -2029,7 +2030,7 @@ static int dgnc_tty_tiocmget(struct tty_struct *tty)
struct un_t *un; struct un_t *un;
int result = -EIO; int result = -EIO;
uchar mstat = 0; uchar mstat = 0;
ulong lock_flags; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return result; return result;
...@@ -2042,11 +2043,11 @@ static int dgnc_tty_tiocmget(struct tty_struct *tty) ...@@ -2042,11 +2043,11 @@ static int dgnc_tty_tiocmget(struct tty_struct *tty)
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return result; return result;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
mstat = (ch->ch_mostat | ch->ch_mistat); mstat = (ch->ch_mostat | ch->ch_mistat);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
result = 0; result = 0;
...@@ -2080,7 +2081,7 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty, ...@@ -2080,7 +2081,7 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty,
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
int ret = -EIO; int ret = -EIO;
ulong lock_flags; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return ret; return ret;
...@@ -2097,7 +2098,7 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty, ...@@ -2097,7 +2098,7 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty,
if (!bd || bd->magic != DGNC_BOARD_MAGIC) if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return ret; return ret;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
if (set & TIOCM_RTS) if (set & TIOCM_RTS)
ch->ch_mostat |= UART_MCR_RTS; ch->ch_mostat |= UART_MCR_RTS;
...@@ -2113,7 +2114,7 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty, ...@@ -2113,7 +2114,7 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty,
ch->ch_bd->bd_ops->assert_modem_signals(ch); ch->ch_bd->bd_ops->assert_modem_signals(ch);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
} }
...@@ -2130,7 +2131,7 @@ static int dgnc_tty_send_break(struct tty_struct *tty, int msec) ...@@ -2130,7 +2131,7 @@ static int dgnc_tty_send_break(struct tty_struct *tty, int msec)
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
int ret = -EIO; int ret = -EIO;
ulong lock_flags; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return ret; return ret;
...@@ -2158,11 +2159,11 @@ static int dgnc_tty_send_break(struct tty_struct *tty, int msec) ...@@ -2158,11 +2159,11 @@ static int dgnc_tty_send_break(struct tty_struct *tty, int msec)
break; break;
} }
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_bd->bd_ops->send_break(ch, msec); ch->ch_bd->bd_ops->send_break(ch, msec);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
...@@ -2212,7 +2213,7 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, char c) ...@@ -2212,7 +2213,7 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, char c)
struct dgnc_board *bd; struct dgnc_board *bd;
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
ulong lock_flags; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return; return;
...@@ -2231,9 +2232,9 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, char c) ...@@ -2231,9 +2232,9 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, char c)
dev_dbg(tty->dev, "dgnc_tty_send_xchar start\n"); dev_dbg(tty->dev, "dgnc_tty_send_xchar start\n");
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
bd->bd_ops->send_immediate_char(ch, c); bd->bd_ops->send_immediate_char(ch, c);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
dev_dbg(tty->dev, "dgnc_tty_send_xchar finish\n"); dev_dbg(tty->dev, "dgnc_tty_send_xchar finish\n");
return; return;
...@@ -2249,16 +2250,16 @@ static inline int dgnc_get_mstat(struct channel_t *ch) ...@@ -2249,16 +2250,16 @@ static inline int dgnc_get_mstat(struct channel_t *ch)
{ {
unsigned char mstat; unsigned char mstat;
int result = -EIO; int result = -EIO;
ulong lock_flags; unsigned long flags;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return -ENXIO; return -ENXIO;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
mstat = (ch->ch_mostat | ch->ch_mistat); mstat = (ch->ch_mostat | ch->ch_mistat);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
result = 0; result = 0;
...@@ -2311,7 +2312,7 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns ...@@ -2311,7 +2312,7 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns
struct un_t *un; struct un_t *un;
int ret = -ENXIO; int ret = -ENXIO;
unsigned int arg = 0; unsigned int arg = 0;
ulong lock_flags; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return ret; return ret;
...@@ -2371,11 +2372,11 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns ...@@ -2371,11 +2372,11 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns
return -EINVAL; return -EINVAL;
} }
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_bd->bd_ops->assert_modem_signals(ch); ch->ch_bd->bd_ops->assert_modem_signals(ch);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
} }
...@@ -2394,7 +2395,7 @@ static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retin ...@@ -2394,7 +2395,7 @@ static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retin
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
struct digi_t tmp; struct digi_t tmp;
ulong lock_flags; unsigned long flags;
if (!retinfo) if (!retinfo)
return -EFAULT; return -EFAULT;
...@@ -2412,9 +2413,9 @@ static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retin ...@@ -2412,9 +2413,9 @@ static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retin
memset(&tmp, 0, sizeof(tmp)); memset(&tmp, 0, sizeof(tmp));
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
memcpy(&tmp, &ch->ch_digi, sizeof(tmp)); memcpy(&tmp, &ch->ch_digi, sizeof(tmp));
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
return -EFAULT; return -EFAULT;
...@@ -2437,7 +2438,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i ...@@ -2437,7 +2438,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
struct digi_t new_digi; struct digi_t new_digi;
ulong lock_flags; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return -EFAULT; return -EFAULT;
...@@ -2457,7 +2458,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i ...@@ -2457,7 +2458,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i
if (copy_from_user(&new_digi, new_info, sizeof(new_digi))) if (copy_from_user(&new_digi, new_info, sizeof(new_digi)))
return -EFAULT; return -EFAULT;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
/* /*
* Handle transistions to and from RTS Toggle. * Handle transistions to and from RTS Toggle.
...@@ -2500,7 +2501,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i ...@@ -2500,7 +2501,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i
ch->ch_bd->bd_ops->param(tty); ch->ch_bd->bd_ops->param(tty);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
} }
...@@ -2514,7 +2515,7 @@ static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te ...@@ -2514,7 +2515,7 @@ static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te
struct dgnc_board *bd; struct dgnc_board *bd;
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
unsigned long lock_flags; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return; return;
...@@ -2531,7 +2532,7 @@ static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te ...@@ -2531,7 +2532,7 @@ static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te
if (!bd || bd->magic != DGNC_BOARD_MAGIC) if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return; return;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_c_cflag = tty->termios.c_cflag; ch->ch_c_cflag = tty->termios.c_cflag;
ch->ch_c_iflag = tty->termios.c_iflag; ch->ch_c_iflag = tty->termios.c_iflag;
...@@ -2543,7 +2544,7 @@ static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te ...@@ -2543,7 +2544,7 @@ static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te
ch->ch_bd->bd_ops->param(tty); ch->ch_bd->bd_ops->param(tty);
dgnc_carrier(ch); dgnc_carrier(ch);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
} }
...@@ -2551,7 +2552,7 @@ static void dgnc_tty_throttle(struct tty_struct *tty) ...@@ -2551,7 +2552,7 @@ static void dgnc_tty_throttle(struct tty_struct *tty)
{ {
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
ulong lock_flags = 0; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return; return;
...@@ -2564,11 +2565,11 @@ static void dgnc_tty_throttle(struct tty_struct *tty) ...@@ -2564,11 +2565,11 @@ static void dgnc_tty_throttle(struct tty_struct *tty)
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return; return;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_flags |= (CH_FORCED_STOPI); ch->ch_flags |= (CH_FORCED_STOPI);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
} }
...@@ -2576,7 +2577,7 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty) ...@@ -2576,7 +2577,7 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty)
{ {
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
ulong lock_flags; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return; return;
...@@ -2589,11 +2590,11 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty) ...@@ -2589,11 +2590,11 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty)
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return; return;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_flags &= ~(CH_FORCED_STOPI); ch->ch_flags &= ~(CH_FORCED_STOPI);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
} }
...@@ -2602,7 +2603,7 @@ static void dgnc_tty_start(struct tty_struct *tty) ...@@ -2602,7 +2603,7 @@ static void dgnc_tty_start(struct tty_struct *tty)
struct dgnc_board *bd; struct dgnc_board *bd;
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
ulong lock_flags; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return; return;
...@@ -2619,11 +2620,11 @@ static void dgnc_tty_start(struct tty_struct *tty) ...@@ -2619,11 +2620,11 @@ static void dgnc_tty_start(struct tty_struct *tty)
if (!bd || bd->magic != DGNC_BOARD_MAGIC) if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return; return;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_flags &= ~(CH_FORCED_STOP); ch->ch_flags &= ~(CH_FORCED_STOP);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
} }
...@@ -2632,7 +2633,7 @@ static void dgnc_tty_stop(struct tty_struct *tty) ...@@ -2632,7 +2633,7 @@ static void dgnc_tty_stop(struct tty_struct *tty)
struct dgnc_board *bd; struct dgnc_board *bd;
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
ulong lock_flags; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return; return;
...@@ -2649,11 +2650,11 @@ static void dgnc_tty_stop(struct tty_struct *tty) ...@@ -2649,11 +2650,11 @@ static void dgnc_tty_stop(struct tty_struct *tty)
if (!bd || bd->magic != DGNC_BOARD_MAGIC) if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return; return;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_flags |= (CH_FORCED_STOP); ch->ch_flags |= (CH_FORCED_STOP);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
} }
...@@ -2675,7 +2676,7 @@ static void dgnc_tty_flush_chars(struct tty_struct *tty) ...@@ -2675,7 +2676,7 @@ static void dgnc_tty_flush_chars(struct tty_struct *tty)
struct dgnc_board *bd; struct dgnc_board *bd;
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
ulong lock_flags; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return; return;
...@@ -2692,11 +2693,11 @@ static void dgnc_tty_flush_chars(struct tty_struct *tty) ...@@ -2692,11 +2693,11 @@ static void dgnc_tty_flush_chars(struct tty_struct *tty)
if (!bd || bd->magic != DGNC_BOARD_MAGIC) if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return; return;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
/* Do something maybe here */ /* Do something maybe here */
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
} }
...@@ -2710,7 +2711,7 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty) ...@@ -2710,7 +2711,7 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty)
{ {
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
ulong lock_flags; unsigned long flags;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
return; return;
...@@ -2723,7 +2724,7 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty) ...@@ -2723,7 +2724,7 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty)
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return; return;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_flags &= ~CH_STOP; ch->ch_flags &= ~CH_STOP;
...@@ -2742,7 +2743,7 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty) ...@@ -2742,7 +2743,7 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty)
wake_up_interruptible(&ch->ch_pun.un_flags_wait); wake_up_interruptible(&ch->ch_pun.un_flags_wait);
} }
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
} }
...@@ -2765,7 +2766,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -2765,7 +2766,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
int rc; int rc;
ulong lock_flags; unsigned long flags;
void __user *uarg = (void __user *) arg; void __user *uarg = (void __user *) arg;
if (!tty || tty->magic != TTY_MAGIC) if (!tty || tty->magic != TTY_MAGIC)
...@@ -2783,10 +2784,10 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -2783,10 +2784,10 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
if (!bd || bd->magic != DGNC_BOARD_MAGIC) if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return -ENODEV; return -ENODEV;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
if (un->un_open_count <= 0) { if (un->un_open_count <= 0) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return -EIO; return -EIO;
} }
...@@ -2804,7 +2805,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -2804,7 +2805,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
* in the middle: 0.375 seconds. * in the middle: 0.375 seconds.
*/ */
rc = tty_check_change(tty); rc = tty_check_change(tty);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
if (rc) if (rc)
return rc; return rc;
...@@ -2813,13 +2814,13 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -2813,13 +2814,13 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
if (rc) if (rc)
return -EINTR; return -EINTR;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) { if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) {
ch->ch_bd->bd_ops->send_break(ch, 250); ch->ch_bd->bd_ops->send_break(ch, 250);
} }
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
...@@ -2831,7 +2832,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -2831,7 +2832,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
* in the middle: 0.375 seconds. * in the middle: 0.375 seconds.
*/ */
rc = tty_check_change(tty); rc = tty_check_change(tty);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
if (rc) if (rc)
return rc; return rc;
...@@ -2839,17 +2840,17 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -2839,17 +2840,17 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
if (rc) if (rc)
return -EINTR; return -EINTR;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_bd->bd_ops->send_break(ch, 250); ch->ch_bd->bd_ops->send_break(ch, 250);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
case TIOCSBRK: case TIOCSBRK:
rc = tty_check_change(tty); rc = tty_check_change(tty);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
if (rc) if (rc)
return rc; return rc;
...@@ -2857,48 +2858,48 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -2857,48 +2858,48 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
if (rc) if (rc)
return -EINTR; return -EINTR;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_bd->bd_ops->send_break(ch, 250); ch->ch_bd->bd_ops->send_break(ch, 250);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
case TIOCCBRK: case TIOCCBRK:
/* Do Nothing */ /* Do Nothing */
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
case TIOCGSOFTCAR: case TIOCGSOFTCAR:
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) arg); rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) arg);
return rc; return rc;
case TIOCSSOFTCAR: case TIOCSSOFTCAR:
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = get_user(arg, (unsigned long __user *) arg); rc = get_user(arg, (unsigned long __user *) arg);
if (rc) if (rc)
return rc; return rc;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0));
ch->ch_bd->bd_ops->param(tty); ch->ch_bd->bd_ops->param(tty);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
case TIOCMGET: case TIOCMGET:
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return dgnc_get_modem_info(ch, uarg); return dgnc_get_modem_info(ch, uarg);
case TIOCMBIS: case TIOCMBIS:
case TIOCMBIC: case TIOCMBIC:
case TIOCMSET: case TIOCMSET:
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return dgnc_set_modem_info(tty, cmd, uarg); return dgnc_set_modem_info(tty, cmd, uarg);
/* /*
...@@ -2917,7 +2918,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -2917,7 +2918,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
*/ */
rc = tty_check_change(tty); rc = tty_check_change(tty);
if (rc) { if (rc) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return rc; return rc;
} }
...@@ -2947,7 +2948,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -2947,7 +2948,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
} }
/* pretend we didn't recognize this IOCTL */ /* pretend we didn't recognize this IOCTL */
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
case TCSETSF: case TCSETSF:
case TCSETSW: case TCSETSW:
...@@ -2970,7 +2971,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -2970,7 +2971,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
} }
/* now wait for all the output to drain */ /* now wait for all the output to drain */
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = ch->ch_bd->bd_ops->drain(tty, 0); rc = ch->ch_bd->bd_ops->drain(tty, 0);
if (rc) if (rc)
return -EINTR; return -EINTR;
...@@ -2980,7 +2981,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -2980,7 +2981,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
case TCSETAW: case TCSETAW:
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = ch->ch_bd->bd_ops->drain(tty, 0); rc = ch->ch_bd->bd_ops->drain(tty, 0);
if (rc) if (rc)
return -EINTR; return -EINTR;
...@@ -2989,13 +2990,13 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -2989,13 +2990,13 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
case TCXONC: case TCXONC:
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
/* Make the ld do it */ /* Make the ld do it */
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
case DIGI_GETA: case DIGI_GETA:
/* get information for ditty */ /* get information for ditty */
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return dgnc_tty_digigeta(tty, uarg); return dgnc_tty_digigeta(tty, uarg);
case DIGI_SETAW: case DIGI_SETAW:
...@@ -3004,31 +3005,31 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -3004,31 +3005,31 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
/* set information for ditty */ /* set information for ditty */
if (cmd == (DIGI_SETAW)) { if (cmd == (DIGI_SETAW)) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = ch->ch_bd->bd_ops->drain(tty, 0); rc = ch->ch_bd->bd_ops->drain(tty, 0);
if (rc) if (rc)
return -EINTR; return -EINTR;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
} else { } else {
tty_ldisc_flush(tty); tty_ldisc_flush(tty);
} }
/* fall thru */ /* fall thru */
case DIGI_SETA: case DIGI_SETA:
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return dgnc_tty_digiseta(tty, uarg); return dgnc_tty_digiseta(tty, uarg);
case DIGI_LOOPBACK: case DIGI_LOOPBACK:
{ {
uint loopback = 0; uint loopback = 0;
/* Let go of locks when accessing user space, could sleep */ /* Let go of locks when accessing user space, could sleep */
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = get_user(loopback, (unsigned int __user *) arg); rc = get_user(loopback, (unsigned int __user *) arg);
if (rc) if (rc)
return rc; return rc;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
/* Enable/disable internal loopback for this port */ /* Enable/disable internal loopback for this port */
if (loopback) if (loopback)
...@@ -3037,12 +3038,12 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -3037,12 +3038,12 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
ch->ch_flags &= ~(CH_LOOPBACK); ch->ch_flags &= ~(CH_LOOPBACK);
ch->ch_bd->bd_ops->param(tty); ch->ch_bd->bd_ops->param(tty);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
} }
case DIGI_GETCUSTOMBAUD: case DIGI_GETCUSTOMBAUD:
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = put_user(ch->ch_custom_speed, (unsigned int __user *) arg); rc = put_user(ch->ch_custom_speed, (unsigned int __user *) arg);
return rc; return rc;
...@@ -3050,14 +3051,14 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -3050,14 +3051,14 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
{ {
int new_rate; int new_rate;
/* Let go of locks when accessing user space, could sleep */ /* Let go of locks when accessing user space, could sleep */
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = get_user(new_rate, (int __user *) arg); rc = get_user(new_rate, (int __user *) arg);
if (rc) if (rc)
return rc; return rc;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
dgnc_set_custom_speed(ch, new_rate); dgnc_set_custom_speed(ch, new_rate);
ch->ch_bd->bd_ops->param(tty); ch->ch_bd->bd_ops->param(tty);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
} }
...@@ -3071,13 +3072,13 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -3071,13 +3072,13 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
case DIGI_REALPORT_SENDIMMEDIATE: case DIGI_REALPORT_SENDIMMEDIATE:
{ {
unsigned char c; unsigned char c;
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = get_user(c, (unsigned char __user *) arg); rc = get_user(c, (unsigned char __user *) arg);
if (rc) if (rc)
return rc; return rc;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
ch->ch_bd->bd_ops->send_immediate_char(ch, c); ch->ch_bd->bd_ops->send_immediate_char(ch, c);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0; return 0;
} }
...@@ -3099,7 +3100,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -3099,7 +3100,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
buf.rbytes = ch->ch_rxcount; buf.rbytes = ch->ch_rxcount;
buf.tbytes = ch->ch_txcount; buf.tbytes = ch->ch_txcount;
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
if (copy_to_user(uarg, &buf, sizeof(buf))) if (copy_to_user(uarg, &buf, sizeof(buf)))
return -EFAULT; return -EFAULT;
...@@ -3127,7 +3128,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -3127,7 +3128,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
events |= (EV_IPU | EV_IPS); events |= (EV_IPU | EV_IPS);
} }
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = put_user(events, (unsigned int __user *) arg); rc = put_user(events, (unsigned int __user *) arg);
return rc; return rc;
} }
...@@ -3144,7 +3145,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -3144,7 +3145,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
int tdist; int tdist;
int count; int count;
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
/* /*
* Get data from user first. * Get data from user first.
...@@ -3152,7 +3153,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -3152,7 +3153,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
if (copy_from_user(&buf, uarg, sizeof(buf))) if (copy_from_user(&buf, uarg, sizeof(buf)))
return -EFAULT; return -EFAULT;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
/* /*
* Figure out how much data is in our RX and TX queues. * Figure out how much data is in our RX and TX queues.
...@@ -3190,7 +3191,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -3190,7 +3191,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
else else
buf.txdone = 1; buf.txdone = 1;
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
if (copy_to_user(uarg, &buf, sizeof(buf))) if (copy_to_user(uarg, &buf, sizeof(buf)))
return -EFAULT; return -EFAULT;
...@@ -3198,7 +3199,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ...@@ -3198,7 +3199,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
return 0; return 0;
} }
default: default:
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
......
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