[PATCH v2] dgnc: Replace non-standard spinlock's macros

Roberta Dobrescu roberta.dobrescu at gmail.com
Mon Sep 22 16:01:44 EEST 2014


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)

Signed-off-by: Roberta Dobrescu <roberta.dobrescu at gmail.com>
---
Changes since v1:
	-use ' instead of ` in subject and description
	-remove unnecessary braces around x

 drivers/staging/dgnc/dgnc_cls.c    |  50 ++++----
 drivers/staging/dgnc/dgnc_driver.c |  30 ++---
 drivers/staging/dgnc/dgnc_driver.h |   8 --
 drivers/staging/dgnc/dgnc_mgmt.c   |  24 ++--
 drivers/staging/dgnc/dgnc_neo.c    | 102 ++++++++-------
 drivers/staging/dgnc/dgnc_tty.c    | 245 +++++++++++++++++++------------------
 6 files changed, 232 insertions(+), 227 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c
index 0393d6d..abdbe0d 100644
--- a/drivers/staging/dgnc/dgnc_cls.c
+++ b/drivers/staging/dgnc/dgnc_cls.c
@@ -372,11 +372,11 @@ static inline void cls_clear_break(struct channel_t *ch, int force)
 	if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
 		return;
 
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, lock_flags);
 
 	/* Bail if we aren't currently sending a break. */
 	if (!ch->ch_stop_sending_break) {
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 		return;
 	}
 
@@ -390,7 +390,7 @@ static inline void cls_clear_break(struct channel_t *ch, int force)
 			ch->ch_stop_sending_break = 0;
 		}
 	}
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 }
 
 
@@ -434,11 +434,11 @@ static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
 		/* Transmit Hold register empty pending */
 		if (isr & UART_IIR_THRI) {
 			/* Transfer data (if any) from Write Queue -> UART. */
-			DGNC_LOCK(ch->ch_lock, lock_flags);
+			spin_lock_irqsave(&ch->ch_lock, lock_flags);
 			ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
 			brd->intr_tx++;
 			ch->ch_intr_tx++;
-			DGNC_UNLOCK(ch->ch_lock, lock_flags);
+			spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 			cls_copy_data_from_queue_to_uart(ch);
 		}
 
@@ -730,16 +730,16 @@ static void cls_tasklet(unsigned long data)
 	}
 
 	/* Cache a couple board values */
-	DGNC_LOCK(bd->bd_lock, lock_flags);
+	spin_lock_irqsave(&bd->bd_lock, lock_flags);
 	state = bd->state;
 	ports = bd->nasync;
-	DGNC_UNLOCK(bd->bd_lock, lock_flags);
+	spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
 
 	/*
 	 * Do NOT allow the interrupt routine to read the intr registers
 	 * Until we release this lock.
 	 */
-	DGNC_LOCK(bd->bd_intr_lock, lock_flags);
+	spin_lock_irqsave(&bd->bd_intr_lock, lock_flags);
 
 	/*
 	 * If board is ready, parse deeper to see if there is anything to do.
@@ -782,7 +782,7 @@ static void cls_tasklet(unsigned long data)
 		}
 	}
 
-	DGNC_UNLOCK(bd->bd_intr_lock, lock_flags);
+	spin_unlock_irqrestore(&bd->bd_intr_lock, lock_flags);
 
 }
 
@@ -814,7 +814,7 @@ static irqreturn_t cls_intr(int irq, void *voidbrd)
 		return IRQ_NONE;
 	}
 
-	DGNC_LOCK(brd->bd_intr_lock, lock_flags);
+	spin_lock_irqsave(&brd->bd_intr_lock, lock_flags);
 
 	brd->intr_count++;
 
@@ -826,7 +826,7 @@ static irqreturn_t cls_intr(int irq, void *voidbrd)
 
 	/* If 0, no interrupts pending */
 	if (!poll_reg) {
-		DGNC_UNLOCK(brd->bd_intr_lock, lock_flags);
+		spin_unlock_irqrestore(&brd->bd_intr_lock, lock_flags);
 		return IRQ_NONE;
 	}
 
