staging: dgnc: 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 <roberta.dobrescu@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
8f3a2e04e3
commit
707505b58e
@ -367,16 +367,16 @@ static inline void cls_set_no_input_flow_control(struct channel_t *ch)
|
|||||||
*/
|
*/
|
||||||
static inline void cls_clear_break(struct channel_t *ch, int force)
|
static inline void cls_clear_break(struct channel_t *ch, int force)
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
|
||||||
/* 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 cls_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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
|
|||||||
{
|
{
|
||||||
struct channel_t *ch;
|
struct channel_t *ch;
|
||||||
uchar isr = 0;
|
uchar isr = 0;
|
||||||
ulong lock_flags;
|
unsigned long flags;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No need to verify board pointer, it was already
|
* No need to verify board pointer, it was already
|
||||||
@ -434,11 +434,11 @@ static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
|
|||||||
/* Transmit Hold register empty pending */
|
/* Transmit Hold register empty pending */
|
||||||
if (isr & UART_IIR_THRI) {
|
if (isr & UART_IIR_THRI) {
|
||||||
/* 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);
|
||||||
brd->intr_tx++;
|
brd->intr_tx++;
|
||||||
ch->ch_intr_tx++;
|
ch->ch_intr_tx++;
|
||||||
DGNC_UNLOCK(ch->ch_lock, lock_flags);
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
||||||
cls_copy_data_from_queue_to_uart(ch);
|
cls_copy_data_from_queue_to_uart(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,7 +719,7 @@ static void cls_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;
|
||||||
@ -730,16 +730,16 @@ static void cls_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.
|
||||||
@ -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, flags);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,7 +797,7 @@ static irqreturn_t cls_intr(int irq, void *voidbrd)
|
|||||||
struct dgnc_board *brd = (struct dgnc_board *) voidbrd;
|
struct dgnc_board *brd = (struct dgnc_board *) voidbrd;
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
uchar poll_reg;
|
uchar poll_reg;
|
||||||
unsigned long lock_flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (!brd) {
|
if (!brd) {
|
||||||
APR(("Received interrupt (%d) with null board associated\n",
|
APR(("Received interrupt (%d) with null board associated\n",
|
||||||
@ -814,7 +814,7 @@ static irqreturn_t cls_intr(int irq, void *voidbrd)
|
|||||||
return IRQ_NONE;
|
return IRQ_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DGNC_LOCK(brd->bd_intr_lock, lock_flags);
|
spin_lock_irqsave(&brd->bd_intr_lock, flags);
|
||||||
|
|
||||||
brd->intr_count++;
|
brd->intr_count++;
|
||||||
|
|
||||||
@ -826,7 +826,7 @@ static irqreturn_t cls_intr(int irq, void *voidbrd)
|
|||||||
|
|
||||||
/* If 0, no interrupts pending */
|
/* If 0, no interrupts pending */
|
||||||
if (!poll_reg) {
|
if (!poll_reg) {
|
||||||
DGNC_UNLOCK(brd->bd_intr_lock, lock_flags);
|
spin_unlock_irqrestore(&brd->bd_intr_lock, flags);
|
||||||
return IRQ_NONE;
|
return IRQ_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -839,7 +839,7 @@ static irqreturn_t cls_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;
|
||||||
}
|
}
|
||||||
@ -870,12 +870,12 @@ static void cls_copy_data_from_uart_to_queue(struct channel_t *ch)
|
|||||||
uchar error_mask = 0;
|
uchar error_mask = 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;
|
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_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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -961,7 +961,7 @@ static void cls_copy_data_from_uart_to_queue(struct channel_t *ch)
|
|||||||
*/
|
*/
|
||||||
static int cls_drain(struct tty_struct *tty, uint seconds)
|
static int cls_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;
|
||||||
@ -977,9 +977,9 @@ static int cls_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);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: Do something with time passed in.
|
* NOTE: Do something with time passed in.
|
||||||
@ -1035,28 +1035,28 @@ static void cls_copy_data_from_queue_to_uart(struct channel_t *ch)
|
|||||||
int n;
|
int n;
|
||||||
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) ||
|
if ((ch->ch_flags & CH_FORCED_STOP) ||
|
||||||
(ch->ch_flags & CH_BREAK_SENDING)) {
|
(ch->ch_flags & CH_BREAK_SENDING)) {
|
||||||
DGNC_UNLOCK(ch->ch_lock, lock_flags);
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1110,14 +1110,14 @@ static void cls_copy_data_from_queue_to_uart(struct channel_t *ch)
|
|||||||
if (len_written > 0)
|
if (len_written > 0)
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void cls_parse_modem(struct channel_t *ch, uchar signals)
|
static void cls_parse_modem(struct channel_t *ch, uchar signals)
|
||||||
{
|
{
|
||||||
uchar msignals = signals;
|
uchar msignals = signals;
|
||||||
ulong lock_flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
||||||
return;
|
return;
|
||||||
@ -1126,7 +1126,7 @@ static void cls_parse_modem(struct channel_t *ch, uchar signals)
|
|||||||
* Do altpin switching. Altpin switches DCD and DSR.
|
* Do altpin switching. Altpin switches DCD and DSR.
|
||||||
* This prolly breaks DSRPACE, so we should be more clever here.
|
* This prolly breaks DSRPACE, so we should be more clever here.
|
||||||
*/
|
*/
|
||||||
DGNC_LOCK(ch->ch_lock, lock_flags);
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
||||||
if (ch->ch_digi.digi_flags & DIGI_ALTPIN) {
|
if (ch->ch_digi.digi_flags & DIGI_ALTPIN) {
|
||||||
uchar mswap = signals;
|
uchar mswap = signals;
|
||||||
|
|
||||||
@ -1147,7 +1147,7 @@ static void cls_parse_modem(struct channel_t *ch, uchar signals)
|
|||||||
msignals |= UART_MSR_DCD;
|
msignals |= UART_MSR_DCD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DGNC_UNLOCK(ch->ch_lock, lock_flags);
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scrub off lower bits. They signify delta's, which I don't
|
* 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;
|
signals &= 0xf0;
|
||||||
|
|
||||||
DGNC_LOCK(ch->ch_lock, lock_flags);
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
||||||
if (msignals & UART_MSR_DCD)
|
if (msignals & UART_MSR_DCD)
|
||||||
ch->ch_mistat |= UART_MSR_DCD;
|
ch->ch_mistat |= UART_MSR_DCD;
|
||||||
else
|
else
|
||||||
@ -1175,7 +1175,7 @@ static void cls_parse_modem(struct channel_t *ch, uchar signals)
|
|||||||
ch->ch_mistat |= UART_MSR_CTS;
|
ch->ch_mistat |= UART_MSR_CTS;
|
||||||
else
|
else
|
||||||
ch->ch_mistat &= ~UART_MSR_CTS;
|
ch->ch_mistat &= ~UART_MSR_CTS;
|
||||||
DGNC_UNLOCK(ch->ch_lock, lock_flags);
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user