From: Jiri Slaby <jslaby@suse.cz>
To: gregkh@suse.de
Cc: linux-kernel@vger.kernel.org, alan@linux.intel.com,
jirislaby@gmail.com, Havard Skinnemoen <hskinnemoen@google.com>
Subject: [PATCH 1/5] TTY: provide tty_standard_install helper
Date: Mon, 30 Jan 2012 21:14:28 +0100 [thread overview]
Message-ID: <1327954472-26594-1-git-send-email-jslaby@suse.cz> (raw)
There are currently many cut&paste copies of what
tty_driver_install_tty does when custom ->install method is not
provided. Let's get rid of the copies and create a helper with this
setup code.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alan Cox <alan@linux.intel.com>
---
drivers/tty/tty_io.c | 30 +++++++++++++++---------------
include/linux/tty.h | 2 ++
2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index fbcc140..44736f9 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1271,6 +1271,19 @@ int tty_init_termios(struct tty_struct *tty)
}
EXPORT_SYMBOL_GPL(tty_init_termios);
+int tty_standard_install(struct tty_driver *driver, struct tty_struct *tty)
+{
+ int ret = tty_init_termios(tty);
+ if (ret)
+ return ret;
+
+ tty_driver_kref_get(driver);
+ tty->count++;
+ driver->ttys[tty->index] = tty;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(tty_standard_install);
+
/**
* tty_driver_install_tty() - install a tty entry in the driver
* @driver: the driver for the tty
@@ -1286,21 +1299,8 @@ EXPORT_SYMBOL_GPL(tty_init_termios);
static int tty_driver_install_tty(struct tty_driver *driver,
struct tty_struct *tty)
{
- int idx = tty->index;
- int ret;
-
- if (driver->ops->install) {
- ret = driver->ops->install(driver, tty);
- return ret;
- }
-
- if (tty_init_termios(tty) == 0) {
- tty_driver_kref_get(driver);
- tty->count++;
- driver->ttys[idx] = tty;
- return 0;
- }
- return -ENOMEM;
+ return driver->ops->install ? driver->ops->install(driver, tty) :
+ tty_standard_install(driver, tty);
}
/**
diff --git a/include/linux/tty.h b/include/linux/tty.h
index f801a85..653fc57 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -490,6 +490,8 @@ extern void deinitialize_tty_struct(struct tty_struct *tty);
extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx);
extern int tty_release(struct inode *inode, struct file *filp);
extern int tty_init_termios(struct tty_struct *tty);
+extern int tty_standard_install(struct tty_driver *driver,
+ struct tty_struct *tty);
extern struct tty_struct *tty_pair_get_tty(struct tty_struct *tty);
extern struct tty_struct *tty_pair_get_pty(struct tty_struct *tty);
--
1.7.8.3
next reply other threads:[~2012-01-30 20:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-30 20:14 Jiri Slaby [this message]
2012-01-30 20:14 ` [PATCH 2/5] USB: serial, use tty_standard_install Jiri Slaby
2012-01-30 20:14 ` [PATCH 3/5] TTY: " Jiri Slaby
2012-01-30 20:37 ` Alan Cox
2012-02-01 9:40 ` Jiri Slaby
2012-02-01 9:52 ` Jiri Slaby
2012-02-02 23:05 ` Greg KH
2012-02-02 23:23 ` Jiri Slaby
2012-02-02 23:49 ` Greg KH
2012-01-30 20:14 ` [PATCH 4/5] TTY: pty, remove superfluous ptm test Jiri Slaby
2012-01-30 20:37 ` Alan Cox
2012-01-30 20:14 ` [PATCH 5/5] TTY: get rid of BTM around devpts_* Jiri Slaby
2012-01-30 20:36 ` [PATCH 1/5] TTY: provide tty_standard_install helper Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1327954472-26594-1-git-send-email-jslaby@suse.cz \
--to=jslaby@suse.cz \
--cc=alan@linux.intel.com \
--cc=gregkh@suse.de \
--cc=hskinnemoen@google.com \
--cc=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).