@@ -839,7 +839,7 @@ static irqreturn_t cls_intr(int irq, void *voidbrd)
 	 */
 	tasklet_schedule(&brd->helper_tasklet);
 
-	DGNC_UNLOCK(brd->bd_intr_lock, lock_flags);
+	spin_unlock_irqrestore(&brd->bd_intr_lock, lock_flags);
 
 	return IRQ_HANDLED;
 }
@@ -875,7 +875,7 @@ static void cls_copy_data_from_uart_to_queue(struct channel_t *ch)
 	if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
 		return;
 
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, lock_flags);
 
 	/* cache head and tail of queue */
 	head = ch->ch_r_head;
@@ -951,7 +951,7 @@ static void cls_copy_data_from_uart_to_queue(struct channel_t *ch)
 	ch->ch_r_head = head & RQUEUEMASK;
 	ch->ch_e_head = head & EQUEUEMASK;
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 }
 
 
@@ -977,9 +977,9 @@ static int cls_drain(struct tty_struct *tty, uint seconds)
 	if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
 		return -ENXIO;
 
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, lock_flags);
 	un->un_flags |= UN_EMPTY;
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 	/*
 	 * NOTE: Do something with time passed in.
@@ -1040,23 +1040,23 @@ static void cls_copy_data_from_queue_to_uart(struct channel_t *ch)
 	if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
 		return;
 
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, lock_flags);
 
 	/* No data to write to the UART */
 	if (ch->ch_w_tail == ch->ch_w_head) {
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 		return;
 	}
 
 	/* If port is "stopped", don't send any data to the UART */
 	if ((ch->ch_flags & CH_FORCED_STOP) ||
 				 (ch->ch_flags & CH_BREAK_SENDING)) {
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 		return;
 	}
 
 	if (!(ch->ch_flags & (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM))) {
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 		return;
 	}
 
@@ -1110,7 +1110,7 @@ static void cls_copy_data_from_queue_to_uart(struct channel_t *ch)
 	if (len_written > 0)
 		ch->ch_flags &= ~(CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 }
 
 
@@ -1126,7 +1126,7 @@ static void cls_parse_modem(struct channel_t *ch, uchar signals)
 	 * Do altpin switching. Altpin switches DCD and DSR.
 	 * This prolly breaks DSRPACE, so we should be more clever here.
 	 */
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, lock_flags);
 	if (ch->ch_digi.digi_flags & DIGI_ALTPIN) {
 		uchar mswap = signals;
 
@@ -1147,7 +1147,7 @@ static void cls_parse_modem(struct channel_t *ch, uchar signals)
 			msignals |= UART_MSR_DCD;
 		}
 	}
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 	/*
 	 * Scrub off lower bits. They signify delta's, which I don't
@@ -1155,7 +1155,7 @@ static void cls_parse_modem(struct channel_t *ch, uchar signals)
 	 */
 	signals &= 0xf0;
 
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, lock_flags);
 	if (msignals & UART_MSR_DCD)
 		ch->ch_mistat |= UART_MSR_DCD;
 	else
@@ -1175,7 +1175,7 @@ static void cls_parse_modem(struct channel_t *ch, uchar signals)
 		ch->ch_mistat |= UART_MSR_CTS;
 	else
 		ch->ch_mistat &= ~UART_MSR_CTS;
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 }
 
 
diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index 2cc02c9..4356b63 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -186,9 +186,9 @@ static void dgnc_cleanup_module(void)
 	int i;
 	ulong lock_flags;
 
-	DGNC_LOCK(dgnc_poll_lock, lock_flags);
+	spin_lock_irqsave(&dgnc_poll_lock, lock_flags);
 	dgnc_poll_stop = 1;
-	DGNC_UNLOCK(dgnc_poll_lock, lock_flags);
+	spin_unlock_irqrestore(&dgnc_poll_lock, lock_flags);
 
 	/* Turn off poller right away. */
 	del_timer_sync(&dgnc_poll_timer);
