summaryrefslogtreecommitdiffstats
path: root/drivers/staging/dgnc
diff options
context:
space:
mode:
authorRoberta Dobrescu <roberta.dobrescu@gmail.com>2014-09-26 23:58:38 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-28 22:52:12 -0400
commit7be869b0726b270a5702346e66f57e9886cbba6b (patch)
tree2e6e4fcb2a06521467a8e2cefdb62ee58ffcf36f /drivers/staging/dgnc
parenta44b508a32aed3a5e6af1468753886ba4d216a8c (diff)
downloadop-kernel-dev-7be869b0726b270a5702346e66f57e9886cbba6b.zip
op-kernel-dev-7be869b0726b270a5702346e66f57e9886cbba6b.tar.gz
staging: dgnc: dgnc_neo.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 ...> Additionally replace 'lock_flags2' with 'flags2'. This was done by hand since it had only 3 occurences and all in this file. Signed-off-by: Roberta Dobrescu <roberta.dobrescu@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/dgnc')
-rw-r--r--drivers/staging/dgnc/dgnc_neo.c120
1 files changed, 66 insertions, 54 deletions
diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index d6f4a80..9c8f06b 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -368,13 +368,13 @@ static inline void neo_set_new_start_stop_chars(struct channel_t *ch)
*/
static inline void neo_clear_break(struct channel_t *ch, int force)
{
- ulong lock_flags;
+ unsigned long flags;
- DGNC_LOCK(ch->ch_lock, lock_flags);
+ spin_lock_irqsave(&ch->ch_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, 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, flags);
}
@@ -402,7 +402,7 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port)
struct channel_t *ch;
uchar isr;
uchar cause;
- ulong lock_flags;
+ unsigned long flags;
if (!brd || brd->magic != DGNC_BOARD_MAGIC)
return;
@@ -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, flags);
dgnc_check_queue_flow_control(ch);
- DGNC_UNLOCK(ch->ch_lock, lock_flags);
+ spin_unlock_irqrestore(&ch->ch_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, 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, 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,
+ flags);
ch->ch_flags &= ~(CH_STOP);
- DGNC_UNLOCK(ch->ch_lock, lock_flags);
+ spin_unlock_irqrestore(&ch->ch_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,
+ flags);
ch->ch_flags |= CH_STOP;
- DGNC_UNLOCK(ch->ch_lock, lock_flags);
+ spin_unlock_irqrestore(&ch->ch_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,
+ flags);
ch->ch_mostat |= UART_MCR_RTS;
- DGNC_UNLOCK(ch->ch_lock, lock_flags);
+ spin_unlock_irqrestore(&ch->ch_lock,
+ flags);
} else {
- DGNC_LOCK(ch->ch_lock, lock_flags);
+ spin_lock_irqsave(&ch->ch_lock,
+ flags);
ch->ch_mostat &= ~(UART_MCR_RTS);
- DGNC_UNLOCK(ch->ch_lock, lock_flags);
+ spin_unlock_irqrestore(&ch->ch_lock,
+ flags);
}
} else {
if (cause & UART_MCR_DTR) {
- DGNC_LOCK(ch->ch_lock, lock_flags);
+ spin_lock_irqsave(&ch->ch_lock,
+ flags);
ch->ch_mostat |= UART_MCR_DTR;
- DGNC_UNLOCK(ch->ch_lock, lock_flags);
+ spin_unlock_irqrestore(&ch->ch_lock,
+ flags);
} else {
- DGNC_LOCK(ch->ch_lock, lock_flags);
+ spin_lock_irqsave(&ch->ch_lock,
+ flags);
ch->ch_mostat &= ~(UART_MCR_DTR);
- DGNC_UNLOCK(ch->ch_lock, lock_flags);
+ spin_unlock_irqrestore(&ch->ch_lock,
+ flags);
}
}
}
@@ -516,7 +528,7 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port)
{
struct channel_t *ch;
int linestatus;
- ulong lock_flags;
+ unsigned long flags;
if (!brd)
return;
@@ -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, flags);
dgnc_check_queue_flow_control(ch);
- DGNC_UNLOCK(ch->ch_lock, lock_flags);
+ spin_unlock_irqrestore(&ch->ch_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, 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, 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, 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, flags);
/* Transfer data (if any) from Write Queue -> UART. */
neo_copy_data_from_queue_to_uart(ch);
@@ -852,7 +864,7 @@ static void neo_tasklet(unsigned long data)
{
struct dgnc_board *bd = (struct dgnc_board *) data;
struct channel_t *ch;
- ulong lock_flags;
+ unsigned long flags;
int i;
int state = 0;
int ports = 0;
@@ -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, flags);
state = bd->state;
ports = bd->nasync;
- DGNC_UNLOCK(bd->bd_lock, lock_flags);
+ spin_unlock_irqrestore(&bd->bd_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, 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, flags);
}
@@ -940,8 +952,8 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
int current_port;
u32 tmp;
u32 uart_poll;
- unsigned long lock_flags;
- unsigned long lock_flags2;
+ unsigned long flags;
+ unsigned long flags2;
if (!brd) {
APR(("Received interrupt (%d) with null board associated\n", irq));
@@ -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, 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, 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, flags2);
dgnc_check_queue_flow_control(ch);
- DGNC_UNLOCK(ch->ch_lock, lock_flags2);
+ spin_unlock_irqrestore(&ch->ch_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, flags);
return IRQ_HANDLED;
}
@@ -1118,12 +1130,12 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch)
int total = 0;
ushort head;
ushort tail;
- 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);
/* 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, flags);
}
@@ -1326,7 +1338,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch)
*/
static int neo_drain(struct tty_struct *tty, uint seconds)
{
- ulong lock_flags;
+ unsigned long flags;
struct channel_t *ch;
struct un_t *un;
int rc = 0;
@@ -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, flags);
un->un_flags |= UN_EMPTY;
- DGNC_UNLOCK(ch->ch_lock, lock_flags);
+ spin_unlock_irqrestore(&ch->ch_lock, flags);
/*
* Go to sleep waiting for the tty layer to wake me back up when
@@ -1425,22 +1437,22 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
int s;
int qlen;
uint len_written = 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);
/* 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, 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, 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, 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, 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, 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, flags);
}
OpenPOWER on IntegriCloud