Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1480416

[PATCH 6/9] tty: serial_core: introduce tty_port_to_uart_state

From Rob Herring <robh@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 6/9] tty: serial_core: introduce tty_port_to_uart_state
Date 2016-09-10 00:40 +0200
Message-ID <sfCCJ-mH-13@gated-at.bofh.it> (permalink)
References <sfCCJ-mH-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The uart_state is a container of tty_port. Add an inline to convert
tty_port ptr to uart_state ptr and convert existing container_of users.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/tty/serial/serial_core.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index d48ea0a98e92..29eef4644e98 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -93,6 +93,11 @@ static inline void uart_port_deref(struct uart_port *uport)
 		uart_port_deref(__uport);				\
 	})
 
+static inline struct uart_state *tty_port_to_uart_state(struct tty_port *port)
+{
+	return container_of(port, struct uart_state, port);
+}
+
 static inline struct uart_port *uart_port_check(struct uart_state *state)
 {
 	lockdep_assert_held(&state->port.mutex);
@@ -720,7 +725,7 @@ static void uart_unthrottle(struct tty_struct *tty)
 
 static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo)
 {
-	struct uart_state *state = container_of(port, struct uart_state, port);
+	struct uart_state *state = tty_port_to_uart_state(port);
 	struct uart_port *uport;
 	int ret = -ENODEV;
 
@@ -1603,7 +1608,7 @@ static void uart_hangup(struct tty_struct *tty)
 /* uport == NULL if uart_port has already been removed */
 static void uart_port_shutdown(struct tty_port *port)
 {
-	struct uart_state *state = container_of(port, struct uart_state, port);
+	struct uart_state *state = tty_port_to_uart_state(port);
 	struct uart_port *uport = uart_port_check(state);
 
 	/*
@@ -1630,7 +1635,7 @@ static void uart_port_shutdown(struct tty_port *port)
 
 static int uart_carrier_raised(struct tty_port *port)
 {
-	struct uart_state *state = container_of(port, struct uart_state, port);
+	struct uart_state *state = tty_port_to_uart_state(port);
 	struct uart_port *uport;
 	int mctrl;
 
@@ -1655,7 +1660,7 @@ static int uart_carrier_raised(struct tty_port *port)
 
 static void uart_dtr_rts(struct tty_port *port, int onoff)
 {
-	struct uart_state *state = container_of(port, struct uart_state, port);
+	struct uart_state *state = tty_port_to_uart_state(port);
 	struct uart_port *uport;
 
 	uport = uart_port_ref(state);
-- 
2.9.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring <robh@kernel.org> - 2016-09-10 00:40 +0200
  [PATCH 5/9] tty: serial_core: use tty_port_tty_wakeup instead of tty_wakeup Rob Herring <robh@kernel.org> - 2016-09-10 00:40 +0200
  [PATCH 6/9] tty: serial_core: introduce tty_port_to_uart_state Rob Herring <robh@kernel.org> - 2016-09-10 00:40 +0200
  [PATCH 1/9] tty: serial_core: add tty NULL check to uart_tx_stopped Rob Herring <robh@kernel.org> - 2016-09-10 00:40 +0200
  [PATCH 3/9] tty: move hw_stopped flag to tty_port Rob Herring <robh@kernel.org> - 2016-09-10 00:40 +0200
    Re: [PATCH 3/9] tty: move hw_stopped flag to tty_port One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-09-11 23:20 +0200
  [PATCH 4/9] tty: move TTY_IO_ERROR flag to tty_port iflags Rob Herring <robh@kernel.org> - 2016-09-10 00:40 +0200
    Re: [PATCH 4/9] tty: move TTY_IO_ERROR flag to tty_port iflags One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-09-11 23:20 +0200
  [PATCH 8/9] tty: serial_core: remove dependence on tty->driver_data Rob Herring <robh@kernel.org> - 2016-09-10 00:40 +0200
  Re: [PATCH 2/9] tty: remove tty_struct dependency in tty flag macros Rob Herring <robh@kernel.org> - 2016-09-10 03:10 +0200
  Re: [PATCH 0/9] tty: tty_struct dependency clean-ups One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-09-11 23:20 +0200
    Re: [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring <robh@kernel.org> - 2016-09-12 05:10 +0200
      Re: [PATCH 0/9] tty: tty_struct dependency clean-ups One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-09-12 13:50 +0200
  Re: [PATCH 0/9] tty: tty_struct dependency clean-ups Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-15 12:50 +0200

csiph-web