@@ -299,13 +299,13 @@ static int dgnc_start(void)
 	}
 
 	/* Start the poller */
-	DGNC_LOCK(dgnc_poll_lock, flags);
+	spin_lock_irqsave(&dgnc_poll_lock, flags);
 	init_timer(&dgnc_poll_timer);
 	dgnc_poll_timer.function = dgnc_poll_handler;
 	dgnc_poll_timer.data = 0;
 	dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
 	dgnc_poll_timer.expires = dgnc_poll_time;
-	DGNC_UNLOCK(dgnc_poll_lock, flags);
+	spin_unlock_irqrestore(&dgnc_poll_lock, flags);
 
 	add_timer(&dgnc_poll_timer);
 
@@ -369,12 +369,12 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
 	if (brd->msgbuf_head) {
 		unsigned long flags;
 
-		DGNC_LOCK(dgnc_global_lock, flags);
+		spin_lock_irqsave(&dgnc_global_lock, flags);
 		brd->msgbuf = NULL;
 		printk("%s", brd->msgbuf_head);
 		kfree(brd->msgbuf_head);
 		brd->msgbuf_head = NULL;
-		DGNC_UNLOCK(dgnc_global_lock, flags);
+		spin_unlock_irqrestore(&dgnc_global_lock, flags);
 	}
 
 	/* Free all allocated channels structs */
@@ -440,8 +440,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 	brd->dpastatus = BD_NOFEP;
 	init_waitqueue_head(&brd->state_wait);
 
-	DGNC_SPINLOCK_INIT(brd->bd_lock);
-	DGNC_SPINLOCK_INIT(brd->bd_intr_lock);
+	spin_lock_init(&brd->bd_lock);
+	spin_lock_init(&brd->bd_intr_lock);
 
 	brd->state		= BOARD_FOUND;
 
@@ -613,12 +613,12 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 	/* init our poll helper tasklet */
 	tasklet_init(&brd->helper_tasklet, brd->bd_ops->tasklet, (unsigned long) brd);
 
-	DGNC_LOCK(dgnc_global_lock, flags);
+	spin_lock_irqsave(&dgnc_global_lock, flags);
 	brd->msgbuf = NULL;
 	printk("%s", brd->msgbuf_head);
 	kfree(brd->msgbuf_head);
 	brd->msgbuf_head = NULL;
-	DGNC_UNLOCK(dgnc_global_lock, flags);
+	spin_unlock_irqrestore(&dgnc_global_lock, flags);
 
 	/*
 	 * allocate flip buffer for board.
@@ -711,24 +711,24 @@ static void dgnc_poll_handler(ulong dummy)
 	for (i = 0; i < dgnc_NumBoards; i++) {
 		brd = dgnc_Board[i];
 
-		DGNC_LOCK(brd->bd_lock, lock_flags);
+		spin_lock_irqsave(&brd->bd_lock, lock_flags);
 
 		/* If board is in a failed state, don't bother scheduling a tasklet */
 		if (brd->state == BOARD_FAILED) {
-			DGNC_UNLOCK(brd->bd_lock, lock_flags);
+			spin_unlock_irqrestore(&brd->bd_lock, lock_flags);
 			continue;
 		}
 
 		/* Schedule a poll helper task */
 		tasklet_schedule(&brd->helper_tasklet);
 
-		DGNC_UNLOCK(brd->bd_lock, lock_flags);
+		spin_unlock_irqrestore(&brd->bd_lock, lock_flags);
 	}
 
 	/*
 	 * Schedule ourself back at the nominal wakeup interval.
 	 */
-	DGNC_LOCK(dgnc_poll_lock, lock_flags);
+	spin_lock_irqsave(&dgnc_poll_lock, lock_flags);
 	dgnc_poll_time += dgnc_jiffies_from_ms(dgnc_poll_tick);
 
 	new_time = dgnc_poll_time - jiffies;
@@ -740,7 +740,7 @@ static void dgnc_poll_handler(ulong dummy)
 	dgnc_poll_timer.function = dgnc_poll_handler;
 	dgnc_poll_timer.data = 0;
 	dgnc_poll_timer.expires = dgnc_poll_time;
