Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: serial core: decouple pm states from ACPI

The serial core is using power states lifted from ACPI for no
good reason. Remove this reference from the documentation and
alter all users to use an enum specific to the serial core
instead, and define it in <linux/serial_core.h>.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Alan Cox <alan@linux.intel.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Linus Walleij and committed by
Greg Kroah-Hartman
6f538fe3 fdbc7353

+31 -18
+2 -3
Documentation/serial/driver
··· 242 242 243 243 pm(port,state,oldstate) 244 244 Perform any power management related activities on the specified 245 - port. State indicates the new state (defined by ACPI D0-D3), 246 - oldstate indicates the previous state. Essentially, D0 means 247 - fully on, D3 means powered down. 245 + port. State indicates the new state (defined by 246 + enum uart_pm_state), oldstate indicates the previous state. 248 247 249 248 This function should not be used to grab any resources. 250 249
+16 -14
drivers/tty/serial/serial_core.c
··· 59 59 static void uart_change_speed(struct tty_struct *tty, struct uart_state *state, 60 60 struct ktermios *old_termios); 61 61 static void uart_wait_until_sent(struct tty_struct *tty, int timeout); 62 - static void uart_change_pm(struct uart_state *state, int pm_state); 62 + static void uart_change_pm(struct uart_state *state, 63 + enum uart_pm_state pm_state); 63 64 64 65 static void uart_port_shutdown(struct tty_port *port); 65 66 ··· 1366 1365 spin_lock_irqsave(&port->lock, flags); 1367 1366 } else if (!uart_console(uport)) { 1368 1367 spin_unlock_irqrestore(&port->lock, flags); 1369 - uart_change_pm(state, 3); 1368 + uart_change_pm(state, UART_PM_STATE_OFF); 1370 1369 spin_lock_irqsave(&port->lock, flags); 1371 1370 } 1372 1371 ··· 1580 1579 * Make sure the device is in D0 state. 1581 1580 */ 1582 1581 if (port->count == 1) 1583 - uart_change_pm(state, 0); 1582 + uart_change_pm(state, UART_PM_STATE_ON); 1584 1583 1585 1584 /* 1586 1585 * Start up the serial port. ··· 1621 1620 { 1622 1621 struct uart_state *state = drv->state + i; 1623 1622 struct tty_port *port = &state->port; 1624 - int pm_state; 1623 + enum uart_pm_state pm_state; 1625 1624 struct uart_port *uport = state->uart_port; 1626 1625 char stat_buf[32]; 1627 1626 unsigned int status; ··· 1646 1645 if (capable(CAP_SYS_ADMIN)) { 1647 1646 mutex_lock(&port->mutex); 1648 1647 pm_state = state->pm_state; 1649 - if (pm_state) 1650 - uart_change_pm(state, 0); 1648 + if (pm_state != UART_PM_STATE_ON) 1649 + uart_change_pm(state, UART_PM_STATE_ON); 1651 1650 spin_lock_irq(&uport->lock); 1652 1651 status = uport->ops->get_mctrl(uport); 1653 1652 spin_unlock_irq(&uport->lock); 1654 - if (pm_state) 1653 + if (pm_state != UART_PM_STATE_ON) 1655 1654 uart_change_pm(state, pm_state); 1656 1655 mutex_unlock(&port->mutex); 1657 1656 ··· 1898 1897 * 1899 1898 * Locking: port->mutex has to be held 1900 1899 */ 1901 - static void uart_change_pm(struct uart_state *state, int pm_state) 1900 + static void uart_change_pm(struct uart_state *state, 1901 + enum uart_pm_state pm_state) 1902 1902 { 1903 1903 struct uart_port *port = state->uart_port; 1904 1904 ··· 1984 1982 console_stop(uport->cons); 1985 1983 1986 1984 if (console_suspend_enabled || !uart_console(uport)) 1987 - uart_change_pm(state, 3); 1985 + uart_change_pm(state, UART_PM_STATE_OFF); 1988 1986 1989 1987 mutex_unlock(&port->mutex); 1990 1988 ··· 2029 2027 termios = port->tty->termios; 2030 2028 2031 2029 if (console_suspend_enabled) 2032 - uart_change_pm(state, 0); 2030 + uart_change_pm(state, UART_PM_STATE_ON); 2033 2031 uport->ops->set_termios(uport, &termios, NULL); 2034 2032 if (console_suspend_enabled) 2035 2033 console_start(uport->cons); ··· 2039 2037 const struct uart_ops *ops = uport->ops; 2040 2038 int ret; 2041 2039 2042 - uart_change_pm(state, 0); 2040 + uart_change_pm(state, UART_PM_STATE_ON); 2043 2041 spin_lock_irq(&uport->lock); 2044 2042 ops->set_mctrl(uport, 0); 2045 2043 spin_unlock_irq(&uport->lock); ··· 2139 2137 uart_report_port(drv, port); 2140 2138 2141 2139 /* Power up port for set_mctrl() */ 2142 - uart_change_pm(state, 0); 2140 + uart_change_pm(state, UART_PM_STATE_ON); 2143 2141 2144 2142 /* 2145 2143 * Ensure that the modem control lines are de-activated. ··· 2163 2161 * console if we have one. 2164 2162 */ 2165 2163 if (!uart_console(port)) 2166 - uart_change_pm(state, 3); 2164 + uart_change_pm(state, UART_PM_STATE_OFF); 2167 2165 } 2168 2166 } 2169 2167 ··· 2590 2588 } 2591 2589 2592 2590 state->uart_port = uport; 2593 - state->pm_state = -1; 2591 + state->pm_state = UART_PM_STATE_UNDEFINED; 2594 2592 2595 2593 uport->cons = drv->cons; 2596 2594 uport->state = state;
+13 -1
include/linux/serial_core.h
··· 208 208 up->serial_out(up, offset, value); 209 209 } 210 210 211 + /** 212 + * enum uart_pm_state - power states for UARTs 213 + * @UART_PM_STATE_ON: UART is powered, up and operational 214 + * @UART_PM_STATE_OFF: UART is powered off 215 + * @UART_PM_STATE_UNDEFINED: sentinel 216 + */ 217 + enum uart_pm_state { 218 + UART_PM_STATE_ON = 0, 219 + UART_PM_STATE_OFF = 3, /* number taken from ACPI */ 220 + UART_PM_STATE_UNDEFINED, 221 + }; 222 + 211 223 /* 212 224 * This is the state information which is persistent across opens. 213 225 */ 214 226 struct uart_state { 215 227 struct tty_port port; 216 228 217 - int pm_state; 229 + enum uart_pm_state pm_state; 218 230 struct circ_buf xmit; 219 231 220 232 struct uart_port *uart_port;