From: Peter Hurley <peter@hurleysoftware.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
Peter Hurley <peter@hurleysoftware.com>
Subject: [PATCH 3/7] tty: Replace #ifdef TTY_DEBUG_HANGUP with tty_debug_hangup()
Date: Sun, 12 Jul 2015 22:49:09 -0400 [thread overview]
Message-ID: <1436755753-7746-4-git-send-email-peter@hurleysoftware.com> (raw)
In-Reply-To: <1436755753-7746-1-git-send-email-peter@hurleysoftware.com>
Add tty_debug_hangup() macro which uses tty_debug to print the
debug message; remove inlined #ifdefs.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
drivers/tty/tty_io.c | 47 ++++++++++++++++++-----------------------------
1 file changed, 18 insertions(+), 29 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 6de2c36..acd6988 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -106,6 +106,11 @@
#include <linux/nsproxy.h>
#undef TTY_DEBUG_HANGUP
+#ifdef TTY_DEBUG_HANGUP
+# define tty_debug_hangup(tty, f, args...) tty_debug(tty, f, ##args)
+#else
+# define tty_debug_hangup(tty, f, args...) do { } while (0)
+#endif
#define TTY_PARANOIA_CHECK 1
#define CHECK_TTY_COUNT 1
@@ -767,9 +772,7 @@ static void do_tty_hangup(struct work_struct *work)
void tty_hangup(struct tty_struct *tty)
{
-#ifdef TTY_DEBUG_HANGUP
- tty_debug(tty, "\n");
-#endif
+ tty_debug_hangup(tty, "\n");
schedule_work(&tty->hangup_work);
}
@@ -786,9 +789,7 @@ EXPORT_SYMBOL(tty_hangup);
void tty_vhangup(struct tty_struct *tty)
{
-#ifdef TTY_DEBUG_HANGUP
- tty_debug(tty, "\n")
-#endif
+ tty_debug_hangup(tty, "\n");
__tty_hangup(tty, 0);
}
@@ -825,9 +826,7 @@ void tty_vhangup_self(void)
static void tty_vhangup_session(struct tty_struct *tty)
{
-#ifdef TTY_DEBUG_HANGUP
- tty_debug(tty, "\n");
-#endif
+ tty_debug_hangup(tty, "\n");
__tty_hangup(tty, 1);
}
@@ -921,11 +920,8 @@ void disassociate_ctty(int on_exit)
tty->pgrp = NULL;
spin_unlock_irqrestore(&tty->ctrl_lock, flags);
tty_kref_put(tty);
- } else {
-#ifdef TTY_DEBUG_HANGUP
- tty_debug(tty, "no current tty\n");
-#endif
- }
+ } else
+ tty_debug_hangup(tty, "no current tty\n");
spin_unlock_irq(¤t->sighand->siglock);
/* Now clear signal->tty under the lock */
@@ -1781,9 +1777,7 @@ int tty_release(struct inode *inode, struct file *filp)
return 0;
}
-#ifdef TTY_DEBUG_HANGUP
- tty_debug(tty, "(tty count=%d)...\n", tty->count);
-#endif
+ tty_debug_hangup(tty, "(tty count=%d)...\n", tty->count);
if (tty->ops->close)
tty->ops->close(tty, filp);
@@ -1893,9 +1887,7 @@ int tty_release(struct inode *inode, struct file *filp)
if (!final)
return 0;
-#ifdef TTY_DEBUG_HANGUP
- tty_debug(tty, "final close\n");
-#endif
+ tty_debug_hangup(tty, "final close\n");
/*
* Ask the line discipline code to release its structures
*/
@@ -1904,9 +1896,7 @@ int tty_release(struct inode *inode, struct file *filp)
/* Wait for pending work before tty destruction commmences */
tty_flush_works(tty);
-#ifdef TTY_DEBUG_HANGUP
- tty_debug(tty, "freeing structure...\n");
-#endif
+ tty_debug_hangup(tty, "freeing structure...\n");
/*
* The release_tty function takes care of the details of clearing
* the slots and preserving the termios structure. The tty_unlock_pair
@@ -2095,9 +2085,9 @@ retry_open:
if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
tty->driver->subtype == PTY_TYPE_MASTER)
noctty = 1;
-#ifdef TTY_DEBUG_HANGUP
- tty_debug(tty, "(tty count=%d)\n", tty->count);
-#endif
+
+ tty_debug_hangup(tty, "(tty count=%d)\n", tty->count);
+
if (tty->ops->open)
retval = tty->ops->open(tty, filp);
else
@@ -2105,9 +2095,8 @@ retry_open:
filp->f_flags = saved_flags;
if (retval) {
-#ifdef TTY_DEBUG_HANGUP
- tty_debug(tty, "error %d, releasing...\n", retval);
-#endif
+ tty_debug_hangup(tty, "error %d, releasing...\n", retval);
+
tty_unlock(tty); /* need to call tty_release without BTM */
tty_release(inode, filp);
if (retval != -ERESTARTSYS)
--
2.4.5
next prev parent reply other threads:[~2015-07-13 2:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-13 2:49 [PATCH 0/7] tty core debug patches Peter Hurley
2015-07-13 2:49 ` [PATCH 1/7] tty: core: Improve debug message content Peter Hurley
2015-07-13 2:49 ` [PATCH 2/7] tty: core: Add tty_debug() for printk(KERN_DEBUG) messages Peter Hurley
2015-07-13 3:47 ` Joe Perches
2015-07-13 4:25 ` Peter Hurley
2015-07-13 4:30 ` Joe Perches
2015-07-13 4:40 ` Peter Hurley
2015-07-24 1:35 ` Greg Kroah-Hartman
2015-08-05 18:33 ` Peter Hurley
2015-08-05 19:22 ` Greg Kroah-Hartman
2015-07-13 2:49 ` Peter Hurley [this message]
2015-07-13 2:49 ` [PATCH 4/7] tty: Use tty_debug() for tty_ldisc_debug() Peter Hurley
2015-07-13 2:49 ` [PATCH 5/7] tty: Replace inline #ifdef TTY_DEBUG_WAIT_UNTIL_SENT Peter Hurley
2015-07-13 2:49 ` [PATCH 6/7] tty: core: Improve ldisc debug messages Peter Hurley
2015-07-13 2:49 ` [PATCH 7/7] pty: Add debug message for ptmx open Peter Hurley
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=1436755753-7746-4-git-send-email-peter@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.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).