aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_io.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-01-30 15:14:28 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-02-02 17:55:45 -0500
commit66d450e84ec656ec4b774c41cd8d46b3e48d51df (patch)
tree3a2d623257ec6ac04de296fa98f8485bd4b0a3f8 /drivers/tty/tty_io.c
parent6bbcbf22085e0b144899d6067e243dd26c0e7533 (diff)
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: Jiri Slaby <jslaby@suse.cz> Cc: Havard Skinnemoen <hskinnemoen@google.com> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/tty_io.c')
-rw-r--r--drivers/tty/tty_io.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index fbcc14063804..44736f9e61d7 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)
1271} 1271}
1272EXPORT_SYMBOL_GPL(tty_init_termios); 1272EXPORT_SYMBOL_GPL(tty_init_termios);
1273 1273
1274int tty_standard_install(struct tty_driver *driver, struct tty_struct *tty)
1275{
1276 int ret = tty_init_termios(tty);
1277 if (ret)
1278 return ret;
1279
1280 tty_driver_kref_get(driver);
1281 tty->count++;
1282 driver->ttys[tty->index] = tty;
1283 return 0;
1284}
1285EXPORT_SYMBOL_GPL(tty_standard_install);
1286
1274/** 1287/**
1275 * tty_driver_install_tty() - install a tty entry in the driver 1288 * tty_driver_install_tty() - install a tty entry in the driver
1276 * @driver: the driver for the tty 1289 * @driver: the driver for the tty
@@ -1286,21 +1299,8 @@ EXPORT_SYMBOL_GPL(tty_init_termios);
1286static int tty_driver_install_tty(struct tty_driver *driver, 1299static int tty_driver_install_tty(struct tty_driver *driver,
1287 struct tty_struct *tty) 1300 struct tty_struct *tty)
1288{ 1301{
1289 int idx = tty->index; 1302 return driver->ops->install ? driver->ops->install(driver, tty) :
1290 int ret; 1303 tty_standard_install(driver, tty);
1291
1292 if (driver->ops->install) {
1293 ret = driver->ops->install(driver, tty);
1294 return ret;
1295 }
1296
1297 if (tty_init_termios(tty) == 0) {
1298 tty_driver_kref_get(driver);
1299 tty->count++;
1300 driver->ttys[idx] = tty;
1301 return 0;
1302 }
1303 return -ENOMEM;
1304} 1304}
1305 1305
1306/** 1306/**