-	DGNC_UNLOCK(dgnc_poll_lock, lock_flags);
+	spin_unlock_irqrestore(&dgnc_poll_lock, lock_flags);
 
 	if (!dgnc_poll_stop)
 		add_timer(&dgnc_poll_timer);
diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h
index d2a45ec..c6d0746 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -138,14 +138,6 @@
 #define SNIFF_MASK	(SNIFF_MAX - 1)	/* Sniff wrap mask */
 
 /*
- * Lock function/defines.
- * Makes spotting lock/unlock locations easier.
- */
-# define DGNC_SPINLOCK_INIT(x)		spin_lock_init(&(x))
-# define DGNC_LOCK(x, y)		spin_lock_irqsave(&(x), y)
-# define DGNC_UNLOCK(x, y)		spin_unlock_irqrestore(&(x), y)
-
-/*
  * All the possible states the driver can be while being loaded.
  */
 enum {
diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index 31e9f45..ff346b3 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -65,22 +65,22 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file)
 	unsigned long lock_flags;
 	unsigned int minor = iminor(inode);
 
-	DGNC_LOCK(dgnc_global_lock, lock_flags);
+	spin_lock_irqsave(&dgnc_global_lock, lock_flags);
 
 	/* mgmt device */
 	if (minor < MAXMGMTDEVICES) {
 		/* Only allow 1 open at a time on mgmt device */
 		if (dgnc_mgmt_in_use[minor]) {
-			DGNC_UNLOCK(dgnc_global_lock, lock_flags);
+			spin_unlock_irqrestore(&dgnc_global_lock, lock_flags);
 			return -EBUSY;
 		}
 		dgnc_mgmt_in_use[minor]++;
 	} else {
-		DGNC_UNLOCK(dgnc_global_lock, lock_flags);
+		spin_unlock_irqrestore(&dgnc_global_lock, lock_flags);
 		return -ENXIO;
 	}
 
-	DGNC_UNLOCK(dgnc_global_lock, lock_flags);
+	spin_unlock_irqrestore(&dgnc_global_lock, lock_flags);
 
 	return 0;
 }
@@ -96,14 +96,14 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file)
 	unsigned long lock_flags;
 	unsigned int minor = iminor(inode);
 
-	DGNC_LOCK(dgnc_global_lock, lock_flags);
+	spin_lock_irqsave(&dgnc_global_lock, lock_flags);
 
 	/* mgmt device */
 	if (minor < MAXMGMTDEVICES) {
 		if (dgnc_mgmt_in_use[minor])
 			dgnc_mgmt_in_use[minor] = 0;
 	}
-	DGNC_UNLOCK(dgnc_global_lock, lock_flags);
+	spin_unlock_irqrestore(&dgnc_global_lock, lock_flags);
 
 	return 0;
 }
@@ -131,12 +131,12 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		 */
 		struct digi_dinfo ddi;
 
-		DGNC_LOCK(dgnc_global_lock, lock_flags);
+		spin_lock_irqsave(&dgnc_global_lock, lock_flags);
 
 		ddi.dinfo_nboards = dgnc_NumBoards;
 		sprintf(ddi.dinfo_version, "%s", DG_PART);
 
-		DGNC_UNLOCK(dgnc_global_lock, lock_flags);
+		spin_unlock_irqrestore(&dgnc_global_lock, lock_flags);
 
 		if (copy_to_user(uarg, &ddi, sizeof(ddi)))
 			return -EFAULT;
@@ -161,7 +161,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 		di.info_bdnum = brd;
 
-		DGNC_LOCK(dgnc_Board[brd]->bd_lock, lock_flags);
+		spin_lock_irqsave(&dgnc_Board[brd]->bd_lock, lock_flags);
 
 		di.info_bdtype = dgnc_Board[brd]->dpatype;
 		di.info_bdstate = dgnc_Board[brd]->dpastatus;
@@ -173,7 +173,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		else
 			di.info_nports = 0;
 
