From patchwork Fri Jan 6 16:26:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 90203 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp9520260qgi; Fri, 6 Jan 2017 08:28:55 -0800 (PST) X-Received: by 10.84.171.228 with SMTP id l91mr169008915plb.4.1483720135857; Fri, 06 Jan 2017 08:28:55 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r20si80092981pfj.47.2017.01.06.08.28.55 for ; Fri, 06 Jan 2017 08:28:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-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-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751517AbdAFQ2v (ORCPT ); Fri, 6 Jan 2017 11:28:51 -0500 Received: from mail-oi0-f65.google.com ([209.85.218.65]:36719 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750881AbdAFQ0n (ORCPT ); Fri, 6 Jan 2017 11:26:43 -0500 Received: by mail-oi0-f65.google.com with SMTP id u143so6691259oif.3; Fri, 06 Jan 2017 08:26:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BH9UQnj7ddVucGSIAo0pib2LeIHHBiAzD/ztlkMvAFI=; b=eG7Ts2jQ0DgcfKEx185RNwUtpDsR2jVhxHaRBG5PfQGJ1u3cNOCmFLXPOp4T4573i7 XimsudiKku1wMpn620MSZWdw2E5PR/a8orOp7YgLynosOPS7FhVbElLANBg5tK+YEIPB ZIB9/B05+iFTptfurxCBt9U5adGQLayKFHP9a0CE0xLrdQvdIapLJTHRqmgSOwrllVMY hqxuCLoUsHjG56IHXgW+k6wHDptegqzjEX6Ep4UW7Y7A0Icra18JMLeykf+ckkPUJKB5 B2qJk3Z8YhSp6UK/bHaD1RW+yFMjNKU3vmcjgW3eFZdCcj9bSh/Ib4SdeCW7rXxsh34g 1kqA== X-Gm-Message-State: AIkVDXKYvwe+H/2lRmqC2ftOwU5p5+cABt/8csU60rGBnW/NvSFz+BEQg+lliqUsMqNSDw== X-Received: by 10.202.229.208 with SMTP id c199mr38038032oih.179.1483720001903; Fri, 06 Jan 2017 08:26:41 -0800 (PST) Received: from rob-hp-laptop.herring.priv (50-233-148-156-static.hfc.comcastbusiness.net. [50.233.148.156]) by smtp.googlemail.com with ESMTPSA id i135sm5245809oib.18.2017.01.06.08.26.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jan 2017 08:26:41 -0800 (PST) From: Rob Herring To: Greg Kroah-Hartman , Marcel Holtmann , Jiri Slaby , Sebastian Reichel , Arnd Bergmann , "Dr . H . Nikolaus Schaller" , Peter Hurley , Andy Shevchenko , Alan Cox Cc: Loic Poulain , Pavel Machek , NeilBrown , Linus Walleij , linux-bluetooth@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/9] tty: move the non-file related parts of tty_release to new tty_release_struct Date: Fri, 6 Jan 2017 10:26:27 -0600 Message-Id: <20170106162635.19677-2-robh@kernel.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170106162635.19677-1-robh@kernel.org> References: <20170106162635.19677-1-robh@kernel.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org For in-kernel tty users, we need to be able to create and destroy 'struct tty' that are not associated with a file. The creation side is fine, but tty_release() needs to be split into the file handle portion and the struct tty portion. Introduce a new function, tty_release_struct, to handle just the destroying of a struct tty. Signed-off-by: Rob Herring --- drivers/tty/tty_io.c | 42 ++++++++++++++++++++++++------------------ include/linux/tty.h | 1 + 2 files changed, 25 insertions(+), 18 deletions(-) -- 2.10.1 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 734a635e7363..5ebc090ec47f 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -1744,6 +1744,29 @@ static int tty_release_checks(struct tty_struct *tty, int idx) return 0; } +void tty_release_struct(struct tty_struct *tty, int idx) +{ + /* + * Ask the line discipline code to release its structures + */ + tty_ldisc_release(tty); + + /* Wait for pending work before tty destruction commmences */ + tty_flush_works(tty); + + tty_debug_hangup(tty, "freeing structure\n"); + /* + * The release_tty function takes care of the details of clearing + * the slots and preserving the termios structure. The tty_unlock_pair + * should be safe as we keep a kref while the tty is locked (so the + * unlock never unlocks a freed tty). + */ + mutex_lock(&tty_mutex); + release_tty(tty, idx); + mutex_unlock(&tty_mutex); +} +EXPORT_SYMBOL_GPL(tty_release_struct); + /** * tty_release - vfs callback for close * @inode: inode of tty @@ -1898,25 +1921,8 @@ int tty_release(struct inode *inode, struct file *filp) return 0; tty_debug_hangup(tty, "final close\n"); - /* - * Ask the line discipline code to release its structures - */ - tty_ldisc_release(tty); - - /* Wait for pending work before tty destruction commmences */ - tty_flush_works(tty); - - tty_debug_hangup(tty, "freeing structure\n"); - /* - * The release_tty function takes care of the details of clearing - * the slots and preserving the termios structure. The tty_unlock_pair - * should be safe as we keep a kref while the tty is locked (so the - * unlock never unlocks a freed tty). - */ - mutex_lock(&tty_mutex); - release_tty(tty, idx); - mutex_unlock(&tty_mutex); + tty_release_struct(tty, idx); return 0; } diff --git a/include/linux/tty.h b/include/linux/tty.h index 40144f382516..86c7853282b7 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -528,6 +528,7 @@ extern int tty_alloc_file(struct file *file); extern void tty_add_file(struct tty_struct *tty, struct file *file); extern void tty_free_file(struct file *file); extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx); +extern void tty_release_struct(struct tty_struct *tty, int idx); extern int tty_release(struct inode *inode, struct file *filp); extern void tty_init_termios(struct tty_struct *tty); extern int tty_standard_install(struct tty_driver *driver,