Commit 66d450e8 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: provide tty_standard_install helper

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: default avatarJiri Slaby <jslaby@suse.cz>
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Acked-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6bbcbf22
...@@ -1271,6 +1271,19 @@ int tty_init_termios(struct tty_struct *tty) ...@@ -1271,6 +1271,19 @@ int tty_init_termios(struct tty_struct *tty)
} }
EXPORT_SYMBOL_GPL(tty_init_termios); 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 * tty_driver_install_tty() - install a tty entry in the driver
* @driver: the driver for the tty * @driver: the driver for the tty
...@@ -1286,21 +1299,8 @@ EXPORT_SYMBOL_GPL(tty_init_termios); ...@@ -1286,21 +1299,8 @@ EXPORT_SYMBOL_GPL(tty_init_termios);
static int tty_driver_install_tty(struct tty_driver *driver, static int tty_driver_install_tty(struct tty_driver *driver,
struct tty_struct *tty) struct tty_struct *tty)
{ {
int idx = tty->index; return driver->ops->install ? driver->ops->install(driver, tty) :
int ret; tty_standard_install(driver, tty);
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;
} }
/** /**
......
...@@ -484,6 +484,8 @@ extern void deinitialize_tty_struct(struct tty_struct *tty); ...@@ -484,6 +484,8 @@ extern void deinitialize_tty_struct(struct tty_struct *tty);
extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx); 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_release(struct inode *inode, struct file *filp);
extern int tty_init_termios(struct tty_struct *tty); 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_tty(struct tty_struct *tty);
extern struct tty_struct *tty_pair_get_pty(struct tty_struct *tty); extern struct tty_struct *tty_pair_get_pty(struct tty_struct *tty);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment