From patchwork Thu Dec 6 18:46:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13398 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 3B30B4C15B0 for ; Thu, 6 Dec 2012 18:47:29 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 8594EA19AE4 for ; Thu, 6 Dec 2012 18:47:28 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id t4so5007726iag.11 for ; Thu, 06 Dec 2012 10:47:28 -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=ADVvM4rfqSakBzas4zO7gUKHvNsQ2Zr3aYsOOweXpJE=; b=DUUGuDZnOuzA2cz5oet5YjJf5/QVZrk+v3g6th4iyDNdclshbTHZfhQrYLC3kGjtLD 8VuAx38hgB8RQmuvPy1YwZTR0o+uAOwYVPt3jgIbIX0tewmEzMgal7KSIC7bAFJeizgZ Q4u2NDiubz0C3FJYqeLrrP9zmzRkUbwCKuMLsm6HKuQJYkruiiYR9KERHrssasIHjC1q 4TMXtH3i7Hh9t+XX1uprW3LaPVqg0EGxTgheeS0I26xyghHB2B0mtN40QY0PkMR/yGJk oOraO55NkhtfygYJ31F/cI1MsPr/h3934lymg/dKVltA1q8RTh2dZ9RLAIuZ8jy5SNYo DTpw== Received: by 10.43.125.133 with SMTP id gs5mr2226564icc.54.1354819647984; Thu, 06 Dec 2012 10:47:27 -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 n20csp427816igt; Thu, 6 Dec 2012 10:47:27 -0800 (PST) Received: by 10.14.220.71 with SMTP id n47mr8018981eep.39.1354819646429; Thu, 06 Dec 2012 10:47:26 -0800 (PST) Received: from eu1sys200aog118.obsmtp.com (eu1sys200aog118.obsmtp.com [207.126.144.145]) by mx.google.com with SMTP id l8si2362632eem.29.2012.12.06.10.47.20 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Dec 2012 10:47:26 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.145 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.145; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.145 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-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob118.postini.com ([207.126.147.11]) with SMTP ID DSNKUMDoNsCtOaLzUQnXRx0TpSfflewRVIwT@postini.com; Thu, 06 Dec 2012 18:47:26 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 85244D1; Thu, 6 Dec 2012 18:46:59 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 17EDE526F; Thu, 6 Dec 2012 18:46:59 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id A5D1DA8074; Thu, 6 Dec 2012 19:46:51 +0100 (CET) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 6 Dec 2012 19:46:58 +0100 From: Linus Walleij To: , Greg Kroah-Hartman , Len Brown , "Rafael J. Wysocki" Cc: Alan Cox , Rickard Andersson , , Linus Walleij Subject: [PATCH 2/2] tty: serial core: use the ACPI PM state defines Date: Thu, 6 Dec 2012 19:46:52 +0100 Message-ID: <1354819612-2401-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: ALoCoQmfMLqv1JxcczlKmYqlVLnOU2veFiO+jKZxoAY5yBDhwmOsrFEBZm2RSU22q0/8t3ebyCiw From: Linus Walleij The Documentation/serial/driver file defines that: State indicates the new state (defined by ACPI D0-D3), oldstate indicates the previous state. Essentially, D0 means fully on, D3 means powered down. So let's change the code to actually using the defined ACPI states instead of using magic numbers. Further it is clear from the ACPI definitions that the state is a u8 so use this data type. Signed-off-by: Linus Walleij --- drivers/tty/serial/serial_core.c | 26 ++++++++++++++------------ include/linux/serial_core.h | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 2c7230a..f327115 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -34,6 +34,8 @@ #include #include +#include /* for power states */ + #include #include @@ -59,7 +61,7 @@ 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, u8 pm_state); static void uart_port_shutdown(struct tty_port *port); @@ -1365,7 +1367,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, ACPI_STATE_D3_HOT); spin_lock_irqsave(&port->lock, flags); } @@ -1579,7 +1581,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, ACPI_STATE_D0); /* * Start up the serial port. @@ -1620,7 +1622,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; + u8 pm_state; struct uart_port *uport = state->uart_port; char stat_buf[32]; unsigned int status; @@ -1646,7 +1648,7 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i) mutex_lock(&port->mutex); pm_state = state->pm_state; if (pm_state) - uart_change_pm(state, 0); + uart_change_pm(state, ACPI_STATE_D0); spin_lock_irq(&uport->lock); status = uport->ops->get_mctrl(uport); spin_unlock_irq(&uport->lock); @@ -1897,7 +1899,7 @@ 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, u8 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, ACPI_STATE_D3_HOT); 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, ACPI_STATE_D0); 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, ACPI_STATE_D0); 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, ACPI_STATE_D0); /* * 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, ACPI_STATE_D3_HOT); } } @@ -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 = ACPI_STATE_UNKNOWN; uport->cons = drv->cons; uport->state = state; diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index c6690a2..43e8d87 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -214,7 +214,7 @@ static inline void serial_port_out(struct uart_port *up, int offset, int value) struct uart_state { struct tty_port port; - int pm_state; + u8 pm_state; struct circ_buf xmit; struct uart_port *uart_port;