From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by befuddled.reisers.ca (Postfix, from userid 65534) id 3C1731EFD90; Sat, 29 Apr 2017 15:57:21 -0400 (EDT) Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by befuddled.reisers.ca (Postfix) with ESMTPS id 5DE831F023B for ; Sat, 29 Apr 2017 15:54:17 -0400 (EDT) Received: by mail-wr0-x244.google.com with SMTP id w50so10301589wrc.0 for ; Sat, 29 Apr 2017 12:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:user-agent:date:from:to:cc:subject:references :mime-version:content-disposition; bh=ScJyAJCvP8EUA8sk7qqDuyKvFpFM31MpD4ladYXxImA=; b=B48bCnr46pxyxVc7atYiVSMb74yRixA6KKNaUFZqqt30xB8kZNRhI2BLN53XZtLHlI OIv7qPZ8mR5FMCF3ppsaKlIR+wVArOwkNUBfqWcOyC6DueADgaBakCWCDnXpxQsmolP2 MFIFsrG9Wf1tV6mXXd4HL9d5uunVH7srS8PA7i64Xf9qyuauWgw97fRhsIiulBfD2Ooz E3hrhMZ5EBuE8uTp0Bbfo25wuYGYunIxhok+g/m938gmE+1it0xtWvRvbAHTp1Adq9tc 2UR0/KU+Y1jYD81KtqSF67JZgWYAQagpM6orPynPZn+kyG0Bk+O5iRgbOp6LPzI9OG0U SW7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject :references:mime-version:content-disposition; bh=ScJyAJCvP8EUA8sk7qqDuyKvFpFM31MpD4ladYXxImA=; b=tXBfesABHjHPfUApvvyg/m2Vax4ByMOAsvgfx2Nfbqjb2UwqQqegGwcKJg2cnNHQCU GshzVeqAXX6m5XPzSVZ/ejpb9L8kF1SE1XKLjMMHWBBY3qemQmPc3hrpeTMqcsjPBR6K XrUbIfvxCOQZou1dwYHchORY3ulODdbIfmJAVyggbN+e8StRXD9nghMytvzLgvBJRVu7 +PUbyTfGtX4ykK3IsLIE4A59hFwmcuLxmnTIujb0CGrfmACuEYpIbRLo4GmcwcQOStMo dHp5LX209ADBLSsLKjk0h/n/dWU0j4C415QmVdtq56V3H6crrkXqGDehPdEiXDNjTRJk V0Sw== X-Gm-Message-State: AN3rC/6ggzDoEaazjnsta4K0+stM/yM7cg6Uy/wenhOlAkxqadwHOqEz Ftq0UA2dxVZA3w== X-Received: by 10.223.151.6 with SMTP id r6mr11394243wrb.189.1493495646252; Sat, 29 Apr 2017 12:54:06 -0700 (PDT) Received: from sanghar.laptop ([2a00:23c4:7320:5e00:224:d6ff:fe76:7136]) by smtp.gmail.com with ESMTPSA id f64sm6498741wmg.2.2017.04.29.12.54.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 29 Apr 2017 12:54:05 -0700 (PDT) Received: by sanghar.laptop (sSMTP sendmail emulation); Sat, 29 Apr 2017 20:54:03 +0100 Message-Id: <20170429195403.522579504@gmail.com> User-Agent: quilt/0.65 Date: Sat, 29 Apr 2017 20:52:59 +0100 From: Okash Khawaja To: Greg Kroah-Hartman , Jiri Slaby , Samuel Thibault , linux-kernel@vger.kernel.org Cc: William Hubbs , Chris Brannon , Kirk Reiser , speakup@linux-speakup.org, devel@driverdev.osuosl.org Subject: [patch 2/6] tty: export tty_open_by_driver References: <20170429195257.630355823@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=02_export_tty_open_by_driver X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-BeenThere: speakup@linux-speakup.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Speakup is a screen review system for Linux." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Apr 2017 19:57:23 -0000 This applies on top of the changes already in staging-next branch which allow kernel access to TTY dev. Signe-doff-by: Okash Khawaja Reviewed-by: Samuel Thibault Index: linux-staging/drivers/tty/tty_io.c =================================================================== --- linux-staging.orig/drivers/tty/tty_io.c +++ linux-staging/drivers/tty/tty_io.c @@ -1369,7 +1369,10 @@ static struct tty_struct *tty_driver_loo struct tty_struct *tty; if (driver->ops->lookup) - tty = driver->ops->lookup(driver, file, idx); + if (!file) + tty = ERR_PTR(-EIO); + else + tty = driver->ops->lookup(driver, file, idx); else tty = driver->ttys[idx]; @@ -2001,7 +2004,7 @@ static struct tty_driver *tty_lookup_dri struct tty_driver *console_driver = console_device(index); if (console_driver) { driver = tty_driver_kref_get(console_driver); - if (driver) { + if (driver && filp) { /* Don't let /dev/console block */ filp->f_flags |= O_NONBLOCK; break; @@ -2034,7 +2037,7 @@ static struct tty_driver *tty_lookup_dri * - concurrent tty driver removal w/ lookup * - concurrent tty removal from driver table */ -static struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode, +struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode, struct file *filp) { struct tty_struct *tty; @@ -2079,6 +2082,7 @@ out: tty_driver_kref_put(driver); return tty; } +EXPORT_SYMBOL(tty_open_by_driver); /** * tty_open - open a tty device Index: linux-staging/include/linux/tty.h =================================================================== --- linux-staging.orig/include/linux/tty.h +++ linux-staging/include/linux/tty.h @@ -401,6 +401,8 @@ extern struct tty_struct *get_current_tt /* tty_io.c */ extern int __init tty_init(void); extern const char *tty_name(const struct tty_struct *tty); +extern struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode, + struct file *filp); #else static inline void console_init(void) { }