From patchwork Thu Dec 6 19:59:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13400 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id D31C523E2C for ; Thu, 6 Dec 2012 19:59:51 +0000 (UTC) Received: from mail-ia0-f171.google.com (mail-ia0-f171.google.com [209.85.210.171]) by fiordland.canonical.com (Postfix) with ESMTP id 41EA9A18019 for ; Thu, 6 Dec 2012 19:59:51 +0000 (UTC) Received: by mail-ia0-f171.google.com with SMTP id k27so6001316iad.16 for ; Thu, 06 Dec 2012 11:59:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=Oz3KtzTrDDZOno/Lc4ZStKOzzs50jSArs4GZijr8r2Q=; b=WbCIRkaOA9thOfGcXPqxBvl4htNu+5f0jYhjNilkXAAfK7lyfx+waRcYF/5m1Rg4jo W2TVXtYXHjHDiTBtXRQ2MgzytEK/xo+ZW1xJCSxezBnPIQ0g2hlYeDEtt5uaFCbuCCFe BXDmi4zOerDpWcO43MLd0fluk3JRJNPRTGh0v4Px4kSxnH94zA1tgbDEy5oGkj2dAM34 gpp+zMApFYBCndYuTnPXWFjw75xcZvlQIEwvoSUx7PKpydySotvhTTZ4Lioic3fo8jiQ NdyYh8R8RKLQ8hHHCKqBVbwZ+f7kVSIja37Cj8OvLsLFUbwvd5fkCOPz/JtMZStmmKQk Du6Q== Received: by 10.50.91.195 with SMTP id cg3mr6992206igb.57.1354823990645; Thu, 06 Dec 2012 11:59:50 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp431343igt; Thu, 6 Dec 2012 11:59:49 -0800 (PST) Received: by 10.14.215.197 with SMTP id e45mr8992124eep.0.1354823988891; Thu, 06 Dec 2012 11:59:48 -0800 (PST) Received: from eu1sys200aog120.obsmtp.com (eu1sys200aog120.obsmtp.com [207.126.144.149]) by mx.google.com with SMTP id l1si18643402een.97.2012.12.06.11.59.38 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Dec 2012 11:59:48 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.149 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.149; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.149 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob120.postini.com ([207.126.147.11]) with SMTP ID DSNKUMD5KiSkRBDjzvnc85xXK5ZAmS4GOnit@postini.com; Thu, 06 Dec 2012 19:59:46 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 3E63344; Thu, 6 Dec 2012 19:58:46 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id BCDE34E; Thu, 6 Dec 2012 14:53:47 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id CE28A24C2AB; Thu, 6 Dec 2012 20:59:13 +0100 (CET) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 6 Dec 2012 20:59:22 +0100 From: Linus Walleij To: , Greg Kroah-Hartman Cc: Alan Cox , Rickard Andersson , , Linus Walleij Subject: [PATCH] tty: serial core: decouple pm states from ACPI Date: Thu, 6 Dec 2012 20:59:14 +0100 Message-ID: <1354823954-6073-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQk0c6tmQoNg9jl4q766TDp7YtHuJNO+vOxn/2Ujye1L6qXqcDb/xvzunV+IIFTOzJbjJcMc From: Linus Walleij 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 . Signed-off-by: Linus Walleij --- Alan think that depending on ACPI for PM states is a bad idea, so let's instead create our own definition of the PM states for the tty/serial subsystem. (Ditch the other two patches.) --- Documentation/serial/driver | 5 ++--- drivers/tty/serial/serial_core.c | 30 ++++++++++++++++-------------- include/linux/serial_core.h | 14 +++++++++++++- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Documentation/serial/driver b/Documentation/serial/driver index 0a25a91..a6ef8dc 100644 --- a/Documentation/serial/driver +++ b/Documentation/serial/driver @@ -242,9 +242,8 @@ hardware. pm(port,state,oldstate) Perform any power management related activities on the specified - port. State indicates the new state (defined by ACPI D0-D3), - oldstate indicates the previous state. Essentially, D0 means - fully on, D3 means powered down. + port. State indicates the new state (defined by + enum uart_pm_state), oldstate indicates the previous state. This function should not be used to grab any resources. diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 2c7230a..11b23e2 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -59,7 +59,8 @@ static struct lock_class_key port_lock_key; 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, int pm_state); +static void uart_change_pm(struct uart_state *state, + enum uart_pm_state pm_state); static void uart_port_shutdown(struct tty_port *port); @@ -1365,7 +1366,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, 3); + uart_change_pm(state, UART_PM_STATE_SLEEP); spin_lock_irqsave(&port->lock, flags); } @@ -1579,7 +1580,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, 0); + uart_change_pm(state, UART_PM_STATE_DEFAULT); /* * Start up the serial port. @@ -1620,7 +1621,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; - int pm_state; + enum uart_pm_state pm_state; struct uart_port *uport = state->uart_port; char stat_buf[32]; unsigned int status; @@ -1645,12 +1646,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_change_pm(state, 0); + if (pm_state != UART_PM_STATE_DEFAULT) + uart_change_pm(state, UART_PM_STATE_DEFAULT); spin_lock_irq(&uport->lock); status = uport->ops->get_mctrl(uport); spin_unlock_irq(&uport->lock); - if (pm_state) + if (pm_state != UART_PM_STATE_DEFAULT) uart_change_pm(state, pm_state); mutex_unlock(&port->mutex); @@ -1897,7 +1898,8 @@ EXPORT_SYMBOL_GPL(uart_set_options); * * Locking: port->mutex has to be held */ -static void uart_change_pm(struct uart_state *state, int pm_state) +static void uart_change_pm(struct uart_state *state, + enum uart_pm_state pm_state) { struct uart_port *port = state->uart_port; @@ -1982,7 +1984,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, 3); + uart_change_pm(state, UART_PM_STATE_SLEEP); mutex_unlock(&port->mutex); @@ -2027,7 +2029,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, 0); + uart_change_pm(state, UART_PM_STATE_DEFAULT); uport->ops->set_termios(uport, &termios, NULL); if (console_suspend_enabled) console_start(uport->cons); @@ -2037,7 +2039,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, 0); + uart_change_pm(state, UART_PM_STATE_DEFAULT); spin_lock_irq(&uport->lock); ops->set_mctrl(uport, 0); spin_unlock_irq(&uport->lock); @@ -2137,7 +2139,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, 0); + uart_change_pm(state, UART_PM_STATE_DEFAULT); /* * Ensure that the modem control lines are de-activated. @@ -2161,7 +2163,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, 3); + uart_change_pm(state, UART_PM_STATE_SLEEP); } } @@ -2588,7 +2590,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport) } state->uart_port = uport; - state->pm_state = -1; + state->pm_state = UART_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 c6690a2..d1fd0af 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -208,13 +208,25 @@ 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_DEFAULT: UART is powered, up and operational + * @UART_PM_STATE_SLEEP: UART is powered off + * @UART_PM_STATE_UNDEFINED: sentinel + */ +enum uart_pm_state { + UART_PM_STATE_DEFAULT = 0, + UART_PM_STATE_SLEEP = 3, + UART_PM_STATE_UNDEFINED, +}; + /* * This is the state information which is persistent across opens. */ struct uart_state { struct tty_port port; - int pm_state; + enum uart_pm_state pm_state; struct circ_buf xmit; struct uart_port *uart_port;