-		DGNC_UNLOCK(dgnc_Board[brd]->bd_lock, lock_flags);
+		spin_unlock_irqrestore(&dgnc_Board[brd]->bd_lock, lock_flags);
 
 		if (copy_to_user(uarg, &di, sizeof(di)))
 			return -EFAULT;
@@ -212,7 +212,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		ni.board = board;
 		ni.channel = channel;
 
-		DGNC_LOCK(ch->ch_lock, lock_flags);
+		spin_lock_irqsave(&ch->ch_lock, lock_flags);
 
 		mstat = (ch->ch_mostat | ch->ch_mistat);
 
@@ -266,7 +266,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 		ni.baud = ch->ch_old_baud;
 
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 		if (copy_to_user(uarg, &ni, sizeof(ni)))
 			return -EFAULT;
diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index d6f4a80..9d1501a 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -370,11 +370,11 @@ static inline void neo_clear_break(struct channel_t *ch, int force)
 {
 	ulong lock_flags;
 
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, lock_flags);
 
 	/* Bail if we aren't currently sending a break. */
 	if (!ch->ch_stop_sending_break) {
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 		return;
 	}
 
@@ -390,7 +390,7 @@ static inline void neo_clear_break(struct channel_t *ch, int force)
 			ch->ch_stop_sending_break = 0;
 		}
 	}
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 }
 
 
@@ -435,18 +435,18 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port)
 			neo_copy_data_from_uart_to_queue(ch);
 
 			/* Call our tty layer to enforce queue flow control if needed. */
-			DGNC_LOCK(ch->ch_lock, lock_flags);
+			spin_lock_irqsave(&ch->ch_lock, lock_flags);
 			dgnc_check_queue_flow_control(ch);
-			DGNC_UNLOCK(ch->ch_lock, lock_flags);
+			spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 		}
 
 		if (isr & UART_IIR_THRI) {
 			brd->intr_tx++;
 			ch->ch_intr_tx++;
 			/* Transfer data (if any) from Write Queue -> UART. */
-			DGNC_LOCK(ch->ch_lock, lock_flags);
+			spin_lock_irqsave(&ch->ch_lock, lock_flags);
 			ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
-			DGNC_UNLOCK(ch->ch_lock, lock_flags);
+			spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 			neo_copy_data_from_queue_to_uart(ch);
 		}
 
@@ -461,15 +461,19 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port)
 			if (cause == UART_17158_XON_DETECT) {
 				/* Is output stopped right now, if so, resume it */
 				if (brd->channels[port]->ch_flags & CH_STOP) {
-					DGNC_LOCK(ch->ch_lock, lock_flags);
+					spin_lock_irqsave(&ch->ch_lock,
+							  lock_flags);
 					ch->ch_flags &= ~(CH_STOP);
-					DGNC_UNLOCK(ch->ch_lock, lock_flags);
+					spin_unlock_irqrestore(&ch->ch_lock,
+							       lock_flags);
 				}
 			} else if (cause == UART_17158_XOFF_DETECT) {
 				if (!(brd->channels[port]->ch_flags & CH_STOP)) {
-					DGNC_LOCK(ch->ch_lock, lock_flags);
+					spin_lock_irqsave(&ch->ch_lock,
+							  lock_flags);
 					ch->ch_flags |= CH_STOP;
-					DGNC_UNLOCK(ch->ch_lock, lock_flags);
+					spin_unlock_irqrestore(&ch->ch_lock,
+							       lock_flags);
 				}
 			}
 		}
