Commit c84a083b authored by Quentin Lambert's avatar Quentin Lambert Committed by Greg Kroah-Hartman

Staging: dgnc: Use goto for spinlock release before return

spin_unlock_irqrestore() is called at several
different places before exiting. This patch uses a goto statement
to factorize these calls.

Coccinelle was used to generate this patch.
Signed-off-by: default avatarQuentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f6a14cf0
...@@ -492,7 +492,7 @@ void dgnc_input(struct channel_t *ch) ...@@ -492,7 +492,7 @@ void dgnc_input(struct channel_t *ch)
{ {
struct dgnc_board *bd; struct dgnc_board *bd;
struct tty_struct *tp; struct tty_struct *tp;
struct tty_ldisc *ld; struct tty_ldisc *ld = NULL;
uint rmask; uint rmask;
ushort head; ushort head;
ushort tail; ushort tail;
...@@ -524,10 +524,8 @@ void dgnc_input(struct channel_t *ch) ...@@ -524,10 +524,8 @@ void dgnc_input(struct channel_t *ch)
tail = ch->ch_r_tail & rmask; tail = ch->ch_r_tail & rmask;
data_len = (head - tail) & rmask; data_len = (head - tail) & rmask;
if (data_len == 0) { if (data_len == 0)
spin_unlock_irqrestore(&ch->ch_lock, flags); goto exit_unlock;
return;
}
/* /*
* If the device is not open, or CREAD is off, * If the device is not open, or CREAD is off,
...@@ -541,17 +539,14 @@ void dgnc_input(struct channel_t *ch) ...@@ -541,17 +539,14 @@ void dgnc_input(struct channel_t *ch)
/* Force queue flow control to be released, if needed */ /* Force queue flow control to be released, if needed */
dgnc_check_queue_flow_control(ch); dgnc_check_queue_flow_control(ch);
spin_unlock_irqrestore(&ch->ch_lock, flags); goto exit_unlock;
return;
} }
/* /*
* If we are throttled, simply don't read any data. * If we are throttled, simply don't read any data.
*/ */
if (ch->ch_flags & CH_FORCED_STOPI) { if (ch->ch_flags & CH_FORCED_STOPI)
spin_unlock_irqrestore(&ch->ch_lock, flags); goto exit_unlock;
return;
}
flip_len = TTY_FLIPBUF_SIZE; flip_len = TTY_FLIPBUF_SIZE;
...@@ -589,12 +584,8 @@ void dgnc_input(struct channel_t *ch) ...@@ -589,12 +584,8 @@ void dgnc_input(struct channel_t *ch)
} }
} }
if (len <= 0) { if (len <= 0)
spin_unlock_irqrestore(&ch->ch_lock, flags); goto exit_unlock;
if (ld)
tty_ldisc_deref(ld);
return;
}
/* /*
* The tty layer in the kernel has changed in 2.6.16+. * The tty layer in the kernel has changed in 2.6.16+.
...@@ -662,6 +653,12 @@ void dgnc_input(struct channel_t *ch) ...@@ -662,6 +653,12 @@ void dgnc_input(struct channel_t *ch)
if (ld) if (ld)
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
return;
exit_unlock:
if (ld)
tty_ldisc_deref(ld);
spin_unlock_irqrestore(&ch->ch_lock, flags);
} }
...@@ -1758,10 +1755,8 @@ static int dgnc_tty_write(struct tty_struct *tty, ...@@ -1758,10 +1755,8 @@ static int dgnc_tty_write(struct tty_struct *tty,
/* /*
* Bail if no space left. * Bail if no space left.
*/ */
if (count <= 0) { if (count <= 0)
spin_unlock_irqrestore(&ch->ch_lock, flags); goto exit_retry;
return 0;
}
/* /*
* Output the printer ON string, if we are in terminal mode, but * Output the printer ON string, if we are in terminal mode, but
...@@ -1788,10 +1783,8 @@ static int dgnc_tty_write(struct tty_struct *tty, ...@@ -1788,10 +1783,8 @@ 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 there is nothing left to copy, or I can't handle any more data, leave.
*/ */
if (count <= 0) { if (count <= 0)
spin_unlock_irqrestore(&ch->ch_lock, flags); goto exit_retry;
return 0;
}
if (from_user) { if (from_user) {
...@@ -1877,6 +1870,11 @@ static int dgnc_tty_write(struct tty_struct *tty, ...@@ -1877,6 +1870,11 @@ static int dgnc_tty_write(struct tty_struct *tty,
} }
return count; return count;
exit_retry:
spin_unlock_irqrestore(&ch->ch_lock, flags);
return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment