From patchwork Fri Sep 9 22:37:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 75923 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp569856qgf; Fri, 9 Sep 2016 15:37:49 -0700 (PDT) X-Received: by 10.66.138.74 with SMTP id qo10mr10631313pab.135.1473460668948; Fri, 09 Sep 2016 15:37:48 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k88si5958679pfa.274.2016.09.09.15.37.48; Fri, 09 Sep 2016 15:37:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755672AbcIIWh2 (ORCPT + 27 others); Fri, 9 Sep 2016 18:37:28 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:36621 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755586AbcIIWhU (ORCPT ); Fri, 9 Sep 2016 18:37:20 -0400 Received: by mail-oi0-f68.google.com with SMTP id s71so9362984oih.3; Fri, 09 Sep 2016 15:37:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bCvLAEayREJiGbv8WdylYOM4OGXGEqYMiLx1/oxtlpo=; b=b2VPoFrFXd79OOqy9XDYOHo/V0+JpbxSb0PnZWmvELLL5iZDhujD0UGJyl3u7tJONQ P9UL/V8/W75ocruh/PuFowLUJx9BvVFh6aX+dOZAZ0LSJbhv6QBvuB9It+WCD3KFYGFX kchOfsAGV+66gUapnmt0vxKG3wJ7Q8/gpX+xgfsztgiqwKMvKFG7GnSyHYdHTKeYOdD/ Anv+Q3/vA2t9DOmuMJvqLY6pTZxXmuv63jsPCXTf1v7quzwiany6+RaiW1n/ImqREkPT e16hFLYGghvYjW16fkSpD+OB3wTTtvUnuAQRhDKWJQ3qcZ70yokTNLn6tJYdHNFpk1bh DYPg== X-Gm-Message-State: AE9vXwOgp487Sk92DVqjI5lgJu0IGkNQ+oyfKBkyz6jLbWazSMdZl4diJWphgSQiuULQPg== X-Received: by 10.202.171.76 with SMTP id u73mr8242818oie.16.1473460640082; Fri, 09 Sep 2016 15:37:20 -0700 (PDT) Received: from rob-hp-laptop.herring.priv (72-48-98-129.dyn.grandenetworks.net. [72.48.98.129]) by smtp.googlemail.com with ESMTPSA id v185sm1902378oie.24.2016.09.09.15.37.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Sep 2016 15:37:19 -0700 (PDT) From: Rob Herring To: Alan Cox , Greg Kroah-Hartman , Jiri Slaby , Peter Hurley Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH 6/9] tty: serial_core: introduce tty_port_to_uart_state Date: Fri, 9 Sep 2016 17:37:07 -0500 Message-Id: <20160909223711.26238-7-robh@kernel.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160909223711.26238-1-robh@kernel.org> References: <20160909223711.26238-1-robh@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The uart_state is a container of tty_port. Add an inline to convert tty_port ptr to uart_state ptr and convert existing container_of users. Signed-off-by: Rob Herring --- drivers/tty/serial/serial_core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.9.3 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index d48ea0a98e92..29eef4644e98 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -93,6 +93,11 @@ static inline void uart_port_deref(struct uart_port *uport) uart_port_deref(__uport); \ }) +static inline struct uart_state *tty_port_to_uart_state(struct tty_port *port) +{ + return container_of(port, struct uart_state, port); +} + static inline struct uart_port *uart_port_check(struct uart_state *state) { lockdep_assert_held(&state->port.mutex); @@ -720,7 +725,7 @@ static void uart_unthrottle(struct tty_struct *tty) static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo) { - struct uart_state *state = container_of(port, struct uart_state, port); + struct uart_state *state = tty_port_to_uart_state(port); struct uart_port *uport; int ret = -ENODEV; @@ -1603,7 +1608,7 @@ static void uart_hangup(struct tty_struct *tty) /* uport == NULL if uart_port has already been removed */ static void uart_port_shutdown(struct tty_port *port) { - struct uart_state *state = container_of(port, struct uart_state, port); + struct uart_state *state = tty_port_to_uart_state(port); struct uart_port *uport = uart_port_check(state); /* @@ -1630,7 +1635,7 @@ static void uart_port_shutdown(struct tty_port *port) static int uart_carrier_raised(struct tty_port *port) { - struct uart_state *state = container_of(port, struct uart_state, port); + struct uart_state *state = tty_port_to_uart_state(port); struct uart_port *uport; int mctrl; @@ -1655,7 +1660,7 @@ static int uart_carrier_raised(struct tty_port *port) static void uart_dtr_rts(struct tty_port *port, int onoff) { - struct uart_state *state = container_of(port, struct uart_state, port); + struct uart_state *state = tty_port_to_uart_state(port); struct uart_port *uport; uport = uart_port_ref(state);