@@ -485,23 +489,31 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port)
 			/* Which pin is doing auto flow? RTS or DTR? */
 			if ((cause & 0x4) == 0) {
 				if (cause & UART_MCR_RTS) {
-					DGNC_LOCK(ch->ch_lock, lock_flags);
+					spin_lock_irqsave(&ch->ch_lock,
+							  lock_flags);
 					ch->ch_mostat |= UART_MCR_RTS;
-					DGNC_UNLOCK(ch->ch_lock, lock_flags);
+					spin_unlock_irqrestore(&ch->ch_lock,
+							       lock_flags);
 				} else {
-					DGNC_LOCK(ch->ch_lock, lock_flags);
+					spin_lock_irqsave(&ch->ch_lock,
+							  lock_flags);
 					ch->ch_mostat &= ~(UART_MCR_RTS);
-					DGNC_UNLOCK(ch->ch_lock, lock_flags);
+					spin_unlock_irqrestore(&ch->ch_lock,
+							       lock_flags);
 				}
 			} else {
 				if (cause & UART_MCR_DTR) {
-					DGNC_LOCK(ch->ch_lock, lock_flags);
+					spin_lock_irqsave(&ch->ch_lock,
+							  lock_flags);
 					ch->ch_mostat |= UART_MCR_DTR;
-					DGNC_UNLOCK(ch->ch_lock, lock_flags);
+					spin_unlock_irqrestore(&ch->ch_lock,
+							       lock_flags);
 				} else {
-					DGNC_LOCK(ch->ch_lock, lock_flags);
+					spin_lock_irqsave(&ch->ch_lock,
+							  lock_flags);
 					ch->ch_mostat &= ~(UART_MCR_DTR);
-					DGNC_UNLOCK(ch->ch_lock, lock_flags);
+					spin_unlock_irqrestore(&ch->ch_lock,
+							       lock_flags);
 				}
 			}
 		}
@@ -540,9 +552,9 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port)
 		ch->ch_intr_rx++;
 		/* Read data from uart -> queue */
 		neo_copy_data_from_uart_to_queue(ch);
-		DGNC_LOCK(ch->ch_lock, lock_flags);
+		spin_lock_irqsave(&ch->ch_lock, lock_flags);
 		dgnc_check_queue_flow_control(ch);
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 	}
 
 	/*
@@ -572,18 +584,18 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port)
 	if (linestatus & UART_LSR_THRE) {
 		brd->intr_tx++;
 		ch->ch_intr_tx++;
-		DGNC_LOCK(ch->ch_lock, lock_flags);
+		spin_lock_irqsave(&ch->ch_lock, lock_flags);
 		ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 		/* Transfer data (if any) from Write Queue -> UART. */
 		neo_copy_data_from_queue_to_uart(ch);
 	} else if (linestatus & UART_17158_TX_AND_FIFO_CLR) {
 		brd->intr_tx++;
 		ch->ch_intr_tx++;
-		DGNC_LOCK(ch->ch_lock, lock_flags);
+		spin_lock_irqsave(&ch->ch_lock, lock_flags);
 		ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 		/* Transfer data (if any) from Write Queue -> UART. */
 		neo_copy_data_from_queue_to_uart(ch);
@@ -863,16 +875,16 @@ static void neo_tasklet(unsigned long data)
 	}
 
 	/* Cache a couple board values */
-	DGNC_LOCK(bd->bd_lock, lock_flags);
+	spin_lock_irqsave(&bd->bd_lock, lock_flags);
 	state = bd->state;
 	ports = bd->nasync;
-	DGNC_UNLOCK(bd->bd_lock, lock_flags);
+	spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
 
 	/*
 	 * Do NOT allow the interrupt routine to read the intr registers
 	 * Until we release this lock.
 	 */
-	DGNC_LOCK(bd->bd_intr_lock, lock_flags);
+	spin_lock_irqsave(&bd->bd_intr_lock, lock_flags);
 
 	/*
 	 * If board is ready, parse deeper to see if there is anything to do.
@@ -921,7 +933,7 @@ static void neo_tasklet(unsigned long data)
 	}
 
 	/* Allow interrupt routine to access the interrupt register again */
-	DGNC_UNLOCK(bd->bd_intr_lock, lock_flags);
+	spin_unlock_irqrestore(&bd->bd_intr_lock, lock_flags);
 
 }
 
@@ -959,7 +971,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
 	brd->intr_count++;
 
 	/* Lock out the slow poller from running on this board. */
