Commit ef510bea authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman

serial: core: don't check port twice in a row

There is no need to check port for NULL in uart_port_deref() since we call it
only when port is defined.

There are few places that violate this. Fix them here as well.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b8106454
...@@ -73,7 +73,7 @@ static inline struct uart_port *uart_port_ref(struct uart_state *state) ...@@ -73,7 +73,7 @@ static inline struct uart_port *uart_port_ref(struct uart_state *state)
static inline void uart_port_deref(struct uart_port *uport) static inline void uart_port_deref(struct uart_port *uport)
{ {
if (uport && atomic_dec_and_test(&uport->state->refcount)) if (atomic_dec_and_test(&uport->state->refcount))
wake_up(&uport->state->remove_wait); wake_up(&uport->state->remove_wait);
} }
...@@ -88,9 +88,10 @@ static inline void uart_port_deref(struct uart_port *uport) ...@@ -88,9 +88,10 @@ static inline void uart_port_deref(struct uart_port *uport)
#define uart_port_unlock(uport, flags) \ #define uart_port_unlock(uport, flags) \
({ \ ({ \
struct uart_port *__uport = uport; \ struct uart_port *__uport = uport; \
if (__uport) \ if (__uport) { \
spin_unlock_irqrestore(&__uport->lock, flags); \ spin_unlock_irqrestore(&__uport->lock, flags); \
uart_port_deref(__uport); \ uart_port_deref(__uport); \
} \
}) })
static inline struct uart_port *uart_port_check(struct uart_state *state) static inline struct uart_port *uart_port_check(struct uart_state *state)
...@@ -1515,7 +1516,10 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout) ...@@ -1515,7 +1516,10 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
unsigned long char_time, expire; unsigned long char_time, expire;
port = uart_port_ref(state); port = uart_port_ref(state);
if (!port || port->type == PORT_UNKNOWN || port->fifosize == 0) { if (!port)
return;
if (port->type == PORT_UNKNOWN || port->fifosize == 0) {
uart_port_deref(port); uart_port_deref(port);
return; return;
} }
...@@ -2365,9 +2369,10 @@ static int uart_poll_get_char(struct tty_driver *driver, int line) ...@@ -2365,9 +2369,10 @@ static int uart_poll_get_char(struct tty_driver *driver, int line)
if (state) { if (state) {
port = uart_port_ref(state); port = uart_port_ref(state);
if (port) if (port) {
ret = port->ops->poll_get_char(port); ret = port->ops->poll_get_char(port);
uart_port_deref(port); uart_port_deref(port);
}
} }
return ret; return ret;
} }
......
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