* [PATCH 1/2] tty: move serial PM state to TTY driver interface
@ 2012-12-10 12:34 Rickard Andersson
2012-12-10 12:34 ` [PATCH 2/2] TTY: serial, add pm function Rickard Andersson
0 siblings, 1 reply; 3+ messages in thread
From: Rickard Andersson @ 2012-12-10 12:34 UTC (permalink / raw)
To: linux-serial, gregkh, linus.walleij
Cc: alan, daniel.lezcano, rickard.andersson
From: Linus Walleij <linus.walleij@linaro.org>
We want to make it possible for TTY drivers to control the
power state of the serial core, so as a first step make the
serial core power states generic and rename them TTY_*
so they can be used across all TTY drivers.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/tty/serial/serial_core.c | 28 ++++++++++++++--------------
include/linux/serial_core.h | 14 +-------------
include/linux/tty_driver.h | 12 ++++++++++++
3 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 006c0ba..b2fc8d7 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -60,7 +60,7 @@ static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
struct ktermios *old_termios);
static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
static void uart_change_pm(struct uart_state *state,
- enum uart_pm_state pm_state);
+ enum tty_pm_state pm_state);
static void uart_port_shutdown(struct tty_port *port);
@@ -1319,7 +1319,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
spin_lock_irqsave(&port->lock, flags);
} else if (!uart_console(uport)) {
spin_unlock_irqrestore(&port->lock, flags);
- uart_change_pm(state, UART_PM_STATE_OFF);
+ uart_change_pm(state, TTY_PM_STATE_OFF);
spin_lock_irqsave(&port->lock, flags);
}
@@ -1533,7 +1533,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
* Make sure the device is in D0 state.
*/
if (port->count == 1)
- uart_change_pm(state, UART_PM_STATE_ON);
+ uart_change_pm(state, TTY_PM_STATE_ON);
/*
* Start up the serial port.
@@ -1574,7 +1574,7 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i)
{
struct uart_state *state = drv->state + i;
struct tty_port *port = &state->port;
- enum uart_pm_state pm_state;
+ enum tty_pm_state pm_state;
struct uart_port *uport = state->uart_port;
char stat_buf[32];
unsigned int status;
@@ -1599,12 +1599,12 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i)
if (capable(CAP_SYS_ADMIN)) {
mutex_lock(&port->mutex);
pm_state = state->pm_state;
- if (pm_state != UART_PM_STATE_ON)
- uart_change_pm(state, UART_PM_STATE_ON);
+ if (pm_state != TTY_PM_STATE_ON)
+ uart_change_pm(state, TTY_PM_STATE_ON);
spin_lock_irq(&uport->lock);
status = uport->ops->get_mctrl(uport);
spin_unlock_irq(&uport->lock);
- if (pm_state != UART_PM_STATE_ON)
+ if (pm_state != TTY_PM_STATE_ON)
uart_change_pm(state, pm_state);
mutex_unlock(&port->mutex);
@@ -1852,7 +1852,7 @@ EXPORT_SYMBOL_GPL(uart_set_options);
* Locking: port->mutex has to be held
*/
static void uart_change_pm(struct uart_state *state,
- enum uart_pm_state pm_state)
+ enum tty_pm_state pm_state)
{
struct uart_port *port = state->uart_port;
@@ -1937,7 +1937,7 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
console_stop(uport->cons);
if (console_suspend_enabled || !uart_console(uport))
- uart_change_pm(state, UART_PM_STATE_OFF);
+ uart_change_pm(state, TTY_PM_STATE_OFF);
mutex_unlock(&port->mutex);
@@ -1982,7 +1982,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
termios = port->tty->termios;
if (console_suspend_enabled)
- uart_change_pm(state, UART_PM_STATE_ON);
+ uart_change_pm(state, TTY_PM_STATE_ON);
uport->ops->set_termios(uport, &termios, NULL);
if (console_suspend_enabled)
console_start(uport->cons);
@@ -1992,7 +1992,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
const struct uart_ops *ops = uport->ops;
int ret;
- uart_change_pm(state, UART_PM_STATE_ON);
+ uart_change_pm(state, TTY_PM_STATE_ON);
spin_lock_irq(&uport->lock);
ops->set_mctrl(uport, 0);
spin_unlock_irq(&uport->lock);
@@ -2092,7 +2092,7 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state,
uart_report_port(drv, port);
/* Power up port for set_mctrl() */
- uart_change_pm(state, UART_PM_STATE_ON);
+ uart_change_pm(state, TTY_PM_STATE_ON);
/*
* Ensure that the modem control lines are de-activated.
@@ -2116,7 +2116,7 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state,
* console if we have one.
*/
if (!uart_console(port))
- uart_change_pm(state, UART_PM_STATE_OFF);
+ uart_change_pm(state, TTY_PM_STATE_OFF);
}
}
@@ -2391,7 +2391,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
}
state->uart_port = uport;
- state->pm_state = UART_PM_STATE_UNDEFINED;
+ state->pm_state = TTY_PM_STATE_UNDEFINED;
uport->cons = drv->cons;
uport->state = state;
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index a83c5f6..75f89a7 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -202,25 +202,13 @@ static inline void serial_port_out(struct uart_port *up, int offset, int value)
up->serial_out(up, offset, value);
}
-/**
- * enum uart_pm_state - power states for UARTs
- * @UART_PM_STATE_ON: UART is powered, up and operational
- * @UART_PM_STATE_OFF: UART is powered off
- * @UART_PM_STATE_UNDEFINED: sentinel
- */
-enum uart_pm_state {
- UART_PM_STATE_ON = 0,
- UART_PM_STATE_OFF = 3, /* number taken from ACPI */
- UART_PM_STATE_UNDEFINED,
-};
-
/*
* This is the state information which is persistent across opens.
*/
struct uart_state {
struct tty_port port;
- enum uart_pm_state pm_state;
+ enum tty_pm_state pm_state;
struct circ_buf xmit;
struct uart_port *uart_port;
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index dd976cf..d150a6f 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -241,6 +241,18 @@ struct tty_struct;
struct tty_driver;
struct serial_icounter_struct;
+/**
+ * enum tty_pm_state - power states for TTYs
+ * @TTY_PM_STATE_ON: TTY is powered, up and operational
+ * @TTY_PM_STATE_OFF: TTY is powered off
+ * @TTY_PM_STATE_UNDEFINED: sentinel
+ */
+enum tty_pm_state {
+ TTY_PM_STATE_ON = 0,
+ TTY_PM_STATE_OFF = 3, /* number taken from ACPI */
+ TTY_PM_STATE_UNDEFINED,
+};
+
struct tty_operations {
struct tty_struct * (*lookup)(struct tty_driver *driver,
struct inode *inode, int idx);
--
1.8.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] TTY: serial, add pm function
2012-12-10 12:34 [PATCH 1/2] tty: move serial PM state to TTY driver interface Rickard Andersson
@ 2012-12-10 12:34 ` Rickard Andersson
2012-12-11 17:06 ` Rickard Andersson
0 siblings, 1 reply; 3+ messages in thread
From: Rickard Andersson @ 2012-12-10 12:34 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>
---
drivers/tty/serial/serial_core.c | 10 ++++++++++
include/linux/tty_driver.h | 8 ++++++++
2 files changed, 18 insertions(+)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index b2fc8d7..3597dc8 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1114,6 +1114,15 @@ 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;
+
+ uart_change_pm(ustate, state);
+
+ return 0;
+}
+
/*
* Called via sys_ioctl. We can use spin_lock_irq() here.
*/
@@ -2217,6 +2226,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] 3+ messages in thread
* Re: [PATCH 2/2] TTY: serial, add pm function
2012-12-10 12:34 ` [PATCH 2/2] TTY: serial, add pm function Rickard Andersson
@ 2012-12-11 17:06 ` Rickard Andersson
0 siblings, 0 replies; 3+ messages in thread
From: Rickard Andersson @ 2012-12-11 17:06 UTC (permalink / raw)
To: Rickard ANDERSSON
Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org,
Linus WALLEIJ, alan@linux.intel.com, daniel.lezcano@linaro.org
On 12/10/2012 01:34 PM, Rickard ANDERSSON wrote:
> Add power management function to tty driver interface
> and add implementation for serial core.
>
> Signed-off-by: Rickard Andersson<rickard.andersson@stericsson.com>
> ---
> drivers/tty/serial/serial_core.c | 10 ++++++++++
> include/linux/tty_driver.h | 8 ++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index b2fc8d7..3597dc8 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -1114,6 +1114,15 @@ 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;
> +
> + uart_change_pm(ustate, state);
I just realized that I should hold "port->mutex" while calling
uart_change_pm(..).
I am waiting for further comments on the patch set.
BR
Rickard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-11 17:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-10 12:34 [PATCH 1/2] tty: move serial PM state to TTY driver interface Rickard Andersson
2012-12-10 12:34 ` [PATCH 2/2] TTY: serial, add pm function Rickard Andersson
2012-12-11 17:06 ` Rickard Andersson
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).