-	DGNC_LOCK(brd->bd_intr_lock, lock_flags);
+	spin_lock_irqsave(&brd->bd_intr_lock, lock_flags);
 
 	/*
 	 * Read in "extended" IRQ information from the 32bit Neo register.
@@ -973,7 +985,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
 	 * This can happen if the IRQ is shared among a couple Neo/Classic boards.
 	 */
 	if (!uart_poll) {
-		DGNC_UNLOCK(brd->bd_intr_lock, lock_flags);
+		spin_unlock_irqrestore(&brd->bd_intr_lock, lock_flags);
 		return IRQ_NONE;
 	}
 
@@ -1021,9 +1033,9 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
 			neo_copy_data_from_uart_to_queue(ch);
 
 			/* Call our tty layer to enforce queue flow control if needed. */
-			DGNC_LOCK(ch->ch_lock, lock_flags2);
+			spin_lock_irqsave(&ch->ch_lock, lock_flags2);
 			dgnc_check_queue_flow_control(ch);
-			DGNC_UNLOCK(ch->ch_lock, lock_flags2);
+			spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
 
 			continue;
 
@@ -1073,7 +1085,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
 	 */
 	tasklet_schedule(&brd->helper_tasklet);
 
-	DGNC_UNLOCK(brd->bd_intr_lock, lock_flags);
+	spin_unlock_irqrestore(&brd->bd_intr_lock, lock_flags);
 
 	return IRQ_HANDLED;
 }
@@ -1123,7 +1135,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch)
 	if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
 		return;
 
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, lock_flags);
 
 	/* cache head and tail of queue */
 	head = ch->ch_r_head & RQUEUEMASK;
@@ -1316,7 +1328,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch)
 	ch->ch_r_head = head & RQUEUEMASK;
 	ch->ch_e_head = head & EQUEUEMASK;
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 }
 
 
@@ -1342,9 +1354,9 @@ static int neo_drain(struct tty_struct *tty, uint seconds)
 	if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
 		return -ENXIO;
 
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, lock_flags);
 	un->un_flags |= UN_EMPTY;
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 	/*
 	 * Go to sleep waiting for the tty layer to wake me back up when
@@ -1430,17 +1442,17 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
 	if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
 		return;
 
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, lock_flags);
 
 	/* No data to write to the UART */
 	if (ch->ch_w_tail == ch->ch_w_head) {
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 		return;
 	}
 
 	/* If port is "stopped", don't send any data to the UART */
 	if ((ch->ch_flags & CH_FORCED_STOP) || (ch->ch_flags & CH_BREAK_SENDING)) {
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 		return;
 	}
 
@@ -1483,7 +1495,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
 			ch->ch_w_tail &= WQUEUEMASK;
 			ch->ch_txcount++;
 		}
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 		return;
 	}
 
@@ -1492,7 +1504,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
 	 */
 	if ((ch->ch_bd->dvid & 0xf0) < UART_XR17E158_DVID) {
 		if (!(ch->ch_flags & (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM))) {
-			DGNC_UNLOCK(ch->ch_lock, lock_flags);
+			spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 			return;
 		}
 
@@ -1501,7 +1513,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
 		n = readb(&ch->ch_neo_uart->tfifo);
 
 		if ((unsigned int) n > ch->ch_t_tlevel) {
-			DGNC_UNLOCK(ch->ch_lock, lock_flags);
+			spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 			return;
 		}
 
@@ -1568,7 +1580,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
 		ch->ch_flags &= ~(CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
 	}
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 }
 
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index a4e6c9e..6b1d84a 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;
@@ -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, 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, 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, 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, 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, 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, lock_flags);
 
 	/* Tell the tty layer its okay to "eat" the data now */
 	tty_flip_buffer_push(tp->port);
@@ -1057,7 +1057,7 @@ void dgnc_wakeup_writes(struct channel_t *ch)
 	if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
 		return;
 
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, 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, 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, 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, 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, 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, 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, lock_flags);
 }
 
 
@@ -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, 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, 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, lock_flags);
 		return -ENXIO;
 	}
 
 	/* Drop board lock */
