提交 7be869b0 编写于 作者: R Roberta Dobrescu 提交者: Greg Kroah-Hartman

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: NRoberta Dobrescu <roberta.dobrescu@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 a44b508a
...@@ -368,13 +368,13 @@ static inline void neo_set_new_start_stop_chars(struct channel_t *ch) ...@@ -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) 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. */ /* Bail if we aren't currently sending a break. */
if (!ch->ch_stop_sending_break) { if (!ch->ch_stop_sending_break) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return; return;
} }
...@@ -390,7 +390,7 @@ static inline void neo_clear_break(struct channel_t *ch, int force) ...@@ -390,7 +390,7 @@ static inline void neo_clear_break(struct channel_t *ch, int force)
ch->ch_stop_sending_break = 0; 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) ...@@ -402,7 +402,7 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port)
struct channel_t *ch; struct channel_t *ch;
uchar isr; uchar isr;
uchar cause; uchar cause;
ulong lock_flags; unsigned long flags;
if (!brd || brd->magic != DGNC_BOARD_MAGIC) if (!brd || brd->magic != DGNC_BOARD_MAGIC)
return; return;
...@@ -435,18 +435,18 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port) ...@@ -435,18 +435,18 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port)
neo_copy_data_from_uart_to_queue(ch); neo_copy_data_from_uart_to_queue(ch);
/* Call our tty layer to enforce queue flow control if needed. */ /* 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_check_queue_flow_control(ch);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
} }
if (isr & UART_IIR_THRI) { if (isr & UART_IIR_THRI) {
brd->intr_tx++; brd->intr_tx++;
ch->ch_intr_tx++; ch->ch_intr_tx++;
/* Transfer data (if any) from Write Queue -> UART. */ /* 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); 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); neo_copy_data_from_queue_to_uart(ch);
} }
...@@ -461,15 +461,19 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port) ...@@ -461,15 +461,19 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port)
if (cause == UART_17158_XON_DETECT) { if (cause == UART_17158_XON_DETECT) {
/* Is output stopped right now, if so, resume it */ /* Is output stopped right now, if so, resume it */
if (brd->channels[port]->ch_flags & CH_STOP) { 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); 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) { } else if (cause == UART_17158_XOFF_DETECT) {
if (!(brd->channels[port]->ch_flags & CH_STOP)) { 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; 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) ...@@ -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? */ /* Which pin is doing auto flow? RTS or DTR? */
if ((cause & 0x4) == 0) { if ((cause & 0x4) == 0) {
if (cause & UART_MCR_RTS) { 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; ch->ch_mostat |= UART_MCR_RTS;
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock,
flags);
} else { } else {
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock,
flags);
ch->ch_mostat &= ~(UART_MCR_RTS); ch->ch_mostat &= ~(UART_MCR_RTS);
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock,
flags);
} }
} else { } else {
if (cause & UART_MCR_DTR) { 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; ch->ch_mostat |= UART_MCR_DTR;
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock,
flags);
} else { } else {
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock,
flags);
ch->ch_mostat &= ~(UART_MCR_DTR); 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) ...@@ -516,7 +528,7 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port)
{ {
struct channel_t *ch; struct channel_t *ch;
int linestatus; int linestatus;
ulong lock_flags; unsigned long flags;
if (!brd) if (!brd)
return; return;
...@@ -540,9 +552,9 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port) ...@@ -540,9 +552,9 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port)
ch->ch_intr_rx++; ch->ch_intr_rx++;
/* Read data from uart -> queue */ /* Read data from uart -> queue */
neo_copy_data_from_uart_to_queue(ch); 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_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) ...@@ -572,18 +584,18 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port)
if (linestatus & UART_LSR_THRE) { if (linestatus & UART_LSR_THRE) {
brd->intr_tx++; brd->intr_tx++;
ch->ch_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); 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. */ /* Transfer data (if any) from Write Queue -> UART. */
neo_copy_data_from_queue_to_uart(ch); neo_copy_data_from_queue_to_uart(ch);
} else if (linestatus & UART_17158_TX_AND_FIFO_CLR) { } else if (linestatus & UART_17158_TX_AND_FIFO_CLR) {
brd->intr_tx++; brd->intr_tx++;
ch->ch_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); 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. */ /* Transfer data (if any) from Write Queue -> UART. */
neo_copy_data_from_queue_to_uart(ch); neo_copy_data_from_queue_to_uart(ch);
...@@ -852,7 +864,7 @@ static void neo_tasklet(unsigned long data) ...@@ -852,7 +864,7 @@ static void neo_tasklet(unsigned long data)
{ {
struct dgnc_board *bd = (struct dgnc_board *) data; struct dgnc_board *bd = (struct dgnc_board *) data;
struct channel_t *ch; struct channel_t *ch;
ulong lock_flags; unsigned long flags;
int i; int i;
int state = 0; int state = 0;
int ports = 0; int ports = 0;
...@@ -863,16 +875,16 @@ static void neo_tasklet(unsigned long data) ...@@ -863,16 +875,16 @@ static void neo_tasklet(unsigned long data)
} }
/* Cache a couple board values */ /* Cache a couple board values */
DGNC_LOCK(bd->bd_lock, lock_flags); spin_lock_irqsave(&bd->bd_lock, flags);
state = bd->state; state = bd->state;
ports = bd->nasync; 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 * Do NOT allow the interrupt routine to read the intr registers
* Until we release this lock. * 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. * 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) ...@@ -921,7 +933,7 @@ static void neo_tasklet(unsigned long data)
} }
/* Allow interrupt routine to access the interrupt register again */ /* 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) ...@@ -940,8 +952,8 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
int current_port; int current_port;
u32 tmp; u32 tmp;
u32 uart_poll; u32 uart_poll;
unsigned long lock_flags; unsigned long flags;
unsigned long lock_flags2; unsigned long flags2;
if (!brd) { if (!brd) {
APR(("Received interrupt (%d) with null board associated\n", irq)); APR(("Received interrupt (%d) with null board associated\n", irq));
...@@ -959,7 +971,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd) ...@@ -959,7 +971,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
brd->intr_count++; brd->intr_count++;
/* Lock out the slow poller from running on this board. */ /* 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. * Read in "extended" IRQ information from the 32bit Neo register.
...@@ -973,7 +985,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd) ...@@ -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. * This can happen if the IRQ is shared among a couple Neo/Classic boards.
*/ */
if (!uart_poll) { if (!uart_poll) {
DGNC_UNLOCK(brd->bd_intr_lock, lock_flags); spin_unlock_irqrestore(&brd->bd_intr_lock, flags);
return IRQ_NONE; return IRQ_NONE;
} }
...@@ -1021,9 +1033,9 @@ static irqreturn_t neo_intr(int irq, void *voidbrd) ...@@ -1021,9 +1033,9 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
neo_copy_data_from_uart_to_queue(ch); neo_copy_data_from_uart_to_queue(ch);
/* Call our tty layer to enforce queue flow control if needed. */ /* 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_check_queue_flow_control(ch);
DGNC_UNLOCK(ch->ch_lock, lock_flags2); spin_unlock_irqrestore(&ch->ch_lock, flags2);
continue; continue;
...@@ -1073,7 +1085,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd) ...@@ -1073,7 +1085,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
*/ */
tasklet_schedule(&brd->helper_tasklet); tasklet_schedule(&brd->helper_tasklet);
DGNC_UNLOCK(brd->bd_intr_lock, lock_flags); spin_unlock_irqrestore(&brd->bd_intr_lock, flags);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -1118,12 +1130,12 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) ...@@ -1118,12 +1130,12 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch)
int total = 0; int total = 0;
ushort head; ushort head;
ushort tail; ushort tail;
ulong lock_flags; unsigned long flags;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return; return;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
/* cache head and tail of queue */ /* cache head and tail of queue */
head = ch->ch_r_head & RQUEUEMASK; head = ch->ch_r_head & RQUEUEMASK;
...@@ -1316,7 +1328,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) ...@@ -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_r_head = head & RQUEUEMASK;
ch->ch_e_head = head & EQUEUEMASK; 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) ...@@ -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) static int neo_drain(struct tty_struct *tty, uint seconds)
{ {
ulong lock_flags; unsigned long flags;
struct channel_t *ch; struct channel_t *ch;
struct un_t *un; struct un_t *un;
int rc = 0; int rc = 0;
...@@ -1342,9 +1354,9 @@ static int neo_drain(struct tty_struct *tty, uint seconds) ...@@ -1342,9 +1354,9 @@ static int neo_drain(struct tty_struct *tty, uint seconds)
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return -ENXIO; return -ENXIO;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
un->un_flags |= UN_EMPTY; 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 * 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) ...@@ -1425,22 +1437,22 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
int s; int s;
int qlen; int qlen;
uint len_written = 0; uint len_written = 0;
ulong lock_flags; unsigned long flags;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return; return;
DGNC_LOCK(ch->ch_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, flags);
/* No data to write to the UART */ /* No data to write to the UART */
if (ch->ch_w_tail == ch->ch_w_head) { if (ch->ch_w_tail == ch->ch_w_head) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return; return;
} }
/* If port is "stopped", don't send any data to the UART */ /* 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)) { 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; return;
} }
...@@ -1483,7 +1495,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch) ...@@ -1483,7 +1495,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
ch->ch_w_tail &= WQUEUEMASK; ch->ch_w_tail &= WQUEUEMASK;
ch->ch_txcount++; ch->ch_txcount++;
} }
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return; return;
} }
...@@ -1492,7 +1504,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch) ...@@ -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_bd->dvid & 0xf0) < UART_XR17E158_DVID) {
if (!(ch->ch_flags & (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM))) { 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; return;
} }
...@@ -1501,7 +1513,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch) ...@@ -1501,7 +1513,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
n = readb(&ch->ch_neo_uart->tfifo); n = readb(&ch->ch_neo_uart->tfifo);
if ((unsigned int) n > ch->ch_t_tlevel) { if ((unsigned int) n > ch->ch_t_tlevel) {
DGNC_UNLOCK(ch->ch_lock, lock_flags); spin_unlock_irqrestore(&ch->ch_lock, flags);
return; return;
} }
...@@ -1568,7 +1580,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch) ...@@ -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); 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);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册