TTY: sn_console: Replace spin_is_locked() with spin_trylock()
sn_sal_console_write() used spin_is_locked() + spin_lock() to get achieve the same thing as a spin_trylock(), so simplify it by using that instead. This is also a step towards possibly removing spin_is_locked(). Signed-off-by: Lance Roy <ldr709@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.com> Cc: <linux-serial@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
817e9bc8cc
commit
8ebfe885c6
|
@ -888,7 +888,7 @@ sn_sal_console_write(struct console *co, const char *s, unsigned count)
|
||||||
|
|
||||||
/* somebody really wants this output, might be an
|
/* somebody really wants this output, might be an
|
||||||
* oops, kdb, panic, etc. make sure they get it. */
|
* oops, kdb, panic, etc. make sure they get it. */
|
||||||
if (spin_is_locked(&port->sc_port.lock)) {
|
if (!spin_trylock_irqsave(&port->sc_port.lock, flags)) {
|
||||||
int lhead = port->sc_port.state->xmit.head;
|
int lhead = port->sc_port.state->xmit.head;
|
||||||
int ltail = port->sc_port.state->xmit.tail;
|
int ltail = port->sc_port.state->xmit.tail;
|
||||||
int counter, got_lock = 0;
|
int counter, got_lock = 0;
|
||||||
|
@ -905,13 +905,11 @@ sn_sal_console_write(struct console *co, const char *s, unsigned count)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (counter = 0; counter < 150; mdelay(125), counter++) {
|
for (counter = 0; counter < 150; mdelay(125), counter++) {
|
||||||
if (!spin_is_locked(&port->sc_port.lock)
|
if (stole_lock)
|
||||||
|| stole_lock) {
|
break;
|
||||||
if (!stole_lock) {
|
|
||||||
spin_lock_irqsave(&port->sc_port.lock,
|
if (spin_trylock_irqsave(&port->sc_port.lock, flags)) {
|
||||||
flags);
|
got_lock = 1;
|
||||||
got_lock = 1;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
/* still locked */
|
/* still locked */
|
||||||
|
@ -938,7 +936,6 @@ sn_sal_console_write(struct console *co, const char *s, unsigned count)
|
||||||
puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
|
puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
|
||||||
} else {
|
} else {
|
||||||
stole_lock = 0;
|
stole_lock = 0;
|
||||||
spin_lock_irqsave(&port->sc_port.lock, flags);
|
|
||||||
sn_transmit_chars(port, 1);
|
sn_transmit_chars(port, 1);
|
||||||
spin_unlock_irqrestore(&port->sc_port.lock, flags);
|
spin_unlock_irqrestore(&port->sc_port.lock, flags);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue