From a44b508a32aed3a5e6af1468753886ba4d216a8c Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Fri, 26 Sep 2014 23:58:37 +0300 Subject: [PATCH] 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: Roberta Dobrescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 293 ++++++++++++++++---------------- 1 file changed, 147 insertions(+), 146 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index a4e6c9ed799a..3892da25066f 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -342,7 +342,7 @@ int dgnc_tty_init(struct dgnc_board *brd) if (!brd->channels[i]) continue; - DGNC_SPINLOCK_INIT(ch->ch_lock); + spin_lock_init(&ch->ch_lock); /* Store all our magic numbers */ ch->magic = DGNC_CHANNEL_MAGIC; @@ -631,7 +631,7 @@ void dgnc_input(struct channel_t *ch) ushort head; ushort tail; int data_len; - ulong lock_flags; + unsigned long flags; int flip_len; int len = 0; int n = 0; @@ -647,7 +647,7 @@ void dgnc_input(struct channel_t *ch) if (!bd || bd->magic != DGNC_BOARD_MAGIC) return; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); /* * Figure the number of characters in the buffer. @@ -659,7 +659,7 @@ void dgnc_input(struct channel_t *ch) data_len = (head - tail) & rmask; if (data_len == 0) { - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return; } @@ -675,7 +675,7 @@ void dgnc_input(struct channel_t *ch) /* Force queue flow control to be released, if needed */ dgnc_check_queue_flow_control(ch); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return; } @@ -683,7 +683,7 @@ void dgnc_input(struct channel_t *ch) * If we are throttled, simply don't read any data. */ if (ch->ch_flags & CH_FORCED_STOPI) { - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return; } @@ -724,7 +724,7 @@ void dgnc_input(struct channel_t *ch) } if (len <= 0) { - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); if (ld) tty_ldisc_deref(ld); return; @@ -791,7 +791,7 @@ void dgnc_input(struct channel_t *ch) ch->ch_r_tail = tail & rmask; ch->ch_e_tail = tail & rmask; 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 */ tty_flip_buffer_push(tp->port); @@ -1052,12 +1052,12 @@ void dgnc_check_queue_flow_control(struct channel_t *ch) void dgnc_wakeup_writes(struct channel_t *ch) { int qlen = 0; - ulong lock_flags; + unsigned long flags; if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) 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. @@ -1067,16 +1067,16 @@ void dgnc_wakeup_writes(struct channel_t *ch) qlen += WQUEUESIZE; if (qlen >= (WQUEUESIZE - 256)) { - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return; } if (ch->ch_tun.un_flags & UN_ISOPEN) { if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_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); - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); } wake_up_interruptible(&ch->ch_tun.un_tty->write_wait); @@ -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_tty->flags & (1 << TTY_DO_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); - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); } wake_up_interruptible(&ch->ch_pun.un_tty->write_wait); @@ -1135,7 +1135,7 @@ void dgnc_wakeup_writes(struct channel_t *ch) 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) uint major = 0; uint minor = 0; int rc = 0; - ulong lock_flags; + unsigned long flags; rc = 0; @@ -1183,25 +1183,25 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) if (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 (PORT_NUM(minor) > brd->nasync) { - DGNC_UNLOCK(brd->bd_lock, lock_flags); + spin_unlock_irqrestore(&brd->bd_lock, flags); return -ENXIO; } ch = brd->channels[PORT_NUM(minor)]; if (!ch) { - DGNC_UNLOCK(brd->bd_lock, lock_flags); + spin_unlock_irqrestore(&brd->bd_lock, flags); return -ENXIO; } /* Drop board lock */ - DGNC_UNLOCK(brd->bd_lock, lock_flags); + spin_unlock_irqrestore(&brd->bd_lock, flags); /* Grab channel lock */ - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); /* Figure out our type */ if (!IS_PRINT(minor)) { @@ -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->un_type = DGNC_PRINT; } else { - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return -ENXIO; } @@ -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 * 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)); @@ -1242,7 +1242,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) if (rc) 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. */ @@ -1267,7 +1267,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) ch->ch_flags |= (CH_OPENING); /* 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) ch->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL); @@ -1276,7 +1276,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) if (!ch->ch_wqueue) 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); wake_up_interruptible(&ch->ch_flags_wait); @@ -1335,16 +1335,16 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) * 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); /* 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++; un->un_open_count++; un->un_flags |= (UN_ISOPEN); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return rc; } @@ -1359,7 +1359,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc { int retval = 0; struct un_t *un = NULL; - ulong lock_flags; + unsigned long flags; uint old_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 if (!un || un->magic != DGNC_UNIT_MAGIC) return -ENXIO; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); ch->ch_wopen++; @@ -1451,7 +1451,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc * 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. @@ -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. * Before looping around, grab our channel lock. */ - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); } ch->ch_wopen--; - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); if (retval) return retval; @@ -1513,7 +1513,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) struct dgnc_board *bd; struct channel_t *ch; struct un_t *un; - ulong lock_flags; + unsigned long flags; int rc = 0; if (!tty || tty->magic != TTY_MAGIC) @@ -1533,7 +1533,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) 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 @@ -1559,7 +1559,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) ch->ch_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; } @@ -1586,7 +1586,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) ch->ch_flags &= ~CH_PRON; } - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); /* wait for output to drain */ /* 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) dgnc_tty_flush_buffer(tty); tty_ldisc_flush(tty); - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); tty->closing = 0; @@ -1613,9 +1613,10 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) * have been dropped for modems to see it. */ 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_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) wake_up_interruptible(&ch->ch_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) ushort ttail; uint tmask; uint chars = 0; - ulong lock_flags = 0; + unsigned long flags; if (tty == NULL) return 0; @@ -1673,13 +1674,13 @@ static int dgnc_tty_chars_in_buffer(struct tty_struct *tty) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return 0; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); tmask = WQUEUEMASK; thead = ch->ch_w_head & tmask; ttail = ch->ch_w_tail & tmask; - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); if (ttail == thead) { chars = 0; @@ -1763,7 +1764,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty) ushort tail; ushort tmask; int ret = 0; - ulong lock_flags = 0; + unsigned long flags; if (tty == NULL || dgnc_TmpWriteBuf == NULL) return 0; @@ -1776,7 +1777,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return 0; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); tmask = WQUEUEMASK; head = (ch->ch_w_head) & tmask; @@ -1805,7 +1806,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty) if (ret < 0) ret = 0; - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return ret; } @@ -1841,7 +1842,7 @@ static int dgnc_tty_write(struct tty_struct *tty, struct un_t *un = NULL; int bufcount = 0, n = 0; int orig_count = 0; - ulong lock_flags; + unsigned long flags; ushort head; ushort tail; ushort tmask; @@ -1869,7 +1870,7 @@ static int dgnc_tty_write(struct tty_struct *tty, */ 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 */ tmask = WQUEUEMASK; @@ -1896,7 +1897,7 @@ static int dgnc_tty_write(struct tty_struct *tty, * Bail if no space left. */ if (count <= 0) { - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return 0; } @@ -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 (count <= 0) { - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return 0; } @@ -1934,7 +1935,7 @@ static int dgnc_tty_write(struct tty_struct *tty, 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 @@ -1956,7 +1957,7 @@ static int dgnc_tty_write(struct tty_struct *tty, return -EFAULT; } - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); buf = dgnc_TmpWriteBuf; @@ -2001,10 +2002,10 @@ static int dgnc_tty_write(struct tty_struct *tty, } if (from_user) { - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); up(&dgnc_TmpWriteSem); } else { - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); } if (count) { @@ -2029,7 +2030,7 @@ static int dgnc_tty_tiocmget(struct tty_struct *tty) struct un_t *un; int result = -EIO; uchar mstat = 0; - ulong lock_flags; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return result; @@ -2042,11 +2043,11 @@ static int dgnc_tty_tiocmget(struct tty_struct *tty) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return result; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); mstat = (ch->ch_mostat | ch->ch_mistat); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); result = 0; @@ -2080,7 +2081,7 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty, struct channel_t *ch; struct un_t *un; int ret = -EIO; - ulong lock_flags; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return ret; @@ -2097,7 +2098,7 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty, if (!bd || bd->magic != DGNC_BOARD_MAGIC) return ret; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); if (set & TIOCM_RTS) ch->ch_mostat |= UART_MCR_RTS; @@ -2113,7 +2114,7 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty, 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; } @@ -2130,7 +2131,7 @@ static int dgnc_tty_send_break(struct tty_struct *tty, int msec) struct channel_t *ch; struct un_t *un; int ret = -EIO; - ulong lock_flags; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return ret; @@ -2158,11 +2159,11 @@ static int dgnc_tty_send_break(struct tty_struct *tty, int msec) break; } - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); 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; @@ -2212,7 +2213,7 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, char c) struct dgnc_board *bd; struct channel_t *ch; struct un_t *un; - ulong lock_flags; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return; @@ -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"); - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); 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"); return; @@ -2249,16 +2250,16 @@ static inline int dgnc_get_mstat(struct channel_t *ch) { unsigned char mstat; int result = -EIO; - ulong lock_flags; + unsigned long flags; if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return -ENXIO; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); mstat = (ch->ch_mostat | ch->ch_mistat); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); result = 0; @@ -2311,7 +2312,7 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns struct un_t *un; int ret = -ENXIO; unsigned int arg = 0; - ulong lock_flags; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return ret; @@ -2371,11 +2372,11 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns 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); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return 0; } @@ -2394,7 +2395,7 @@ static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retin struct channel_t *ch; struct un_t *un; struct digi_t tmp; - ulong lock_flags; + unsigned long flags; if (!retinfo) return -EFAULT; @@ -2412,9 +2413,9 @@ static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retin 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)); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) return -EFAULT; @@ -2437,7 +2438,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i struct channel_t *ch; struct un_t *un; struct digi_t new_digi; - ulong lock_flags; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return -EFAULT; @@ -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))) return -EFAULT; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); /* * 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 ch->ch_bd->bd_ops->param(tty); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return 0; } @@ -2514,7 +2515,7 @@ static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te struct dgnc_board *bd; struct channel_t *ch; struct un_t *un; - unsigned long lock_flags; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return; @@ -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) 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_iflag = tty->termios.c_iflag; @@ -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); 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) { struct channel_t *ch; struct un_t *un; - ulong lock_flags = 0; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return; @@ -2564,11 +2565,11 @@ static void dgnc_tty_throttle(struct tty_struct *tty) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); 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) { struct channel_t *ch; struct un_t *un; - ulong lock_flags; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return; @@ -2589,11 +2590,11 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); 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) struct dgnc_board *bd; struct channel_t *ch; struct un_t *un; - ulong lock_flags; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return; @@ -2619,11 +2620,11 @@ static void dgnc_tty_start(struct tty_struct *tty) if (!bd || bd->magic != DGNC_BOARD_MAGIC) return; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); 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) struct dgnc_board *bd; struct channel_t *ch; struct un_t *un; - ulong lock_flags; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return; @@ -2649,11 +2650,11 @@ static void dgnc_tty_stop(struct tty_struct *tty) if (!bd || bd->magic != DGNC_BOARD_MAGIC) return; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); 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) struct dgnc_board *bd; struct channel_t *ch; struct un_t *un; - ulong lock_flags; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return; @@ -2692,11 +2693,11 @@ static void dgnc_tty_flush_chars(struct tty_struct *tty) if (!bd || bd->magic != DGNC_BOARD_MAGIC) return; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); /* 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) { struct channel_t *ch; struct un_t *un; - ulong lock_flags; + unsigned long flags; if (!tty || tty->magic != TTY_MAGIC) return; @@ -2723,7 +2724,7 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); ch->ch_flags &= ~CH_STOP; @@ -2742,7 +2743,7 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty) 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, struct channel_t *ch; struct un_t *un; int rc; - ulong lock_flags; + unsigned long flags; void __user *uarg = (void __user *) arg; if (!tty || tty->magic != TTY_MAGIC) @@ -2783,10 +2784,10 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, if (!bd || bd->magic != DGNC_BOARD_MAGIC) return -ENODEV; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); if (un->un_open_count <= 0) { - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return -EIO; } @@ -2804,7 +2805,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, * in the middle: 0.375 seconds. */ rc = tty_check_change(tty); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); if (rc) return rc; @@ -2813,13 +2814,13 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, if (rc) return -EINTR; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) { 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; @@ -2831,7 +2832,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, * in the middle: 0.375 seconds. */ rc = tty_check_change(tty); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); if (rc) return rc; @@ -2839,17 +2840,17 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, if (rc) 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); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return 0; case TIOCSBRK: rc = tty_check_change(tty); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); if (rc) return rc; @@ -2857,48 +2858,48 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, if (rc) 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); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return 0; case TIOCCBRK: /* Do Nothing */ - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return 0; 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); return rc; case TIOCSSOFTCAR: - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); rc = get_user(arg, (unsigned long __user *) arg); if (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)); ch->ch_bd->bd_ops->param(tty); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return 0; case TIOCMGET: - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return dgnc_get_modem_info(ch, uarg); case TIOCMBIS: case TIOCMBIC: case TIOCMSET: - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return dgnc_set_modem_info(tty, cmd, uarg); /* @@ -2917,7 +2918,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, */ rc = tty_check_change(tty); if (rc) { - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return rc; } @@ -2947,7 +2948,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, } /* pretend we didn't recognize this IOCTL */ - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return -ENOIOCTLCMD; case TCSETSF: case TCSETSW: @@ -2970,7 +2971,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, } /* 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); if (rc) return -EINTR; @@ -2980,7 +2981,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, 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); if (rc) return -EINTR; @@ -2989,13 +2990,13 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, return -ENOIOCTLCMD; case TCXONC: - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); /* Make the ld do it */ return -ENOIOCTLCMD; case DIGI_GETA: /* get information for ditty */ - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return dgnc_tty_digigeta(tty, uarg); case DIGI_SETAW: @@ -3004,31 +3005,31 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, /* set information for ditty */ 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); if (rc) return -EINTR; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); } else { tty_ldisc_flush(tty); } /* fall thru */ case DIGI_SETA: - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return dgnc_tty_digiseta(tty, uarg); case DIGI_LOOPBACK: { uint loopback = 0; /* 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); if (rc) return rc; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); /* Enable/disable internal loopback for this port */ if (loopback) @@ -3037,12 +3038,12 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ch->ch_flags &= ~(CH_LOOPBACK); ch->ch_bd->bd_ops->param(tty); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return 0; } 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); return rc; @@ -3050,14 +3051,14 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, { int new_rate; /* 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); if (rc) return rc; - DGNC_LOCK(ch->ch_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, flags); dgnc_set_custom_speed(ch, new_rate); ch->ch_bd->bd_ops->param(tty); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return 0; } @@ -3071,13 +3072,13 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, case DIGI_REALPORT_SENDIMMEDIATE: { 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); if (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); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return 0; } @@ -3099,7 +3100,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, buf.rbytes = ch->ch_rxcount; 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))) return -EFAULT; @@ -3127,7 +3128,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, 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); return rc; } @@ -3144,7 +3145,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, int tdist; int count; - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); /* * Get data from user first. @@ -3152,7 +3153,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, if (copy_from_user(&buf, uarg, sizeof(buf))) 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. @@ -3190,7 +3191,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, else 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))) return -EFAULT; @@ -3198,7 +3199,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, return 0; } default: - DGNC_UNLOCK(ch->ch_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, flags); return -ENOIOCTLCMD; } -- 2.20.1