diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2014-07-10 15:01:22 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-07-11 20:54:28 -0400 |
commit | 2c964a2f4191f2229566895f1a0e85f8339f5dd1 (patch) | |
tree | f83c3259629e2b8416e96a03bcee8c6dc52bd9ca /drivers/tty/pty.c | |
parent | 493671a2cecbb75d5b1aee6959bef1ecb38b932d (diff) |
drivers: tty: Merge alloc_tty_struct and initialize_tty_struct
The two functions alloc_tty_struct and initialize_tty_struct are
always called together. Merge them into alloc_tty_struct, updating its
prototype and the only two callers of these functions.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r-- | drivers/tty/pty.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 25c9bc783722..ac723e3c031a 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -316,7 +316,7 @@ done: | |||
316 | * pty_common_install - set up the pty pair | 316 | * pty_common_install - set up the pty pair |
317 | * @driver: the pty driver | 317 | * @driver: the pty driver |
318 | * @tty: the tty being instantiated | 318 | * @tty: the tty being instantiated |
319 | * @bool: legacy, true if this is BSD style | 319 | * @legacy: true if this is BSD style |
320 | * | 320 | * |
321 | * Perform the initial set up for the tty/pty pair. Called from the | 321 | * Perform the initial set up for the tty/pty pair. Called from the |
322 | * tty layer when the port is first opened. | 322 | * tty layer when the port is first opened. |
@@ -331,18 +331,17 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty, | |||
331 | int idx = tty->index; | 331 | int idx = tty->index; |
332 | int retval = -ENOMEM; | 332 | int retval = -ENOMEM; |
333 | 333 | ||
334 | o_tty = alloc_tty_struct(); | ||
335 | if (!o_tty) | ||
336 | goto err; | ||
337 | ports[0] = kmalloc(sizeof **ports, GFP_KERNEL); | 334 | ports[0] = kmalloc(sizeof **ports, GFP_KERNEL); |
338 | ports[1] = kmalloc(sizeof **ports, GFP_KERNEL); | 335 | ports[1] = kmalloc(sizeof **ports, GFP_KERNEL); |
339 | if (!ports[0] || !ports[1]) | 336 | if (!ports[0] || !ports[1]) |
340 | goto err_free_tty; | 337 | goto err; |
341 | if (!try_module_get(driver->other->owner)) { | 338 | if (!try_module_get(driver->other->owner)) { |
342 | /* This cannot in fact currently happen */ | 339 | /* This cannot in fact currently happen */ |
343 | goto err_free_tty; | 340 | goto err; |
344 | } | 341 | } |
345 | initialize_tty_struct(o_tty, driver->other, idx); | 342 | o_tty = alloc_tty_struct(driver->other, idx); |
343 | if (!o_tty) | ||
344 | goto err_put_module; | ||
346 | 345 | ||
347 | if (legacy) { | 346 | if (legacy) { |
348 | /* We always use new tty termios data so we can do this | 347 | /* We always use new tty termios data so we can do this |
@@ -387,12 +386,12 @@ err_free_termios: | |||
387 | tty_free_termios(tty); | 386 | tty_free_termios(tty); |
388 | err_deinit_tty: | 387 | err_deinit_tty: |
389 | deinitialize_tty_struct(o_tty); | 388 | deinitialize_tty_struct(o_tty); |
389 | free_tty_struct(o_tty); | ||
390 | err_put_module: | ||
390 | module_put(o_tty->driver->owner); | 391 | module_put(o_tty->driver->owner); |
391 | err_free_tty: | 392 | err: |
392 | kfree(ports[0]); | 393 | kfree(ports[0]); |
393 | kfree(ports[1]); | 394 | kfree(ports[1]); |
394 | free_tty_struct(o_tty); | ||
395 | err: | ||
396 | return retval; | 395 | return retval; |
397 | } | 396 | } |
398 | 397 | ||