From: Daniel Thompson <daniel.thompson@linaro.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-serial@vger.kernel.org
Cc: patches@linaro.org, linaro-kernel@lists.linaro.org,
Daniel Thompson <daniel.thompson@linaro.org>,
linux-kernel@vger.kernel.org,
John Stultz <john.stultz@linaro.org>,
Anton Vorontsov <anton.vorontsov@linaro.org>,
Colin Cross <ccross@android.com>,
kernel-team@android.com,
Jason Wessel <jason.wessel@windriver.com>,
kgdb-bugreport@lists.sourceforge.net, Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 2/4] serial: kgdb_nmi: Use container_of() to locate private data
Date: Wed, 14 May 2014 15:55:33 +0100 [thread overview]
Message-ID: <1400079335-32125-3-git-send-email-daniel.thompson@linaro.org> (raw)
In-Reply-To: <1400079335-32125-1-git-send-email-daniel.thompson@linaro.org>
This corrects a crash in kgdb_nmi_tty_shutdown() which occurs when
the function is called with port->tty set to NULL.
All conversions between struct tty_port and struct kgdb_nmi_tty_priv
have been switched to direct calls to container_of() to improve code
clarity and consistancy.
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
---
drivers/tty/serial/kgdb_nmi.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
index 5f673b7..d51b2a1 100644
--- a/drivers/tty/serial/kgdb_nmi.c
+++ b/drivers/tty/serial/kgdb_nmi.c
@@ -84,11 +84,6 @@ struct kgdb_nmi_tty_priv {
STRUCT_KFIFO(char, KGDB_NMI_FIFO_SIZE) fifo;
};
-static struct kgdb_nmi_tty_priv *kgdb_nmi_port_to_priv(struct tty_port *port)
-{
- return container_of(port, struct kgdb_nmi_tty_priv, port);
-}
-
/*
* Our debugging console is polled in a tasklet, so we'll check for input
* every tick. In HZ-less mode, we should program the next tick. We have
@@ -118,7 +113,7 @@ static void kgdb_tty_recv(int ch)
* do that, and actually, we can't: we're in NMI context, no locks are
* possible.
*/
- priv = kgdb_nmi_port_to_priv(kgdb_nmi_port);
+ priv = container_of(kgdb_nmi_port, struct kgdb_nmi_tty_priv, port);
kfifo_in(&priv->fifo, &c, 1);
kgdb_tty_poke();
}
@@ -216,7 +211,8 @@ static void kgdb_nmi_tty_receiver(unsigned long data)
static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty)
{
- struct kgdb_nmi_tty_priv *priv = tty->driver_data;
+ struct kgdb_nmi_tty_priv *priv =
+ container_of(port, struct kgdb_nmi_tty_priv, port);
kgdb_nmi_port = port;
tasklet_schedule(&priv->tlet);
@@ -225,7 +221,8 @@ static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty)
static void kgdb_nmi_tty_shutdown(struct tty_port *port)
{
- struct kgdb_nmi_tty_priv *priv = port->tty->driver_data;
+ struct kgdb_nmi_tty_priv *priv =
+ container_of(port, struct kgdb_nmi_tty_priv, port);
tasklet_kill(&priv->tlet);
kgdb_nmi_port = NULL;
--
1.9.0
next prev parent reply other threads:[~2014-05-14 14:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-14 14:55 [PATCH 0/4] serial: kgdb_nmi: Allow ttyNMIX to act as primary console Daniel Thompson
2014-05-14 14:55 ` [PATCH 1/4] serial: core: Consistent LF handling for poll_put_char Daniel Thompson
2014-05-14 15:08 ` Jason Wessel
2014-05-15 11:06 ` Daniel Thompson
2014-05-28 20:03 ` Greg Kroah-Hartman
2014-05-29 8:48 ` [PATCH tty-next v2 0/4] serial: kgdb_nmi: Allow ttyNMIX to act as primary console Daniel Thompson
2014-05-29 8:48 ` [PATCH tty-next v2 1/4] serial: cpm_uart: No LF conversion in put_poll_char() Daniel Thompson
2014-05-29 8:48 ` [PATCH tty-next v2 2/4] serial: kgdb_nmi: Use container_of() to locate private data Daniel Thompson
2014-05-29 8:48 ` [PATCH tty-next v2 3/4] serial: kgdb_nmi: Switch from tasklets to real timers Daniel Thompson
2014-05-29 8:48 ` [PATCH tty-next v2 4/4] serial: kgdb_nmi: Improve console integration with KDB I/O Daniel Thompson
2014-05-14 14:55 ` Daniel Thompson [this message]
2014-05-14 14:55 ` [PATCH 3/4] serial: kgdb_nmi: Switch from tasklets to real timers Daniel Thompson
2014-05-14 14:55 ` [PATCH 4/4] serial: kgdb_nmi: Improve console integration with KDB I/O Daniel Thompson
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=1400079335-32125-3-git-send-email-daniel.thompson@linaro.org \
--to=daniel.thompson@linaro.org \
--cc=anton.vorontsov@linaro.org \
--cc=ccross@android.com \
--cc=gregkh@linuxfoundation.org \
--cc=jason.wessel@windriver.com \
--cc=john.stultz@linaro.org \
--cc=jslaby@suse.cz \
--cc=kernel-team@android.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=patches@linaro.org \
/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).