From: Rob Herring <robh@kernel.org>
To: Alan Cox <alan@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>,
Peter Hurley <peter@hurleysoftware.com>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: [PATCH 6/9] tty: serial_core: introduce tty_port_to_uart_state
Date: Fri, 9 Sep 2016 17:37:07 -0500 [thread overview]
Message-ID: <20160909223711.26238-7-robh@kernel.org> (raw)
In-Reply-To: <20160909223711.26238-1-robh@kernel.org>
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
next prev parent reply other threads:[~2016-09-09 22:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
2016-09-09 22:37 ` [PATCH 1/9] tty: serial_core: add tty NULL check to uart_tx_stopped Rob Herring
2016-09-09 22:37 ` [PATCH 2/9] tty: remove tty_struct dependency in tty flag macros Rob Herring
2016-09-10 1:02 ` Rob Herring
2016-09-09 22:37 ` [PATCH 3/9] tty: move hw_stopped flag to tty_port Rob Herring
2016-09-11 21:15 ` One Thousand Gnomes
2016-09-09 22:37 ` [PATCH 4/9] tty: move TTY_IO_ERROR flag to tty_port iflags Rob Herring
2016-09-11 21:18 ` One Thousand Gnomes
2016-09-09 22:37 ` [PATCH 5/9] tty: serial_core: use tty_port_tty_wakeup instead of tty_wakeup Rob Herring
2016-09-09 22:37 ` Rob Herring [this message]
2016-09-09 22:37 ` [PATCH 7/9] tty: serial_core: convert private functions to use tty_port instead of tty_struct Rob Herring
2016-09-09 22:37 ` [PATCH 8/9] tty: serial_core: remove dependence on tty->driver_data Rob Herring
2016-09-09 22:37 ` [PATCH 9/9] tty: serial_core: add tty NULL check in uart_port_startup Rob Herring
2016-09-11 21:20 ` One Thousand Gnomes
2016-09-11 21:14 ` [PATCH 0/9] tty: tty_struct dependency clean-ups One Thousand Gnomes
2016-09-12 3:05 ` Rob Herring
2016-09-12 11:46 ` One Thousand Gnomes
2016-09-15 10:43 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160909223711.26238-7-robh@kernel.org \
--to=robh@kernel.org \
--cc=alan@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=peter@hurleysoftware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).