linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] TTY: serial, add pm function
@ 2012-12-12 12:40 Rickard Andersson
  2013-01-16  7:05 ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: Rickard Andersson @ 2012-12-12 12:40 UTC (permalink / raw)
  To: linux-serial, gregkh, linus.walleij
  Cc: alan, daniel.lezcano, rickard.andersson

Add power management function to tty driver interface
and add implementation for serial core.

Signed-off-by: Rickard Andersson <rickard.andersson@stericsson.com>
---
ChangeLog v1->v2
- add mutex handling
---
 drivers/tty/serial/serial_core.c | 13 +++++++++++++
 include/linux/tty_driver.h       |  8 ++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index b2fc8d7..ec501f5 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1114,6 +1114,18 @@ static int uart_get_icount(struct tty_struct *tty,
 	return 0;
 }
 
+static int uart_pm(struct tty_struct *tty, enum tty_pm_state state)
+{
+	struct uart_state *ustate = tty->driver_data;
+	struct tty_port *port = &ustate->port;
+
+	mutex_lock(&port->mutex);
+	uart_change_pm(ustate, state);
+	mutex_unlock(&port->mutex);
+
+	return 0;
+}
+
 /*
  * Called via sys_ioctl.  We can use spin_lock_irq() here.
  */
@@ -2217,6 +2229,7 @@ static const struct tty_operations uart_ops = {
 	.tiocmget	= uart_tiocmget,
 	.tiocmset	= uart_tiocmset,
 	.get_icount	= uart_get_icount,
+	.pm		= uart_pm,
 #ifdef CONFIG_CONSOLE_POLL
 	.poll_init	= uart_poll_init,
 	.poll_get_char	= uart_poll_get_char,
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index d150a6f..ba34b7f 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -229,6 +229,12 @@
  *	Called when the device receives a TIOCGICOUNT ioctl. Passed a kernel
  *	structure to complete. This method is optional and will only be called
  *	if provided (otherwise EINVAL will be returned).
+ *
+ * int (*pm)(struct tty_struct * tty, enum tty_pm_state state);
+ *
+ *      Perform any power management related activities on the specified
+ *      tty. State indicates the new state.
+ *
  */
 
 #include <linux/export.h>
@@ -249,6 +255,7 @@ struct serial_icounter_struct;
  */
 enum tty_pm_state {
 	TTY_PM_STATE_ON = 0,
+	TTY_PM_STATE_SLEEP,
 	TTY_PM_STATE_OFF = 3, /* number taken from ACPI */
 	TTY_PM_STATE_UNDEFINED,
 };
@@ -290,6 +297,7 @@ struct tty_operations {
 	int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew);
 	int (*get_icount)(struct tty_struct *tty,
 				struct serial_icounter_struct *icount);
+	int (*pm)(struct tty_struct *tty, enum tty_pm_state state);
 #ifdef CONFIG_CONSOLE_POLL
 	int (*poll_init)(struct tty_driver *driver, int line, char *options);
 	int (*poll_get_char)(struct tty_driver *driver, int line);
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-01-18 12:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-12 12:40 [PATCH v2] TTY: serial, add pm function Rickard Andersson
2013-01-16  7:05 ` Greg KH
2013-01-16  7:53   ` Rickard Andersson
2013-01-16  7:58     ` Greg KH
2013-01-16  8:33       ` Rickard Andersson
2013-01-16 15:24         ` Greg KH
2013-01-17  0:36           ` Linus Walleij
2013-01-17  2:32             ` Greg KH
2013-01-17 10:10               ` Rickard Andersson
2013-01-17 13:16               ` Alan Cox
2013-01-18 12:43               ` Linus Walleij

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).