All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Govindraj.R" <govindraj.raja@ti.com>
To: linux-serial@vger.kernel.org
Cc: linux-omap@vger.kernel.org, "Govindraj.R" <govindraj.raja@ti.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alan Cox <alan@linux.intel.com>
Subject: [PATCH] tty: serial_core: Add mechanism to identify port closure.
Date: Fri, 20 Apr 2012 16:27:53 +0530	[thread overview]
Message-ID: <1334919473-18870-1-git-send-email-govindraj.raja@ti.com> (raw)

From: "Govindraj.R" <govindraj.raja@ti.com>

Currently all low level uart driver register to serial_core layer
this core layer exposes various serial uart ops.

Currently the core layer provides startup and shutdown hooks
to low level driver, but in port suspend case the shutdown gets called
from uart_suspend_port this makes little difficult in low level driver
to any action specific to port closure.

For example if low level driver tries to disable uart platform
specific wakeups after port closure in low level driver it can be only done
in shutdown ops since this ops is called even in suspend case low level
driver needs some info whether the current shutdown ops is result of
port close or if its suspend ops.

To differentiate this expand the core layer uart_port info with closing flag
this flag is set to true during shutdown and set to false while port open.

Thus closing flag added with this patch can be used in low level driver to
identify the port close.

Discussion reference:
http://marc.info/?l=linux-omap&m=133491321605924&w=2

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alan Cox <alan@linux.intel.com>
Signed-off-by: Govindraj.R <govindraj.raja@ti.com>
---
 drivers/tty/serial/serial_core.c |    3 +++
 include/linux/serial_core.h      |    1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 9c4c05b..0dc246d 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1284,6 +1284,8 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
 		uart_wait_until_sent(tty, uport->timeout);
 	}
 
+	state->uart_port->closing = true;
+
 	mutex_lock(&port->mutex);
 	uart_shutdown(tty, state);
 	uart_flush_buffer(tty);
@@ -1518,6 +1520,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
 	if (port->count == 1)
 		uart_change_pm(state, 0);
 
+	state->uart_port->closing = false;
 	/*
 	 * Start up the serial port.
 	 */
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 2db407a..f5cd1ee 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -381,6 +381,7 @@ struct uart_port {
 	unsigned char		irq_wake;
 	unsigned char		unused[2];
 	void			*private_data;		/* generic platform data pointer */
+	unsigned char		closing;
 };
 
 static inline int serial_port_in(struct uart_port *up, int offset)
-- 
1.7.9


             reply	other threads:[~2012-04-20 10:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-20 10:57 Govindraj.R [this message]
2012-04-20 13:27 ` [PATCH] tty: serial_core: Add mechanism to identify port closure Alan Cox
2012-04-23  8:55   ` Raja, Govindraj
2012-04-23 10:07     ` Alan Cox

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=1334919473-18870-1-git-send-email-govindraj.raja@ti.com \
    --to=govindraj.raja@ti.com \
    --cc=alan@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-omap@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.