-	DGNC_UNLOCK(brd->bd_lock, lock_flags);
+	spin_unlock_irqrestore(&brd->bd_lock, lock_flags);
 
 	/* Grab channel lock */
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, 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, 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, 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, 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, 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, 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, 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, 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, lock_flags);
 
 	return rc;
 }
@@ -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, 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, 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, lock_flags);
 	}
 
 	ch->ch_wopen--;
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 	if (retval)
 		return retval;
@@ -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, 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, 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, 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, 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,
+						       lock_flags);
 				dgnc_ms_sleep(ch->ch_close_delay);
-				DGNC_LOCK(ch->ch_lock, lock_flags);
+				spin_lock_irqsave(&ch->ch_lock, 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, lock_flags);
 }
 
 
@@ -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, 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, lock_flags);
 
 	if (ttail == thead) {
 		chars = 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, 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, lock_flags);
 
 	return ret;
 }
@@ -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, 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, 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, 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, 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, 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, lock_flags);
 		up(&dgnc_TmpWriteSem);
 	} else {
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 	}
 
 	if (count) {
@@ -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, lock_flags);
 
 	mstat = (ch->ch_mostat | ch->ch_mistat);
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 	result = 0;
 
@@ -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, 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, lock_flags);
 
 	return 0;
 }
@@ -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, lock_flags);
 
 	ch->ch_bd->bd_ops->send_break(ch, msec);
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 	return 0;
 
@@ -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, lock_flags);
 	bd->bd_ops->send_immediate_char(ch, c);
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 	dev_dbg(tty->dev, "dgnc_tty_send_xchar finish\n");
 	return;
@@ -2254,11 +2255,11 @@ static inline int dgnc_get_mstat(struct channel_t *ch)
 	if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
 		return -ENXIO;
 
-	DGNC_LOCK(ch->ch_lock, lock_flags);
+	spin_lock_irqsave(&ch->ch_lock, lock_flags);
 
 	mstat = (ch->ch_mostat | ch->ch_mistat);
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 	result = 0;
 
@@ -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, lock_flags);
 
 	ch->ch_bd->bd_ops->assert_modem_signals(ch);
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 	return 0;
 }
@@ -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, lock_flags);
 	memcpy(&tmp, &ch->ch_digi, sizeof(tmp));
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 	if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
 		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, 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, lock_flags);
 
 	return 0;
 }
@@ -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, 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, lock_flags);
 }
 
 
@@ -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, lock_flags);
 
 	ch->ch_flags |= (CH_FORCED_STOPI);
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 }
 
 
@@ -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, lock_flags);
 
 	ch->ch_flags &= ~(CH_FORCED_STOPI);
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 }
 
 
@@ -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, lock_flags);
 
 	ch->ch_flags &= ~(CH_FORCED_STOP);
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 }
 
 
@@ -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, lock_flags);
 
 	ch->ch_flags |= (CH_FORCED_STOP);
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 }
 
 
@@ -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, lock_flags);
 
 	/* Do something maybe here */
 
-	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 }
 
 
@@ -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, 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, lock_flags);
 }
 
 
@@ -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, lock_flags);
 
 	if (un->un_open_count <= 0) {
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, 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, 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, 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, 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, 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, lock_flags);
 
 		ch->ch_bd->bd_ops->send_break(ch, 250);
 
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 		return 0;
 
 	case TIOCSBRK:
 		rc = tty_check_change(tty);
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, 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, lock_flags);
 
 		ch->ch_bd->bd_ops->send_break(ch, 250);
 
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
 		return 0;
 
 	case TIOCCBRK:
 		/* Do Nothing */
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 		return 0;
 
 	case TIOCGSOFTCAR:
 
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, 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, 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, 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, lock_flags);
 
 		return 0;
 
 	case TIOCMGET:
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, lock_flags);
 			return 0;
 		}
 
 	case DIGI_GETCUSTOMBAUD:
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, lock_flags);
 
 		return -ENOIOCTLCMD;
 	}
-- 
1.9.1



More information about the firefly mailing list