From patchwork Thu Aug 18 01:14:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 74135 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp106473qga; Wed, 17 Aug 2016 18:16:04 -0700 (PDT) X-Received: by 10.98.88.131 with SMTP id m125mr28057987pfb.63.1471482963948; Wed, 17 Aug 2016 18:16:03 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k62si40393303pfb.69.2016.08.17.18.15.57; Wed, 17 Aug 2016 18:16:03 -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 S1945986AbcHRBPy (ORCPT + 27 others); Wed, 17 Aug 2016 21:15:54 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:35344 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753614AbcHRBPY (ORCPT ); Wed, 17 Aug 2016 21:15:24 -0400 Received: by mail-oi0-f65.google.com with SMTP id e80so1150174oig.2; Wed, 17 Aug 2016 18:15:24 -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=cH0KQH4/7ulEirHwxDb9BUE5U/2H9w3nXSkkbatZFBs=; b=GcajLJ/P1lppvZ0yzXmNVLO+5ZQsU8XznepxQ0deuKuKPuzR17ZNnbTmhBBDGfhpN9 GTyBeI10xqOURZKfW7qQZbmrF5Y6sophMyAb0d9/lcL8xQpQ5WrWR4BGHMWqC7djKHCL yp1CYDpJu4fZ/TtSYygMCtr8W3Cg2UmnzEIYZLBfef3leINGD7RJ3vqzKisUxIbJFWaU fikvuAOc6qacnzrn/YfCdPAHDrU25X05SPaKuDAPhQSlqGdgkNqnCl9fA7G1zggacUZc dKuDkdzxE2+k4m4DJja1qHo291ooktJJUmxq1iFgV68Oo5K8irdSe1JaEShYGUypPx6b E81A== X-Gm-Message-State: AEkoout5PQoNqB56EAhtzqRp/xOamQI53tMWOwCDB3Iultn0M0V8srRzITMpB5ZLtBo+eg== X-Received: by 10.157.37.66 with SMTP id j2mr1783220otd.129.1471482923631; Wed, 17 Aug 2016 18:15:23 -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 c44sm1261876ote.14.2016.08.17.18.15.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Aug 2016 18:15:23 -0700 (PDT) From: Rob Herring To: Greg Kroah-Hartman , Marcel Holtmann , Jiri Slaby , Sebastian Reichel Cc: Pavel Machek , Peter Hurley , NeilBrown , "Dr . H . Nikolaus Schaller" , Arnd Bergmann , Linus Walleij , linux-bluetooth@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/3] tty: serial_core: make tty_struct optional Date: Wed, 17 Aug 2016 20:14:44 -0500 Message-Id: <20160818011445.22726-3-robh@kernel.org> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20160818011445.22726-1-robh@kernel.org> References: <20160818011445.22726-1-robh@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to allow serial drivers to work without a tty, make calls from drivers and serial_core work when tty_struct is NULL. Signed-off-by: Rob Herring --- drivers/tty/serial/serial_core.c | 3 ++- drivers/tty/tty_buffer.c | 2 ++ include/linux/serial_core.h | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) -- 2.9.2 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 9fc1533..9dd444f 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -111,7 +111,8 @@ void uart_write_wakeup(struct uart_port *port) * closed. No cookie for you. */ BUG_ON(!state); - tty_wakeup(state->port.tty); + if (state->port.tty) + tty_wakeup(state->port.tty); } static void uart_stop(struct tty_struct *tty) diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index aa80dc9..ffab8ea 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -528,6 +528,8 @@ static void flush_to_ldisc(struct work_struct *work) void tty_flip_buffer_push(struct tty_port *port) { + if (!port->tty) + return; tty_schedule_flip(port); } EXPORT_SYMBOL(tty_flip_buffer_push); diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 2f44e20..a27ca1f 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -412,7 +412,7 @@ int uart_resume_port(struct uart_driver *reg, struct uart_port *port); static inline int uart_tx_stopped(struct uart_port *port) { struct tty_struct *tty = port->state->port.tty; - if (tty->stopped || port->hw_stopped) + if ((tty && tty->stopped) || port->hw_stopped) return 1; return 0; }