linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] Get rid of old tty_driver functions
@ 2021-07-23  7:43 Jiri Slaby
  2021-07-23  7:43 ` [PATCH 1/8] xtensa: ISS: don't panic in rs_init Jiri Slaby
                   ` (8 more replies)
  0 siblings, 9 replies; 22+ messages in thread
From: Jiri Slaby @ 2021-07-23  7:43 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

This series converts the rest of the drivers to use:
* tty_alloc_driver instead of alloc_tty_driver, and
* tty_driver_kref_put instead of put_tty_driver.

They were more of less interchangeable, alloc_tty_driver() and
put_tty_driver() are older interfaces which weren't eliminated until
now.

There are few fix and cleanup patches around tty_driver too.

Jiri Slaby (8):
  xtensa: ISS: don't panic in rs_init
  hvsi: don't panic on tty_register_driver failure
  tty: don't store semi-state into tty drivers
  tty: stop using alloc_tty_driver
  tty: drop alloc_tty_driver
  tty: make tty_set_operations an inline
  tty: drop put_tty_driver
  tty: pdc_cons, free tty_driver upon failure

 arch/alpha/kernel/srmcons.c            |  8 ++--
 arch/m68k/emu/nfcon.c                  | 30 +++++++-------
 arch/parisc/kernel/pdc_cons.c          | 34 ++++++++--------
 arch/um/drivers/line.c                 | 13 +++---
 arch/xtensa/platforms/iss/console.c    | 45 +++++++++++++--------
 drivers/char/pcmcia/synclink_cs.c      |  4 +-
 drivers/char/ttyprintk.c               |  4 +-
 drivers/ipack/devices/ipoctal.c        | 13 +++---
 drivers/isdn/capi/capi.c               | 14 +++----
 drivers/misc/bcm-vk/bcm_vk_tty.c       |  8 ++--
 drivers/mmc/core/sdio_uart.c           | 12 +++---
 drivers/net/usb/hso.c                  | 12 +++---
 drivers/s390/char/con3215.c            | 11 +++---
 drivers/s390/char/sclp_tty.c           | 15 ++++---
 drivers/s390/char/sclp_vt220.c         |  9 ++---
 drivers/s390/char/tty3270.c            |  4 +-
 drivers/staging/fwserial/fwserial.c    |  8 ++--
 drivers/staging/gdm724x/gdm_tty.c      | 13 +++---
 drivers/staging/greybus/uart.c         |  4 +-
 drivers/tty/amiserial.c                | 42 ++++++++++----------
 drivers/tty/ehv_bytechan.c             | 34 +++++++++-------
 drivers/tty/goldfish.c                 | 18 ++++-----
 drivers/tty/hvc/hvc_console.c          | 10 ++---
 drivers/tty/hvc/hvcs.c                 | 12 +++---
 drivers/tty/hvc/hvsi.c                 | 55 ++++++++++++++++----------
 drivers/tty/ipwireless/tty.c           | 12 +++---
 drivers/tty/mips_ejtag_fdc.c           |  2 +-
 drivers/tty/moxa.c                     |  4 +-
 drivers/tty/mxser.c                    | 12 +++---
 drivers/tty/n_gsm.c                    | 13 +++---
 drivers/tty/nozomi.c                   | 12 +++---
 drivers/tty/serial/kgdb_nmi.c          | 11 +++---
 drivers/tty/serial/serial_core.c       | 12 +++---
 drivers/tty/synclink_gt.c              | 12 +++---
 drivers/tty/tty_io.c                   | 13 ------
 drivers/tty/ttynull.c                  |  4 +-
 drivers/tty/vcc.c                      |  4 +-
 drivers/tty/vt/vt.c                    |  6 +--
 drivers/usb/class/cdc-acm.c            | 14 +++----
 drivers/usb/gadget/function/u_serial.c | 36 +++++++++--------
 drivers/usb/host/xhci-dbgtty.c         |  4 +-
 drivers/usb/serial/usb-serial.c        | 13 +++---
 include/linux/tty_driver.h             | 21 +++-------
 net/bluetooth/rfcomm/tty.c             | 12 +++---
 44 files changed, 330 insertions(+), 319 deletions(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 1/8] xtensa: ISS: don't panic in rs_init
  2021-07-23  7:43 [PATCH 0/8] Get rid of old tty_driver functions Jiri Slaby
@ 2021-07-23  7:43 ` Jiri Slaby
  2021-07-23 10:18   ` Max Filippov
  2021-07-23  7:43 ` [PATCH 2/8] hvsi: don't panic on tty_register_driver failure Jiri Slaby
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 22+ messages in thread
From: Jiri Slaby @ 2021-07-23  7:43 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby, Chris Zankel,
	Max Filippov, linux-xtensa

While alloc_tty_driver failure in rs_init would mean we have much bigger
problem, there is no reason to panic when tty_register_driver fails
there. It can fail for various reasons.

So handle the failure gracefully. Actually handle them both while at it.
This will make at least the console functional as it was enabled earlier
by console_initcall in iss_console_init. Instead of shooting down the
whole system.

We move tty_port_init() after alloc_tty_driver(), so that we don't need
to destroy the port in case the latter function fails.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: linux-xtensa@linux-xtensa.org
---
 arch/xtensa/platforms/iss/console.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 21184488c277..0108504dfb45 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -136,9 +136,13 @@ static const struct tty_operations serial_ops = {
 
 static int __init rs_init(void)
 {
-	tty_port_init(&serial_port);
+	int ret;
 
 	serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES);
+	if (!serial_driver)
+		return -ENOMEM;
+
+	tty_port_init(&serial_port);
 
 	/* Initialize the tty_driver structure */
 
@@ -156,8 +160,15 @@ static int __init rs_init(void)
 	tty_set_operations(serial_driver, &serial_ops);
 	tty_port_link_device(&serial_port, serial_driver, 0);
 
-	if (tty_register_driver(serial_driver))
-		panic("Couldn't register serial driver\n");
+	ret = tty_register_driver(serial_driver);
+	if (ret) {
+		pr_err("Couldn't register serial driver\n");
+		tty_driver_kref_put(serial_driver);
+		tty_port_destroy(&serial_port);
+
+		return ret;
+	}
+
 	return 0;
 }
 
-- 
2.32.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 2/8] hvsi: don't panic on tty_register_driver failure
  2021-07-23  7:43 [PATCH 0/8] Get rid of old tty_driver functions Jiri Slaby
  2021-07-23  7:43 ` [PATCH 1/8] xtensa: ISS: don't panic in rs_init Jiri Slaby
@ 2021-07-23  7:43 ` Jiri Slaby
  2021-07-23  7:43 ` [PATCH 3/8] tty: don't store semi-state into tty drivers Jiri Slaby
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 22+ messages in thread
From: Jiri Slaby @ 2021-07-23  7:43 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby, linuxppc-dev

The alloc_tty_driver failure is handled gracefully in hvsi_init. But
tty_register_driver is not. panic is called if that one fails.

So handle the failure of tty_register_driver gracefully too. This will
keep at least the console functional as it was enabled earlier by
console_initcall in hvsi_console_init. Instead of shooting down the
whole system.

This means, we disable interrupts and restore hvsi_wait back to
poll_for_state().

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/tty/hvc/hvsi.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
index bfc15279d5bc..f0bc8e780051 100644
--- a/drivers/tty/hvc/hvsi.c
+++ b/drivers/tty/hvc/hvsi.c
@@ -1038,7 +1038,7 @@ static const struct tty_operations hvsi_ops = {
 
 static int __init hvsi_init(void)
 {
-	int i;
+	int i, ret;
 
 	hvsi_driver = alloc_tty_driver(hvsi_count);
 	if (!hvsi_driver)
@@ -1069,12 +1069,25 @@ static int __init hvsi_init(void)
 	}
 	hvsi_wait = wait_for_state; /* irqs active now */
 
-	if (tty_register_driver(hvsi_driver))
-		panic("Couldn't register hvsi console driver\n");
+	ret = tty_register_driver(hvsi_driver);
+	if (ret) {
+		pr_err("Couldn't register hvsi console driver\n");
+		goto err_free_irq;
+	}
 
 	printk(KERN_DEBUG "HVSI: registered %i devices\n", hvsi_count);
 
 	return 0;
+err_free_irq:
+	hvsi_wait = poll_for_state;
+	for (i = 0; i < hvsi_count; i++) {
+		struct hvsi_struct *hp = &hvsi_ports[i];
+
+		free_irq(hp->virq, hp);
+	}
+	tty_driver_kref_put(hvsi_driver);
+
+	return ret;
 }
 device_initcall(hvsi_init);
 
-- 
2.32.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 3/8] tty: don't store semi-state into tty drivers
  2021-07-23  7:43 [PATCH 0/8] Get rid of old tty_driver functions Jiri Slaby
  2021-07-23  7:43 ` [PATCH 1/8] xtensa: ISS: don't panic in rs_init Jiri Slaby
  2021-07-23  7:43 ` [PATCH 2/8] hvsi: don't panic on tty_register_driver failure Jiri Slaby
@ 2021-07-23  7:43 ` Jiri Slaby
  2021-07-23 10:23   ` Max Filippov
  2021-07-23 16:37   ` Helge Deller
  2021-07-23  7:43 ` [PATCH 4/8] tty: stop using alloc_tty_driver Jiri Slaby
                   ` (5 subsequent siblings)
  8 siblings, 2 replies; 22+ messages in thread
From: Jiri Slaby @ 2021-07-23  7:43 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby, Geert Uytterhoeven,
	James E.J. Bottomley, Helge Deller, Chris Zankel, Max Filippov,
	Laurentiu Tudor, Felipe Balbi

When a tty driver pointer is used as a return value of struct
console's device() hook, don't store a semi-state into global variable
which holds the tty driver. It could mean console::device() would return
a bogus value. This is important esp. after the next patch where we
switch from alloc_tty_driver to tty_alloc_driver. tty_alloc_driver
returns ERR_PTR in case of error and that might have unexpected results
as the code doesn't expect this.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Cc: Felipe Balbi <balbi@kernel.org>
---
 arch/m68k/emu/nfcon.c                  | 27 +++++++++++---------
 arch/parisc/kernel/pdc_cons.c          | 28 +++++++++++----------
 arch/xtensa/platforms/iss/console.c    | 33 +++++++++++++-----------
 drivers/tty/amiserial.c                | 35 ++++++++++++++------------
 drivers/tty/ehv_bytechan.c             | 28 ++++++++++++---------
 drivers/tty/hvc/hvsi.c                 | 35 ++++++++++++++------------
 drivers/usb/gadget/function/u_serial.c | 32 ++++++++++++-----------
 7 files changed, 119 insertions(+), 99 deletions(-)

diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c
index 92636c89d65b..f393af375c90 100644
--- a/arch/m68k/emu/nfcon.c
+++ b/arch/m68k/emu/nfcon.c
@@ -120,35 +120,38 @@ early_param("debug", nf_debug_setup);
 
 static int __init nfcon_init(void)
 {
+	struct tty_driver *driver;
 	int res;
 
 	stderr_id = nf_get_id("NF_STDERR");
 	if (!stderr_id)
 		return -ENODEV;
 
-	nfcon_tty_driver = alloc_tty_driver(1);
-	if (!nfcon_tty_driver)
+	driver = alloc_tty_driver(1);
+	if (!driver)
 		return -ENOMEM;
 
 	tty_port_init(&nfcon_tty_port);
 
-	nfcon_tty_driver->driver_name = "nfcon";
-	nfcon_tty_driver->name = "nfcon";
-	nfcon_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM;
-	nfcon_tty_driver->subtype = SYSTEM_TYPE_TTY;
-	nfcon_tty_driver->init_termios = tty_std_termios;
-	nfcon_tty_driver->flags = TTY_DRIVER_REAL_RAW;
+	driver->driver_name = "nfcon";
+	driver->name = "nfcon";
+	driver->type = TTY_DRIVER_TYPE_SYSTEM;
+	driver->subtype = SYSTEM_TYPE_TTY;
+	driver->init_termios = tty_std_termios;
+	driver->flags = TTY_DRIVER_REAL_RAW;
 
-	tty_set_operations(nfcon_tty_driver, &nfcon_tty_ops);
-	tty_port_link_device(&nfcon_tty_port, nfcon_tty_driver, 0);
-	res = tty_register_driver(nfcon_tty_driver);
+	tty_set_operations(driver, &nfcon_tty_ops);
+	tty_port_link_device(&nfcon_tty_port, driver, 0);
+	res = tty_register_driver(driver);
 	if (res) {
 		pr_err("failed to register nfcon tty driver\n");
-		put_tty_driver(nfcon_tty_driver);
+		put_tty_driver(driver);
 		tty_port_destroy(&nfcon_tty_port);
 		return res;
 	}
 
+	nfcon_tty_driver = driver;
+
 	if (!(nf_console.flags & CON_ENABLED))
 		register_console(&nf_console);
 
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index 39ccad063533..650cb01203de 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -138,6 +138,7 @@ static struct tty_driver *pdc_console_tty_driver;
 
 static int __init pdc_console_tty_driver_init(void)
 {
+	struct tty_driver *driver;
 	int err;
 
 	/* Check if the console driver is still registered.
@@ -160,31 +161,32 @@ static int __init pdc_console_tty_driver_init(void)
 	printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n");
 	pdc_cons.flags &= ~CON_BOOT;
 
-	pdc_console_tty_driver = alloc_tty_driver(1);
-
-	if (!pdc_console_tty_driver)
+	driver = alloc_tty_driver(1);
+	if (!driver)
 		return -ENOMEM;
 
 	tty_port_init(&tty_port);
 
-	pdc_console_tty_driver->driver_name = "pdc_cons";
-	pdc_console_tty_driver->name = "ttyB";
-	pdc_console_tty_driver->major = MUX_MAJOR;
-	pdc_console_tty_driver->minor_start = 0;
-	pdc_console_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM;
-	pdc_console_tty_driver->init_termios = tty_std_termios;
-	pdc_console_tty_driver->flags = TTY_DRIVER_REAL_RAW |
+	driver->driver_name = "pdc_cons";
+	driver->name = "ttyB";
+	driver->major = MUX_MAJOR;
+	driver->minor_start = 0;
+	driver->type = TTY_DRIVER_TYPE_SYSTEM;
+	driver->init_termios = tty_std_termios;
+	driver->flags = TTY_DRIVER_REAL_RAW |
 		TTY_DRIVER_RESET_TERMIOS;
-	tty_set_operations(pdc_console_tty_driver, &pdc_console_tty_ops);
-	tty_port_link_device(&tty_port, pdc_console_tty_driver, 0);
+	tty_set_operations(driver, &pdc_console_tty_ops);
+	tty_port_link_device(&tty_port, driver, 0);
 
-	err = tty_register_driver(pdc_console_tty_driver);
+	err = tty_register_driver(driver);
 	if (err) {
 		printk(KERN_ERR "Unable to register the PDC console TTY driver\n");
 		tty_port_destroy(&tty_port);
 		return err;
 	}
 
+	pdc_console_tty_driver = driver;
+
 	return 0;
 }
 device_initcall(pdc_console_tty_driver_init);
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 0108504dfb45..9c3cf369b7b2 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -136,39 +136,42 @@ static const struct tty_operations serial_ops = {
 
 static int __init rs_init(void)
 {
+	struct tty_driver *driver;
 	int ret;
 
-	serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES);
-	if (!serial_driver)
+	driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES);
+	if (!driver)
 		return -ENOMEM;
 
 	tty_port_init(&serial_port);
 
 	/* Initialize the tty_driver structure */
 
-	serial_driver->driver_name = "iss_serial";
-	serial_driver->name = "ttyS";
-	serial_driver->major = TTY_MAJOR;
-	serial_driver->minor_start = 64;
-	serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
-	serial_driver->subtype = SERIAL_TYPE_NORMAL;
-	serial_driver->init_termios = tty_std_termios;
-	serial_driver->init_termios.c_cflag =
+	driver->driver_name = "iss_serial";
+	driver->name = "ttyS";
+	driver->major = TTY_MAJOR;
+	driver->minor_start = 64;
+	driver->type = TTY_DRIVER_TYPE_SERIAL;
+	driver->subtype = SERIAL_TYPE_NORMAL;
+	driver->init_termios = tty_std_termios;
+	driver->init_termios.c_cflag =
 		B9600 | CS8 | CREAD | HUPCL | CLOCAL;
-	serial_driver->flags = TTY_DRIVER_REAL_RAW;
+	driver->flags = TTY_DRIVER_REAL_RAW;
 
-	tty_set_operations(serial_driver, &serial_ops);
-	tty_port_link_device(&serial_port, serial_driver, 0);
+	tty_set_operations(driver, &serial_ops);
+	tty_port_link_device(&serial_port, driver, 0);
 
-	ret = tty_register_driver(serial_driver);
+	ret = tty_register_driver(driver);
 	if (ret) {
 		pr_err("Couldn't register serial driver\n");
-		tty_driver_kref_put(serial_driver);
+		tty_driver_kref_put(driver);
 		tty_port_destroy(&serial_port);
 
 		return ret;
 	}
 
+	serial_driver = driver;
+
 	return 0;
 }
 
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 7ad103e128ac..bfd3acc1ecfa 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1490,34 +1490,35 @@ static const struct tty_port_operations amiga_port_ops = {
 static int __init amiga_serial_probe(struct platform_device *pdev)
 {
 	struct serial_state *state = &serial_state;
+	struct tty_driver *driver;
 	unsigned long flags;
 	int error;
 
-	serial_driver = alloc_tty_driver(1);
-	if (!serial_driver)
+	driver = alloc_tty_driver(1);
+	if (!driver)
 		return -ENOMEM;
 
 	/* Initialize the tty_driver structure */
 
-	serial_driver->driver_name = "amiserial";
-	serial_driver->name = "ttyS";
-	serial_driver->major = TTY_MAJOR;
-	serial_driver->minor_start = 64;
-	serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
-	serial_driver->subtype = SERIAL_TYPE_NORMAL;
-	serial_driver->init_termios = tty_std_termios;
-	serial_driver->init_termios.c_cflag =
+	driver->driver_name = "amiserial";
+	driver->name = "ttyS";
+	driver->major = TTY_MAJOR;
+	driver->minor_start = 64;
+	driver->type = TTY_DRIVER_TYPE_SERIAL;
+	driver->subtype = SERIAL_TYPE_NORMAL;
+	driver->init_termios = tty_std_termios;
+	driver->init_termios.c_cflag =
 		B9600 | CS8 | CREAD | HUPCL | CLOCAL;
-	serial_driver->flags = TTY_DRIVER_REAL_RAW;
-	tty_set_operations(serial_driver, &serial_ops);
+	driver->flags = TTY_DRIVER_REAL_RAW;
+	tty_set_operations(driver, &serial_ops);
 
 	memset(state, 0, sizeof(*state));
 	state->port = (int)&amiga_custom.serdatr; /* Just to give it a value */
 	tty_port_init(&state->tport);
 	state->tport.ops = &amiga_port_ops;
-	tty_port_link_device(&state->tport, serial_driver, 0);
+	tty_port_link_device(&state->tport, driver, 0);
 
-	error = tty_register_driver(serial_driver);
+	error = tty_register_driver(driver);
 	if (error)
 		goto fail_put_tty_driver;
 
@@ -1558,15 +1559,17 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, state);
 
+	serial_driver = driver;
+
 	return 0;
 
 fail_free_irq:
 	free_irq(IRQ_AMIGA_TBE, state);
 fail_unregister:
-	tty_unregister_driver(serial_driver);
+	tty_unregister_driver(driver);
 fail_put_tty_driver:
 	tty_port_destroy(&state->tport);
-	put_tty_driver(serial_driver);
+	put_tty_driver(driver);
 	return error;
 }
 
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c
index 445e5ff9b36d..97ae940af478 100644
--- a/drivers/tty/ehv_bytechan.c
+++ b/drivers/tty/ehv_bytechan.c
@@ -751,6 +751,7 @@ static struct platform_driver ehv_bc_tty_driver = {
  */
 static int __init ehv_bc_init(void)
 {
+	struct tty_driver *driver;
 	struct device_node *np;
 	unsigned int count = 0; /* Number of elements in bcs[] */
 	int ret;
@@ -773,26 +774,28 @@ static int __init ehv_bc_init(void)
 	if (!bcs)
 		return -ENOMEM;
 
-	ehv_bc_driver = alloc_tty_driver(count);
-	if (!ehv_bc_driver) {
+	driver = alloc_tty_driver(count);
+	if (!driver) {
 		ret = -ENOMEM;
 		goto err_free_bcs;
 	}
 
-	ehv_bc_driver->driver_name = "ehv-bc";
-	ehv_bc_driver->name = ehv_bc_console.name;
-	ehv_bc_driver->type = TTY_DRIVER_TYPE_CONSOLE;
-	ehv_bc_driver->subtype = SYSTEM_TYPE_CONSOLE;
-	ehv_bc_driver->init_termios = tty_std_termios;
-	ehv_bc_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
-	tty_set_operations(ehv_bc_driver, &ehv_bc_ops);
+	driver->driver_name = "ehv-bc";
+	driver->name = ehv_bc_console.name;
+	driver->type = TTY_DRIVER_TYPE_CONSOLE;
+	driver->subtype = SYSTEM_TYPE_CONSOLE;
+	driver->init_termios = tty_std_termios;
+	driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
+	tty_set_operations(driver, &ehv_bc_ops);
 
-	ret = tty_register_driver(ehv_bc_driver);
+	ret = tty_register_driver(driver);
 	if (ret) {
 		pr_err("ehv-bc: could not register tty driver (ret=%i)\n", ret);
 		goto err_put_tty_driver;
 	}
 
+	ehv_bc_driver = driver;
+
 	ret = platform_driver_register(&ehv_bc_tty_driver);
 	if (ret) {
 		pr_err("ehv-bc: could not register platform driver (ret=%i)\n",
@@ -803,9 +806,10 @@ static int __init ehv_bc_init(void)
 	return 0;
 
 err_deregister_tty_driver:
-	tty_unregister_driver(ehv_bc_driver);
+	ehv_bc_driver = NULL;
+	tty_unregister_driver(driver);
 err_put_tty_driver:
-	put_tty_driver(ehv_bc_driver);
+	put_tty_driver(driver);
 err_free_bcs:
 	kfree(bcs);
 
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
index f0bc8e780051..bfde7b1936a5 100644
--- a/drivers/tty/hvc/hvsi.c
+++ b/drivers/tty/hvc/hvsi.c
@@ -1038,29 +1038,30 @@ static const struct tty_operations hvsi_ops = {
 
 static int __init hvsi_init(void)
 {
+	struct tty_driver *driver;
 	int i, ret;
 
-	hvsi_driver = alloc_tty_driver(hvsi_count);
-	if (!hvsi_driver)
+	driver = alloc_tty_driver(hvsi_count);
+	if (!driver)
 		return -ENOMEM;
 
-	hvsi_driver->driver_name = "hvsi";
-	hvsi_driver->name = "hvsi";
-	hvsi_driver->major = HVSI_MAJOR;
-	hvsi_driver->minor_start = HVSI_MINOR;
-	hvsi_driver->type = TTY_DRIVER_TYPE_SYSTEM;
-	hvsi_driver->init_termios = tty_std_termios;
-	hvsi_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL;
-	hvsi_driver->init_termios.c_ispeed = 9600;
-	hvsi_driver->init_termios.c_ospeed = 9600;
-	hvsi_driver->flags = TTY_DRIVER_REAL_RAW;
-	tty_set_operations(hvsi_driver, &hvsi_ops);
+	driver->driver_name = "hvsi";
+	driver->name = "hvsi";
+	driver->major = HVSI_MAJOR;
+	driver->minor_start = HVSI_MINOR;
+	driver->type = TTY_DRIVER_TYPE_SYSTEM;
+	driver->init_termios = tty_std_termios;
+	driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL;
+	driver->init_termios.c_ispeed = 9600;
+	driver->init_termios.c_ospeed = 9600;
+	driver->flags = TTY_DRIVER_REAL_RAW;
+	tty_set_operations(driver, &hvsi_ops);
 
 	for (i=0; i < hvsi_count; i++) {
 		struct hvsi_struct *hp = &hvsi_ports[i];
 		int ret = 1;
 
-		tty_port_link_device(&hp->port, hvsi_driver, i);
+		tty_port_link_device(&hp->port, driver, i);
 
 		ret = request_irq(hp->virq, hvsi_interrupt, 0, "hvsi", hp);
 		if (ret)
@@ -1069,12 +1070,14 @@ static int __init hvsi_init(void)
 	}
 	hvsi_wait = wait_for_state; /* irqs active now */
 
-	ret = tty_register_driver(hvsi_driver);
+	ret = tty_register_driver(driver);
 	if (ret) {
 		pr_err("Couldn't register hvsi console driver\n");
 		goto err_free_irq;
 	}
 
+	hvsi_driver = driver;
+
 	printk(KERN_DEBUG "HVSI: registered %i devices\n", hvsi_count);
 
 	return 0;
@@ -1085,7 +1088,7 @@ static int __init hvsi_init(void)
 
 		free_irq(hp->virq, hp);
 	}
-	tty_driver_kref_put(hvsi_driver);
+	tty_driver_kref_put(driver);
 
 	return ret;
 }
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index bffef8e47dac..c99917a07a96 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -1445,51 +1445,53 @@ EXPORT_SYMBOL_GPL(gserial_resume);
 
 static int userial_init(void)
 {
+	struct tty_driver *driver;
 	unsigned			i;
 	int				status;
 
-	gs_tty_driver = alloc_tty_driver(MAX_U_SERIAL_PORTS);
-	if (!gs_tty_driver)
+	driver = alloc_tty_driver(MAX_U_SERIAL_PORTS);
+	if (!driver)
 		return -ENOMEM;
 
-	gs_tty_driver->driver_name = "g_serial";
-	gs_tty_driver->name = "ttyGS";
+	driver->driver_name = "g_serial";
+	driver->name = "ttyGS";
 	/* uses dynamically assigned dev_t values */
 
-	gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
-	gs_tty_driver->subtype = SERIAL_TYPE_NORMAL;
-	gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
-	gs_tty_driver->init_termios = tty_std_termios;
+	driver->type = TTY_DRIVER_TYPE_SERIAL;
+	driver->subtype = SERIAL_TYPE_NORMAL;
+	driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
+	driver->init_termios = tty_std_termios;
 
 	/* 9600-8-N-1 ... matches defaults expected by "usbser.sys" on
 	 * MS-Windows.  Otherwise, most of these flags shouldn't affect
 	 * anything unless we were to actually hook up to a serial line.
 	 */
-	gs_tty_driver->init_termios.c_cflag =
+	driver->init_termios.c_cflag =
 			B9600 | CS8 | CREAD | HUPCL | CLOCAL;
-	gs_tty_driver->init_termios.c_ispeed = 9600;
-	gs_tty_driver->init_termios.c_ospeed = 9600;
+	driver->init_termios.c_ispeed = 9600;
+	driver->init_termios.c_ospeed = 9600;
 
-	tty_set_operations(gs_tty_driver, &gs_tty_ops);
+	tty_set_operations(driver, &gs_tty_ops);
 	for (i = 0; i < MAX_U_SERIAL_PORTS; i++)
 		mutex_init(&ports[i].lock);
 
 	/* export the driver ... */
-	status = tty_register_driver(gs_tty_driver);
+	status = tty_register_driver(driver);
 	if (status) {
 		pr_err("%s: cannot register, err %d\n",
 				__func__, status);
 		goto fail;
 	}
 
+	gs_tty_driver = driver;
+
 	pr_debug("%s: registered %d ttyGS* device%s\n", __func__,
 			MAX_U_SERIAL_PORTS,
 			(MAX_U_SERIAL_PORTS == 1) ? "" : "s");
 
 	return status;
 fail:
-	put_tty_driver(gs_tty_driver);
-	gs_tty_driver = NULL;
+	put_tty_driver(driver);
 	return status;
 }
 module_init(userial_init);
-- 
2.32.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 4/8] tty: stop using alloc_tty_driver
  2021-07-23  7:43 [PATCH 0/8] Get rid of old tty_driver functions Jiri Slaby
                   ` (2 preceding siblings ...)
  2021-07-23  7:43 ` [PATCH 3/8] tty: don't store semi-state into tty drivers Jiri Slaby
@ 2021-07-23  7:43 ` Jiri Slaby
  2021-07-23  7:49   ` Samuel Iglesias Gonsálvez
                     ` (3 more replies)
  2021-07-23  7:43 ` [PATCH 5/8] tty: drop alloc_tty_driver Jiri Slaby
                   ` (4 subsequent siblings)
  8 siblings, 4 replies; 22+ messages in thread
From: Jiri Slaby @ 2021-07-23  7:43 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Geert Uytterhoeven,
	James E.J. Bottomley, Helge Deller, Jeff Dike,
	Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
	Samuel Iglesias Gonsalvez, Jens Taprogge, Karsten Keil,
	Ulf Hansson, David S. Miller, Jakub Kicinski, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger, Laurentiu Tudor,
	Jiri Kosina, David Sterba, Shawn Guo, Sascha Hauer,
	Oliver Neukum, Felipe Balbi, Johan Hovold, Marcel Holtmann,
	Johan Hedberg, Luiz Augusto von Dentz

alloc_tty_driver was deprecated by tty_alloc_driver in commit
7f0bc6a68ed9 (TTY: pass flags to alloc_tty_driver) in 2012.

I never got into eliminating alloc_tty_driver until now. So we still
have two functions for allocating drivers which might be confusing. So
get rid of alloc_tty_driver uses to eliminate it for good in the next
patch.

Note we need to switch return value checking as tty_alloc_driver uses
ERR_PTR. And flags are now a parameter of tty_alloc_driver.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Richard Henderson <rth@twiddle.net>(odd fixer:ALPHA PORT)
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Cc: Jens Taprogge <jens.taprogge@taprogge.org>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: David Sterba <dsterba@suse.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Johan Hovold <johan@kernel.org>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
---
 arch/alpha/kernel/srmcons.c            |  6 +++---
 arch/m68k/emu/nfcon.c                  |  7 +++----
 arch/parisc/kernel/pdc_cons.c          |  9 ++++-----
 arch/um/drivers/line.c                 | 11 ++++++-----
 arch/xtensa/platforms/iss/console.c    |  7 +++----
 drivers/ipack/devices/ipoctal.c        |  9 ++++-----
 drivers/isdn/capi/capi.c               | 10 ++++------
 drivers/mmc/core/sdio_uart.c           |  8 ++++----
 drivers/net/usb/hso.c                  |  8 ++++----
 drivers/s390/char/con3215.c            |  7 +++----
 drivers/s390/char/sclp_tty.c           |  7 +++----
 drivers/s390/char/sclp_vt220.c         |  7 +++----
 drivers/staging/gdm724x/gdm_tty.c      |  9 ++++-----
 drivers/tty/amiserial.c                |  7 +++----
 drivers/tty/ehv_bytechan.c             |  8 ++++----
 drivers/tty/goldfish.c                 | 14 +++++++-------
 drivers/tty/hvc/hvc_console.c          |  8 ++++----
 drivers/tty/hvc/hvcs.c                 |  8 ++++----
 drivers/tty/hvc/hvsi.c                 |  7 +++----
 drivers/tty/ipwireless/tty.c           |  8 ++++----
 drivers/tty/mxser.c                    |  8 ++++----
 drivers/tty/n_gsm.c                    |  9 ++++-----
 drivers/tty/nozomi.c                   |  8 ++++----
 drivers/tty/serial/kgdb_nmi.c          |  7 +++----
 drivers/tty/serial/serial_core.c       |  8 +++++---
 drivers/tty/synclink_gt.c              |  8 ++++----
 drivers/tty/vt/vt.c                    |  6 +++---
 drivers/usb/class/cdc-acm.c            |  8 ++++----
 drivers/usb/gadget/function/u_serial.c |  8 ++++----
 drivers/usb/serial/usb-serial.c        |  9 ++++-----
 net/bluetooth/rfcomm/tty.c             |  8 ++++----
 31 files changed, 120 insertions(+), 132 deletions(-)

diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
index fc03471a0b0f..d0a1b08d851d 100644
--- a/arch/alpha/kernel/srmcons.c
+++ b/arch/alpha/kernel/srmcons.c
@@ -204,9 +204,9 @@ srmcons_init(void)
 		struct tty_driver *driver;
 		int err;
 
-		driver = alloc_tty_driver(MAX_SRM_CONSOLE_DEVICES);
-		if (!driver)
-			return -ENOMEM;
+		driver = tty_alloc_driver(MAX_SRM_CONSOLE_DEVICES, 0);
+		if (IS_ERR(driver))
+			return PTR_ERR(driver);
 
 		tty_port_init(&srmcons_singleton.port);
 
diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c
index f393af375c90..b3b64d03bad6 100644
--- a/arch/m68k/emu/nfcon.c
+++ b/arch/m68k/emu/nfcon.c
@@ -127,9 +127,9 @@ static int __init nfcon_init(void)
 	if (!stderr_id)
 		return -ENODEV;
 
-	driver = alloc_tty_driver(1);
-	if (!driver)
-		return -ENOMEM;
+	driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW);
+	if (IS_ERR(driver))
+		return PTR_ERR(driver);
 
 	tty_port_init(&nfcon_tty_port);
 
@@ -138,7 +138,6 @@ static int __init nfcon_init(void)
 	driver->type = TTY_DRIVER_TYPE_SYSTEM;
 	driver->subtype = SYSTEM_TYPE_TTY;
 	driver->init_termios = tty_std_termios;
-	driver->flags = TTY_DRIVER_REAL_RAW;
 
 	tty_set_operations(driver, &nfcon_tty_ops);
 	tty_port_link_device(&nfcon_tty_port, driver, 0);
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index 650cb01203de..70c2a1648fc1 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -161,9 +161,10 @@ static int __init pdc_console_tty_driver_init(void)
 	printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n");
 	pdc_cons.flags &= ~CON_BOOT;
 
-	driver = alloc_tty_driver(1);
-	if (!driver)
-		return -ENOMEM;
+	driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_RESET_TERMIOS);
+	if (IS_ERR(driver))
+		return PTR_ERR(driver);
 
 	tty_port_init(&tty_port);
 
@@ -173,8 +174,6 @@ static int __init pdc_console_tty_driver_init(void)
 	driver->minor_start = 0;
 	driver->type = TTY_DRIVER_TYPE_SYSTEM;
 	driver->init_termios = tty_std_termios;
-	driver->flags = TTY_DRIVER_REAL_RAW |
-		TTY_DRIVER_RESET_TERMIOS;
 	tty_set_operations(driver, &pdc_console_tty_ops);
 	tty_port_link_device(&tty_port, driver, 0);
 
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index fbc623d2cc07..0d8f4ee6335d 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -538,12 +538,14 @@ int register_lines(struct line_driver *line_driver,
 		   const struct tty_operations *ops,
 		   struct line *lines, int nlines)
 {
-	struct tty_driver *driver = alloc_tty_driver(nlines);
+	struct tty_driver *driver;
 	int err;
 	int i;
 
-	if (!driver)
-		return -ENOMEM;
+	driver = tty_alloc_driver(nlines, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(driver))
+		return PTR_ERR(driver);
 
 	driver->driver_name = line_driver->name;
 	driver->name = line_driver->device_name;
@@ -551,9 +553,8 @@ int register_lines(struct line_driver *line_driver,
 	driver->minor_start = line_driver->minor_start;
 	driver->type = line_driver->type;
 	driver->subtype = line_driver->subtype;
-	driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 	driver->init_termios = tty_std_termios;
-	
+
 	for (i = 0; i < nlines; i++) {
 		tty_port_init(&lines[i].port);
 		lines[i].port.ops = &line_port_ops;
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 9c3cf369b7b2..0b8a0565cdfd 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -139,9 +139,9 @@ static int __init rs_init(void)
 	struct tty_driver *driver;
 	int ret;
 
-	driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES);
-	if (!driver)
-		return -ENOMEM;
+	driver = tty_alloc_driver(SERIAL_MAX_NUM_LINES, TTY_DRIVER_REAL_RAW);
+	if (IS_ERR(driver))
+		return PTR_ERR(driver);
 
 	tty_port_init(&serial_port);
 
@@ -156,7 +156,6 @@ static int __init rs_init(void)
 	driver->init_termios = tty_std_termios;
 	driver->init_termios.c_cflag =
 		B9600 | CS8 | CREAD | HUPCL | CLOCAL;
-	driver->flags = TTY_DRIVER_REAL_RAW;
 
 	tty_set_operations(driver, &serial_ops);
 	tty_port_link_device(&serial_port, driver, 0);
diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c
index 20fa02c81070..be6d11f46e62 100644
--- a/drivers/ipack/devices/ipoctal.c
+++ b/drivers/ipack/devices/ipoctal.c
@@ -347,10 +347,10 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
 	/* Register the TTY device */
 
 	/* Each IP-OCTAL channel is a TTY port */
-	tty = alloc_tty_driver(NR_CHANNELS);
-
-	if (!tty)
-		return -ENOMEM;
+	tty = tty_alloc_driver(NR_CHANNELS, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(tty))
+		return PTR_ERR(tty);
 
 	/* Fill struct tty_driver with ipoctal data */
 	tty->owner = THIS_MODULE;
@@ -362,7 +362,6 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
 	tty->minor_start = 0;
 	tty->type = TTY_DRIVER_TYPE_SERIAL;
 	tty->subtype = SERIAL_TYPE_NORMAL;
-	tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 	tty->init_termios = tty_std_termios;
 	tty->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
 	tty->init_termios.c_ispeed = 9600;
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index d5f9261fa879..32abf4d15450 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1269,10 +1269,11 @@ static int __init capinc_tty_init(void)
 	if (!capiminors)
 		return -ENOMEM;
 
-	drv = alloc_tty_driver(capi_ttyminors);
-	if (!drv) {
+	drv = tty_alloc_driver(capi_ttyminors, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(drv)) {
 		kfree(capiminors);
-		return -ENOMEM;
+		return PTR_ERR(drv);
 	}
 	drv->driver_name = "capi_nc";
 	drv->name = "capi!";
@@ -1285,9 +1286,6 @@ static int __init capinc_tty_init(void)
 	drv->init_termios.c_oflag = OPOST | ONLCR;
 	drv->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
 	drv->init_termios.c_lflag = 0;
-	drv->flags =
-		TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS |
-		TTY_DRIVER_DYNAMIC_DEV;
 	tty_set_operations(drv, &capinc_ops);
 
 	err = tty_register_driver(drv);
diff --git a/drivers/mmc/core/sdio_uart.c b/drivers/mmc/core/sdio_uart.c
index c36242b86b1d..04a57832e486 100644
--- a/drivers/mmc/core/sdio_uart.c
+++ b/drivers/mmc/core/sdio_uart.c
@@ -1135,9 +1135,10 @@ static int __init sdio_uart_init(void)
 	int ret;
 	struct tty_driver *tty_drv;
 
-	sdio_uart_tty_driver = tty_drv = alloc_tty_driver(UART_NR);
-	if (!tty_drv)
-		return -ENOMEM;
+	sdio_uart_tty_driver = tty_drv = tty_alloc_driver(UART_NR,
+			TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(tty_drv))
+		return PTR_ERR(tty_drv);
 
 	tty_drv->driver_name = "sdio_uart";
 	tty_drv->name =   "ttySDIO";
@@ -1145,7 +1146,6 @@ static int __init sdio_uart_init(void)
 	tty_drv->minor_start = 0;
 	tty_drv->type = TTY_DRIVER_TYPE_SERIAL;
 	tty_drv->subtype = SERIAL_TYPE_NORMAL;
-	tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 	tty_drv->init_termios = tty_std_termios;
 	tty_drv->init_termios.c_cflag = B4800 | CS8 | CREAD | HUPCL | CLOCAL;
 	tty_drv->init_termios.c_ispeed = 4800;
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index dec96e8ab567..29df4b34e002 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -3242,9 +3242,10 @@ static int __init hso_init(void)
 		serial_table[i] = NULL;
 
 	/* allocate our driver using the proper amount of supported minors */
-	tty_drv = alloc_tty_driver(HSO_SERIAL_TTY_MINORS);
-	if (!tty_drv)
-		return -ENOMEM;
+	tty_drv = tty_alloc_driver(HSO_SERIAL_TTY_MINORS, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(tty_drv))
+		return PTR_ERR(tty_drv);
 
 	/* fill in all needed values */
 	tty_drv->driver_name = driver_name;
@@ -3257,7 +3258,6 @@ static int __init hso_init(void)
 	tty_drv->minor_start = 0;
 	tty_drv->type = TTY_DRIVER_TYPE_SERIAL;
 	tty_drv->subtype = SERIAL_TYPE_NORMAL;
-	tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 	tty_drv->init_termios = tty_std_termios;
 	hso_init_termios(&tty_drv->init_termios);
 	tty_set_operations(tty_drv, &hso_serial_ops);
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 67c0009ca545..3818a89aef5c 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -1076,9 +1076,9 @@ static int __init tty3215_init(void)
 	if (!CONSOLE_IS_3215)
 		return 0;
 
-	driver = alloc_tty_driver(NR_3215);
-	if (!driver)
-		return -ENOMEM;
+	driver = tty_alloc_driver(NR_3215, TTY_DRIVER_REAL_RAW);
+	if (IS_ERR(driver))
+		return PTR_ERR(driver);
 
 	ret = ccw_driver_register(&raw3215_ccw_driver);
 	if (ret) {
@@ -1101,7 +1101,6 @@ static int __init tty3215_init(void)
 	driver->init_termios.c_iflag = IGNBRK | IGNPAR;
 	driver->init_termios.c_oflag = ONLCR;
 	driver->init_termios.c_lflag = ISIG;
-	driver->flags = TTY_DRIVER_REAL_RAW;
 	tty_set_operations(driver, &tty3215_ops);
 	ret = tty_register_driver(driver);
 	if (ret) {
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index 6be9de8ed37d..48790f8fb3b1 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -503,9 +503,9 @@ sclp_tty_init(void)
 		return 0;
 	if (!sclp.has_linemode)
 		return 0;
-	driver = alloc_tty_driver(1);
-	if (!driver)
-		return -ENOMEM;
+	driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW);
+	if (IS_ERR(driver))
+		return PTR_ERR(driver);
 
 	rc = sclp_rw_init();
 	if (rc) {
@@ -548,7 +548,6 @@ sclp_tty_init(void)
 	driver->init_termios.c_iflag = IGNBRK | IGNPAR;
 	driver->init_termios.c_oflag = ONLCR;
 	driver->init_termios.c_lflag = ISIG | ECHO;
-	driver->flags = TTY_DRIVER_REAL_RAW;
 	tty_set_operations(driver, &sclp_ops);
 	tty_port_link_device(&sclp_port, driver, 0);
 	rc = tty_register_driver(driver);
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index da2496306c04..c6a7ea32aa5c 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -732,9 +732,9 @@ static int __init sclp_vt220_tty_init(void)
 
 	/* Note: we're not testing for CONSOLE_IS_SCLP here to preserve
 	 * symmetry between VM and LPAR systems regarding ttyS1. */
-	driver = alloc_tty_driver(1);
-	if (!driver)
-		return -ENOMEM;
+	driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW);
+	if (IS_ERR(driver))
+		return PTR_ERR(driver);
 	rc = __sclp_vt220_init(MAX_KMEM_PAGES);
 	if (rc)
 		goto out_driver;
@@ -746,7 +746,6 @@ static int __init sclp_vt220_tty_init(void)
 	driver->type = TTY_DRIVER_TYPE_SYSTEM;
 	driver->subtype = SYSTEM_TYPE_TTY;
 	driver->init_termios = tty_std_termios;
-	driver->flags = TTY_DRIVER_REAL_RAW;
 	tty_set_operations(driver, &sclp_vt220_ops);
 	tty_port_link_device(&sclp_vt220_port, driver, 0);
 
diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
index 279de2cd9c4a..918575417264 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -281,9 +281,10 @@ int register_lte_tty_driver(void)
 	int ret;
 
 	for (i = 0; i < TTY_MAX_COUNT; i++) {
-		tty_driver = alloc_tty_driver(GDM_TTY_MINOR);
-		if (!tty_driver)
-			return -ENOMEM;
+		tty_driver = tty_alloc_driver(GDM_TTY_MINOR,
+				TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV);
+		if (IS_ERR(tty_driver))
+			return PTR_ERR(tty_driver);
 
 		tty_driver->owner = THIS_MODULE;
 		tty_driver->driver_name = DRIVER_STRING[i];
@@ -291,8 +292,6 @@ int register_lte_tty_driver(void)
 		tty_driver->major = GDM_TTY_MAJOR;
 		tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
 		tty_driver->subtype = SERIAL_TYPE_NORMAL;
-		tty_driver->flags = TTY_DRIVER_REAL_RAW |
-					TTY_DRIVER_DYNAMIC_DEV;
 		tty_driver->init_termios = tty_std_termios;
 		tty_driver->init_termios.c_cflag = B9600 | CS8 | HUPCL | CLOCAL;
 		tty_driver->init_termios.c_lflag = ISIG | ICANON | IEXTEN;
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index bfd3acc1ecfa..50f1a54ef35a 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1494,9 +1494,9 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
 	unsigned long flags;
 	int error;
 
-	driver = alloc_tty_driver(1);
-	if (!driver)
-		return -ENOMEM;
+	driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW);
+	if (IS_ERR(driver))
+		return PTR_ERR(driver);
 
 	/* Initialize the tty_driver structure */
 
@@ -1509,7 +1509,6 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
 	driver->init_termios = tty_std_termios;
 	driver->init_termios.c_cflag =
 		B9600 | CS8 | CREAD | HUPCL | CLOCAL;
-	driver->flags = TTY_DRIVER_REAL_RAW;
 	tty_set_operations(driver, &serial_ops);
 
 	memset(state, 0, sizeof(*state));
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c
index 97ae940af478..f580a5de3c98 100644
--- a/drivers/tty/ehv_bytechan.c
+++ b/drivers/tty/ehv_bytechan.c
@@ -774,9 +774,10 @@ static int __init ehv_bc_init(void)
 	if (!bcs)
 		return -ENOMEM;
 
-	driver = alloc_tty_driver(count);
-	if (!driver) {
-		ret = -ENOMEM;
+	driver = tty_alloc_driver(count, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(driver)) {
+		ret = PTR_ERR(driver);
 		goto err_free_bcs;
 	}
 
@@ -785,7 +786,6 @@ static int __init ehv_bc_init(void)
 	driver->type = TTY_DRIVER_TYPE_CONSOLE;
 	driver->subtype = SYSTEM_TYPE_CONSOLE;
 	driver->init_termios = tty_std_termios;
-	driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 	tty_set_operations(driver, &ehv_bc_ops);
 
 	ret = tty_register_driver(driver);
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index ccb683a6e6f5..853083fcebb8 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -253,18 +253,18 @@ static int goldfish_tty_create_driver(void)
 		ret = -ENOMEM;
 		goto err_alloc_goldfish_ttys_failed;
 	}
-	tty = alloc_tty_driver(goldfish_tty_line_count);
-	if (tty == NULL) {
-		ret = -ENOMEM;
-		goto err_alloc_tty_driver_failed;
+	tty = tty_alloc_driver(goldfish_tty_line_count,
+			TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(tty)) {
+		ret = PTR_ERR(tty);
+		goto err_tty_alloc_driver_failed;
 	}
 	tty->driver_name = "goldfish";
 	tty->name = "ttyGF";
 	tty->type = TTY_DRIVER_TYPE_SERIAL;
 	tty->subtype = SERIAL_TYPE_NORMAL;
 	tty->init_termios = tty_std_termios;
-	tty->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
-						TTY_DRIVER_DYNAMIC_DEV;
 	tty_set_operations(tty, &goldfish_tty_ops);
 	ret = tty_register_driver(tty);
 	if (ret)
@@ -275,7 +275,7 @@ static int goldfish_tty_create_driver(void)
 
 err_tty_register_driver_failed:
 	put_tty_driver(tty);
-err_alloc_tty_driver_failed:
+err_tty_alloc_driver_failed:
 	kfree(goldfish_ttys);
 	goldfish_ttys = NULL;
 err_alloc_goldfish_ttys_failed:
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 5bb8c4e44961..9215dd4bd9f0 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -1021,9 +1021,10 @@ static int hvc_init(void)
 	int err;
 
 	/* We need more than hvc_count adapters due to hotplug additions. */
-	drv = alloc_tty_driver(HVC_ALLOC_TTY_ADAPTERS);
-	if (!drv) {
-		err = -ENOMEM;
+	drv = tty_alloc_driver(HVC_ALLOC_TTY_ADAPTERS, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_RESET_TERMIOS);
+	if (IS_ERR(drv)) {
+		err = PTR_ERR(drv);
 		goto out;
 	}
 
@@ -1033,7 +1034,6 @@ static int hvc_init(void)
 	drv->minor_start = HVC_MINOR;
 	drv->type = TTY_DRIVER_TYPE_SYSTEM;
 	drv->init_termios = tty_std_termios;
-	drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
 	tty_set_operations(drv, &hvc_ops);
 
 	/* Always start the kthread because there can be hotplug vty adapters
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index fe5e6b4f43de..23aebc964201 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -1445,10 +1445,11 @@ static int hvcs_initialize(void)
 	} else
 		num_ttys_to_alloc = hvcs_parm_num_devs;
 
-	hvcs_tty_driver = alloc_tty_driver(num_ttys_to_alloc);
-	if (!hvcs_tty_driver) {
+	hvcs_tty_driver = tty_alloc_driver(num_ttys_to_alloc,
+			TTY_DRIVER_REAL_RAW);
+	if (IS_ERR(hvcs_tty_driver)) {
 		mutex_unlock(&hvcs_init_mutex);
-		return -ENOMEM;
+		return PTR_ERR(hvcs_tty_driver);
 	}
 
 	if (hvcs_alloc_index_list(num_ttys_to_alloc)) {
@@ -1473,7 +1474,6 @@ static int hvcs_initialize(void)
 	 * throw us into a horrible recursive echo-echo-echo loop.
 	 */
 	hvcs_tty_driver->init_termios = hvcs_tty_termios;
-	hvcs_tty_driver->flags = TTY_DRIVER_REAL_RAW;
 
 	tty_set_operations(hvcs_tty_driver, &hvcs_ops);
 
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
index bfde7b1936a5..aa81f4835fef 100644
--- a/drivers/tty/hvc/hvsi.c
+++ b/drivers/tty/hvc/hvsi.c
@@ -1041,9 +1041,9 @@ static int __init hvsi_init(void)
 	struct tty_driver *driver;
 	int i, ret;
 
-	driver = alloc_tty_driver(hvsi_count);
-	if (!driver)
-		return -ENOMEM;
+	driver = tty_alloc_driver(hvsi_count, TTY_DRIVER_REAL_RAW);
+	if (IS_ERR(driver))
+		return PTR_ERR(driver);
 
 	driver->driver_name = "hvsi";
 	driver->name = "hvsi";
@@ -1054,7 +1054,6 @@ static int __init hvsi_init(void)
 	driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL;
 	driver->init_termios.c_ispeed = 9600;
 	driver->init_termios.c_ospeed = 9600;
-	driver->flags = TTY_DRIVER_REAL_RAW;
 	tty_set_operations(driver, &hvsi_ops);
 
 	for (i=0; i < hvsi_count; i++) {
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index e3a5a5ba752c..d24404c222e0 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -564,9 +564,10 @@ int ipwireless_tty_init(void)
 {
 	int result;
 
-	ipw_tty_driver = alloc_tty_driver(IPWIRELESS_PCMCIA_MINORS);
-	if (!ipw_tty_driver)
-		return -ENOMEM;
+	ipw_tty_driver = tty_alloc_driver(IPWIRELESS_PCMCIA_MINORS,
+			TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(ipw_tty_driver))
+		return PTR_ERR(ipw_tty_driver);
 
 	ipw_tty_driver->driver_name = IPWIRELESS_PCCARD_NAME;
 	ipw_tty_driver->name = "ttyIPWp";
@@ -574,7 +575,6 @@ int ipwireless_tty_init(void)
 	ipw_tty_driver->minor_start = IPWIRELESS_PCMCIA_START;
 	ipw_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
 	ipw_tty_driver->subtype = SERIAL_TYPE_NORMAL;
-	ipw_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 	ipw_tty_driver->init_termios = tty_std_termios;
 	ipw_tty_driver->init_termios.c_cflag =
 	    B9600 | CS8 | CREAD | HUPCL | CLOCAL;
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 900ccb2ca166..650fc6fac88e 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1976,9 +1976,10 @@ static int __init mxser_module_init(void)
 {
 	int retval;
 
-	mxvar_sdriver = alloc_tty_driver(MXSER_PORTS);
-	if (!mxvar_sdriver)
-		return -ENOMEM;
+	mxvar_sdriver = tty_alloc_driver(MXSER_PORTS, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(mxvar_sdriver))
+		return PTR_ERR(mxvar_sdriver);
 
 	/* Initialize the tty_driver structure */
 	mxvar_sdriver->name = "ttyMI";
@@ -1988,7 +1989,6 @@ static int __init mxser_module_init(void)
 	mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL;
 	mxvar_sdriver->init_termios = tty_std_termios;
 	mxvar_sdriver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL;
-	mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW|TTY_DRIVER_DYNAMIC_DEV;
 	tty_set_operations(mxvar_sdriver, &mxser_ops);
 
 	retval = tty_register_driver(mxvar_sdriver);
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index e907b7a5cab5..0308669c21c6 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -3252,10 +3252,11 @@ static int __init gsm_init(void)
 		return status;
 	}
 
-	gsm_tty_driver = alloc_tty_driver(256);
-	if (!gsm_tty_driver) {
+	gsm_tty_driver = tty_alloc_driver(256, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK);
+	if (IS_ERR(gsm_tty_driver)) {
 		pr_err("gsm_init: tty allocation failed.\n");
-		status = -ENOMEM;
+		status = PTR_ERR(gsm_tty_driver);
 		goto err_unreg_ldisc;
 	}
 	gsm_tty_driver->driver_name	= "gsmtty";
@@ -3264,8 +3265,6 @@ static int __init gsm_init(void)
 	gsm_tty_driver->minor_start	= 0;
 	gsm_tty_driver->type		= TTY_DRIVER_TYPE_SERIAL;
 	gsm_tty_driver->subtype	= SERIAL_TYPE_NORMAL;
-	gsm_tty_driver->flags	= TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV
-						| TTY_DRIVER_HARDWARE_BREAK;
 	gsm_tty_driver->init_termios	= tty_std_termios;
 	/* Fixme */
 	gsm_tty_driver->init_termios.c_lflag &= ~ECHO;
diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index 0c80f25c8c3d..f3eb0aaec79b 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -1824,16 +1824,16 @@ static __init int nozomi_init(void)
 {
 	int ret;
 
-	ntty_driver = alloc_tty_driver(NTTY_TTY_MAXMINORS);
-	if (!ntty_driver)
-		return -ENOMEM;
+	ntty_driver = tty_alloc_driver(NTTY_TTY_MAXMINORS, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(ntty_driver))
+		return PTR_ERR(ntty_driver);
 
 	ntty_driver->driver_name = NOZOMI_NAME_TTY;
 	ntty_driver->name = "noz";
 	ntty_driver->major = 0;
 	ntty_driver->type = TTY_DRIVER_TYPE_SERIAL;
 	ntty_driver->subtype = SERIAL_TYPE_NORMAL;
-	ntty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 	ntty_driver->init_termios = tty_std_termios;
 	ntty_driver->init_termios.c_cflag = B115200 | CS8 | CREAD | \
 						HUPCL | CLOCAL;
diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
index 3e7c6ee8e4b3..9209573a7e37 100644
--- a/drivers/tty/serial/kgdb_nmi.c
+++ b/drivers/tty/serial/kgdb_nmi.c
@@ -330,17 +330,16 @@ int kgdb_register_nmi_console(void)
 	if (!arch_kgdb_ops.enable_nmi)
 		return 0;
 
-	kgdb_nmi_tty_driver = alloc_tty_driver(1);
-	if (!kgdb_nmi_tty_driver) {
+	kgdb_nmi_tty_driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW);
+	if (IS_ERR(kgdb_nmi_tty_driver)) {
 		pr_err("%s: cannot allocate tty\n", __func__);
-		return -ENOMEM;
+		return PTR_ERR(kgdb_nmi_tty_driver);
 	}
 	kgdb_nmi_tty_driver->driver_name	= "ttyNMI";
 	kgdb_nmi_tty_driver->name		= "ttyNMI";
 	kgdb_nmi_tty_driver->num		= 1;
 	kgdb_nmi_tty_driver->type		= TTY_DRIVER_TYPE_SERIAL;
 	kgdb_nmi_tty_driver->subtype		= SERIAL_TYPE_NORMAL;
-	kgdb_nmi_tty_driver->flags		= TTY_DRIVER_REAL_RAW;
 	kgdb_nmi_tty_driver->init_termios	= tty_std_termios;
 	tty_termios_encode_baud_rate(&kgdb_nmi_tty_driver->init_termios,
 				     KGDB_NMI_BAUD, KGDB_NMI_BAUD);
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 69092deba11f..b03a883a21c5 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2522,9 +2522,12 @@ int uart_register_driver(struct uart_driver *drv)
 	if (!drv->state)
 		goto out;
 
-	normal = alloc_tty_driver(drv->nr);
-	if (!normal)
+	normal = tty_alloc_driver(drv->nr, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(normal)) {
+		retval = PTR_ERR(normal);
 		goto out_kfree;
+	}
 
 	drv->tty_driver = normal;
 
@@ -2537,7 +2540,6 @@ int uart_register_driver(struct uart_driver *drv)
 	normal->init_termios	= tty_std_termios;
 	normal->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
 	normal->init_termios.c_ispeed = normal->init_termios.c_ospeed = 9600;
-	normal->flags		= TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 	normal->driver_state    = drv;
 	tty_set_operations(normal, &uart_ops);
 
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 5bb928b7873e..525f3a568c32 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -3689,10 +3689,11 @@ static int __init slgt_init(void)
 
 	printk(KERN_INFO "%s\n", driver_name);
 
-	serial_driver = alloc_tty_driver(MAX_DEVICES);
-	if (!serial_driver) {
+	serial_driver = tty_alloc_driver(MAX_DEVICES, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(serial_driver)) {
 		printk("%s can't allocate tty driver\n", driver_name);
-		return -ENOMEM;
+		return PTR_ERR(serial_driver);
 	}
 
 	/* Initialize the tty_driver structure */
@@ -3708,7 +3709,6 @@ static int __init slgt_init(void)
 		B9600 | CS8 | CREAD | HUPCL | CLOCAL;
 	serial_driver->init_termios.c_ispeed = 9600;
 	serial_driver->init_termios.c_ospeed = 9600;
-	serial_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 	tty_set_operations(serial_driver, &ops);
 	if ((rc = tty_register_driver(serial_driver)) < 0) {
 		DBGERR(("%s can't register serial driver\n", driver_name));
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index ef981d3b7bb4..744caa327d8c 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -3559,8 +3559,9 @@ int __init vty_init(const struct file_operations *console_fops)
 
 	vcs_init();
 
-	console_driver = alloc_tty_driver(MAX_NR_CONSOLES);
-	if (!console_driver)
+	console_driver = tty_alloc_driver(MAX_NR_CONSOLES, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_RESET_TERMIOS);
+	if (IS_ERR(console_driver))
 		panic("Couldn't allocate console driver\n");
 
 	console_driver->name = "tty";
@@ -3571,7 +3572,6 @@ int __init vty_init(const struct file_operations *console_fops)
 	console_driver->init_termios = tty_std_termios;
 	if (default_utf8)
 		console_driver->init_termios.c_iflag |= IUTF8;
-	console_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
 	tty_set_operations(console_driver, &con_ops);
 	if (tty_register_driver(console_driver))
 		panic("Couldn't register console driver\n");
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 4895325b16a4..c19b59583d9f 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -2027,16 +2027,16 @@ static const struct tty_operations acm_ops = {
 static int __init acm_init(void)
 {
 	int retval;
-	acm_tty_driver = alloc_tty_driver(ACM_TTY_MINORS);
-	if (!acm_tty_driver)
-		return -ENOMEM;
+	acm_tty_driver = tty_alloc_driver(ACM_TTY_MINORS, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(acm_tty_driver))
+		return PTR_ERR(acm_tty_driver);
 	acm_tty_driver->driver_name = "acm",
 	acm_tty_driver->name = "ttyACM",
 	acm_tty_driver->major = ACM_TTY_MAJOR,
 	acm_tty_driver->minor_start = 0,
 	acm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL,
 	acm_tty_driver->subtype = SERIAL_TYPE_NORMAL,
-	acm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 	acm_tty_driver->init_termios = tty_std_termios;
 	acm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD |
 								HUPCL | CLOCAL;
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index c99917a07a96..74289f68a2ab 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -1449,9 +1449,10 @@ static int userial_init(void)
 	unsigned			i;
 	int				status;
 
-	driver = alloc_tty_driver(MAX_U_SERIAL_PORTS);
-	if (!driver)
-		return -ENOMEM;
+	driver = tty_alloc_driver(MAX_U_SERIAL_PORTS, TTY_DRIVER_REAL_RAW |
+			TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(driver))
+		return PTR_ERR(driver);
 
 	driver->driver_name = "g_serial";
 	driver->name = "ttyGS";
@@ -1459,7 +1460,6 @@ static int userial_init(void)
 
 	driver->type = TTY_DRIVER_TYPE_SERIAL;
 	driver->subtype = SERIAL_TYPE_NORMAL;
-	driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 	driver->init_termios = tty_std_termios;
 
 	/* 9600-8-N-1 ... matches defaults expected by "usbser.sys" on
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index eeb441c77207..2f7855da645f 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1319,9 +1319,10 @@ static int __init usb_serial_init(void)
 {
 	int result;
 
-	usb_serial_tty_driver = alloc_tty_driver(USB_SERIAL_TTY_MINORS);
-	if (!usb_serial_tty_driver)
-		return -ENOMEM;
+	usb_serial_tty_driver = tty_alloc_driver(USB_SERIAL_TTY_MINORS,
+			TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(usb_serial_tty_driver))
+		return PTR_ERR(usb_serial_tty_driver);
 
 	/* Initialize our global data */
 	result = bus_register(&usb_serial_bus_type);
@@ -1336,8 +1337,6 @@ static int __init usb_serial_init(void)
 	usb_serial_tty_driver->minor_start = 0;
 	usb_serial_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
 	usb_serial_tty_driver->subtype = SERIAL_TYPE_NORMAL;
-	usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW |
-						TTY_DRIVER_DYNAMIC_DEV;
 	usb_serial_tty_driver->init_termios = tty_std_termios;
 	usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD
 							| HUPCL | CLOCAL;
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 4e095746e002..8ec0600cd927 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -1127,9 +1127,10 @@ int __init rfcomm_init_ttys(void)
 {
 	int error;
 
-	rfcomm_tty_driver = alloc_tty_driver(RFCOMM_TTY_PORTS);
-	if (!rfcomm_tty_driver)
-		return -ENOMEM;
+	rfcomm_tty_driver = tty_alloc_driver(RFCOMM_TTY_PORTS,
+			TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV);
+	if (IS_ERR(rfcomm_tty_driver))
+		return PTR_ERR(rfcomm_tty_driver);
 
 	rfcomm_tty_driver->driver_name	= "rfcomm";
 	rfcomm_tty_driver->name		= "rfcomm";
@@ -1137,7 +1138,6 @@ int __init rfcomm_init_ttys(void)
 	rfcomm_tty_driver->minor_start	= RFCOMM_TTY_MINOR;
 	rfcomm_tty_driver->type		= TTY_DRIVER_TYPE_SERIAL;
 	rfcomm_tty_driver->subtype	= SERIAL_TYPE_NORMAL;
-	rfcomm_tty_driver->flags	= TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 	rfcomm_tty_driver->init_termios	= tty_std_termios;
 	rfcomm_tty_driver->init_termios.c_cflag	= B9600 | CS8 | CREAD | HUPCL;
 	rfcomm_tty_driver->init_termios.c_lflag &= ~ICANON;
-- 
2.32.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 5/8] tty: drop alloc_tty_driver
  2021-07-23  7:43 [PATCH 0/8] Get rid of old tty_driver functions Jiri Slaby
                   ` (3 preceding siblings ...)
  2021-07-23  7:43 ` [PATCH 4/8] tty: stop using alloc_tty_driver Jiri Slaby
@ 2021-07-23  7:43 ` Jiri Slaby
  2021-07-23  7:43 ` [PATCH 6/8] tty: make tty_set_operations an inline Jiri Slaby
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 22+ messages in thread
From: Jiri Slaby @ 2021-07-23  7:43 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Noone uses this deprecated function now. So we can remove it.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 include/linux/tty_driver.h | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index a798e7f8890a..c7746dee58a6 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -340,18 +340,6 @@ extern void tty_driver_kref_put(struct tty_driver *driver);
 #define tty_alloc_driver(lines, flags) \
 		__tty_alloc_driver(lines, THIS_MODULE, flags)
 
-/*
- * DEPRECATED Do not use this in new code, use tty_alloc_driver instead.
- * (And change the return value checks.)
- */
-static inline struct tty_driver *alloc_tty_driver(unsigned int lines)
-{
-	struct tty_driver *ret = tty_alloc_driver(lines, 0);
-	if (IS_ERR(ret))
-		return NULL;
-	return ret;
-}
-
 static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
 {
 	kref_get(&d->kref);
-- 
2.32.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 6/8] tty: make tty_set_operations an inline
  2021-07-23  7:43 [PATCH 0/8] Get rid of old tty_driver functions Jiri Slaby
                   ` (4 preceding siblings ...)
  2021-07-23  7:43 ` [PATCH 5/8] tty: drop alloc_tty_driver Jiri Slaby
@ 2021-07-23  7:43 ` Jiri Slaby
  2021-07-23  7:43 ` [PATCH 7/8] tty: drop put_tty_driver Jiri Slaby
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 22+ messages in thread
From: Jiri Slaby @ 2021-07-23  7:43 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

Since commit f34d7a5b7010 (tty: The big operations rework) in 2008,
tty_set_operations() is a simple one-line assignment. There is no reason
for this to be an exported function, hence move it to a header and make
an inline from that.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/tty_io.c       | 7 -------
 include/linux/tty_driver.h | 8 ++++++--
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 26debec26b4e..16e3fce6f88d 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3438,13 +3438,6 @@ void tty_driver_kref_put(struct tty_driver *driver)
 }
 EXPORT_SYMBOL(tty_driver_kref_put);
 
-void tty_set_operations(struct tty_driver *driver,
-			const struct tty_operations *op)
-{
-	driver->ops = op;
-};
-EXPORT_SYMBOL(tty_set_operations);
-
 void put_tty_driver(struct tty_driver *d)
 {
 	tty_driver_kref_put(d);
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index c7746dee58a6..6092ce9180aa 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -330,8 +330,6 @@ extern struct list_head tty_drivers;
 extern struct tty_driver *__tty_alloc_driver(unsigned int lines,
 		struct module *owner, unsigned long flags);
 extern void put_tty_driver(struct tty_driver *driver);
-extern void tty_set_operations(struct tty_driver *driver,
-			const struct tty_operations *op);
 extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
 
 extern void tty_driver_kref_put(struct tty_driver *driver);
@@ -346,6 +344,12 @@ static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
 	return d;
 }
 
+static inline void tty_set_operations(struct tty_driver *driver,
+		const struct tty_operations *op)
+{
+	driver->ops = op;
+}
+
 /* tty driver magic number */
 #define TTY_DRIVER_MAGIC		0x5402
 
-- 
2.32.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 7/8] tty: drop put_tty_driver
  2021-07-23  7:43 [PATCH 0/8] Get rid of old tty_driver functions Jiri Slaby
                   ` (5 preceding siblings ...)
  2021-07-23  7:43 ` [PATCH 6/8] tty: make tty_set_operations an inline Jiri Slaby
@ 2021-07-23  7:43 ` Jiri Slaby
  2021-07-23  7:49   ` Samuel Iglesias Gonsálvez
                     ` (4 more replies)
  2021-07-23  7:43 ` [PATCH 8/8] tty: pdc_cons, free tty_driver upon failure Jiri Slaby
  2021-07-27 10:18 ` [PATCH 0/8] Get rid of old tty_driver functions Greg KH
  8 siblings, 5 replies; 22+ messages in thread
From: Jiri Slaby @ 2021-07-23  7:43 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Geert Uytterhoeven, Jeff Dike,
	Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
	Arnd Bergmann, Samuel Iglesias Gonsalvez, Jens Taprogge,
	Karsten Keil, Scott Branden, Ulf Hansson, David S. Miller,
	Jakub Kicinski, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, David Lin, Johan Hovold, Alex Elder,
	Jiri Slaby, Laurentiu Tudor, Jiri Kosina, David Sterba,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Oliver Neukum, Felipe Balbi, Mathias Nyman,
	Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz

put_tty_driver() is an alias for tty_driver_kref_put(). There is no need
for two exported identical functions, therefore switch all users of
old put_tty_driver() to new tty_driver_kref_put() and remove the former
for good.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Cc: Jens Taprogge <jens.taprogge@taprogge.org>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: Scott Branden <scott.branden@broadcom.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: David Sterba <dsterba@suse.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
---
 arch/alpha/kernel/srmcons.c            | 2 +-
 arch/m68k/emu/nfcon.c                  | 4 ++--
 arch/um/drivers/line.c                 | 2 +-
 arch/xtensa/platforms/iss/console.c    | 2 +-
 drivers/char/pcmcia/synclink_cs.c      | 4 ++--
 drivers/char/ttyprintk.c               | 4 ++--
 drivers/ipack/devices/ipoctal.c        | 4 ++--
 drivers/isdn/capi/capi.c               | 4 ++--
 drivers/misc/bcm-vk/bcm_vk_tty.c       | 8 ++++----
 drivers/mmc/core/sdio_uart.c           | 4 ++--
 drivers/net/usb/hso.c                  | 4 ++--
 drivers/s390/char/con3215.c            | 4 ++--
 drivers/s390/char/sclp_tty.c           | 8 ++++----
 drivers/s390/char/sclp_vt220.c         | 2 +-
 drivers/s390/char/tty3270.c            | 4 ++--
 drivers/staging/fwserial/fwserial.c    | 8 ++++----
 drivers/staging/gdm724x/gdm_tty.c      | 4 ++--
 drivers/staging/greybus/uart.c         | 4 ++--
 drivers/tty/amiserial.c                | 8 ++++----
 drivers/tty/ehv_bytechan.c             | 6 +++---
 drivers/tty/goldfish.c                 | 4 ++--
 drivers/tty/hvc/hvc_console.c          | 2 +-
 drivers/tty/hvc/hvcs.c                 | 4 ++--
 drivers/tty/ipwireless/tty.c           | 4 ++--
 drivers/tty/mips_ejtag_fdc.c           | 2 +-
 drivers/tty/moxa.c                     | 4 ++--
 drivers/tty/mxser.c                    | 4 ++--
 drivers/tty/n_gsm.c                    | 4 ++--
 drivers/tty/nozomi.c                   | 4 ++--
 drivers/tty/serial/kgdb_nmi.c          | 4 ++--
 drivers/tty/serial/serial_core.c       | 4 ++--
 drivers/tty/synclink_gt.c              | 4 ++--
 drivers/tty/tty_io.c                   | 6 ------
 drivers/tty/ttynull.c                  | 4 ++--
 drivers/tty/vcc.c                      | 4 ++--
 drivers/usb/class/cdc-acm.c            | 6 +++---
 drivers/usb/gadget/function/u_serial.c | 4 ++--
 drivers/usb/host/xhci-dbgtty.c         | 4 ++--
 drivers/usb/serial/usb-serial.c        | 4 ++--
 include/linux/tty_driver.h             | 1 -
 net/bluetooth/rfcomm/tty.c             | 4 ++--
 41 files changed, 82 insertions(+), 89 deletions(-)

diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
index d0a1b08d851d..90635ef5dafa 100644
--- a/arch/alpha/kernel/srmcons.c
+++ b/arch/alpha/kernel/srmcons.c
@@ -221,7 +221,7 @@ srmcons_init(void)
 		tty_port_link_device(&srmcons_singleton.port, driver, 0);
 		err = tty_register_driver(driver);
 		if (err) {
-			put_tty_driver(driver);
+			tty_driver_kref_put(driver);
 			tty_port_destroy(&srmcons_singleton.port);
 			return err;
 		}
diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c
index b3b64d03bad6..557d60867f98 100644
--- a/arch/m68k/emu/nfcon.c
+++ b/arch/m68k/emu/nfcon.c
@@ -144,7 +144,7 @@ static int __init nfcon_init(void)
 	res = tty_register_driver(driver);
 	if (res) {
 		pr_err("failed to register nfcon tty driver\n");
-		put_tty_driver(driver);
+		tty_driver_kref_put(driver);
 		tty_port_destroy(&nfcon_tty_port);
 		return res;
 	}
@@ -161,7 +161,7 @@ static void __exit nfcon_exit(void)
 {
 	unregister_console(&nf_console);
 	tty_unregister_driver(nfcon_tty_driver);
-	put_tty_driver(nfcon_tty_driver);
+	tty_driver_kref_put(nfcon_tty_driver);
 	tty_port_destroy(&nfcon_tty_port);
 }
 
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 0d8f4ee6335d..8febf95da96e 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -568,7 +568,7 @@ int register_lines(struct line_driver *line_driver,
 	if (err) {
 		printk(KERN_ERR "register_lines : can't register %s driver\n",
 		       line_driver->name);
-		put_tty_driver(driver);
+		tty_driver_kref_put(driver);
 		for (i = 0; i < nlines; i++)
 			tty_port_destroy(&lines[i].port);
 		return err;
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 0b8a0565cdfd..81f988914d9a 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -178,7 +178,7 @@ static int __init rs_init(void)
 static __exit void rs_exit(void)
 {
 	tty_unregister_driver(serial_driver);
-	put_tty_driver(serial_driver);
+	tty_driver_kref_put(serial_driver);
 	tty_port_destroy(&serial_port);
 }
 
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 6eaefea0520e..fd78d5856841 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -2841,7 +2841,7 @@ static int __init synclink_cs_init(void)
 err_unreg_tty:
 	tty_unregister_driver(serial_driver);
 err_put_tty:
-	put_tty_driver(serial_driver);
+	tty_driver_kref_put(serial_driver);
 err:
 	return rc;
 }
@@ -2850,7 +2850,7 @@ static void __exit synclink_cs_exit(void)
 {
 	pcmcia_unregister_driver(&mgslpc_driver);
 	tty_unregister_driver(serial_driver);
-	put_tty_driver(serial_driver);
+	tty_driver_kref_put(serial_driver);
 }
 
 module_init(synclink_cs_init);
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
index 230b2c9b3e3c..adf941c47506 100644
--- a/drivers/char/ttyprintk.c
+++ b/drivers/char/ttyprintk.c
@@ -198,7 +198,7 @@ static int __init ttyprintk_init(void)
 	return 0;
 
 error:
-	put_tty_driver(ttyprintk_driver);
+	tty_driver_kref_put(ttyprintk_driver);
 	tty_port_destroy(&tpk_port.port);
 	return ret;
 }
@@ -206,7 +206,7 @@ static int __init ttyprintk_init(void)
 static void __exit ttyprintk_exit(void)
 {
 	tty_unregister_driver(ttyprintk_driver);
-	put_tty_driver(ttyprintk_driver);
+	tty_driver_kref_put(ttyprintk_driver);
 	tty_port_destroy(&tpk_port.port);
 }
 
diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c
index be6d11f46e62..c14e65a5d38f 100644
--- a/drivers/ipack/devices/ipoctal.c
+++ b/drivers/ipack/devices/ipoctal.c
@@ -371,7 +371,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
 	res = tty_register_driver(tty);
 	if (res) {
 		dev_err(&ipoctal->dev->dev, "Can't register tty driver.\n");
-		put_tty_driver(tty);
+		tty_driver_kref_put(tty);
 		return res;
 	}
 
@@ -696,7 +696,7 @@ static void __ipoctal_remove(struct ipoctal *ipoctal)
 	}
 
 	tty_unregister_driver(ipoctal->tty_drv);
-	put_tty_driver(ipoctal->tty_drv);
+	tty_driver_kref_put(ipoctal->tty_drv);
 	kfree(ipoctal);
 }
 
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 32abf4d15450..0f00be62438d 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1290,7 +1290,7 @@ static int __init capinc_tty_init(void)
 
 	err = tty_register_driver(drv);
 	if (err) {
-		put_tty_driver(drv);
+		tty_driver_kref_put(drv);
 		kfree(capiminors);
 		printk(KERN_ERR "Couldn't register capi_nc driver\n");
 		return err;
@@ -1302,7 +1302,7 @@ static int __init capinc_tty_init(void)
 static void __exit capinc_tty_exit(void)
 {
 	tty_unregister_driver(capinc_tty_driver);
-	put_tty_driver(capinc_tty_driver);
+	tty_driver_kref_put(capinc_tty_driver);
 	kfree(capiminors);
 }
 
diff --git a/drivers/misc/bcm-vk/bcm_vk_tty.c b/drivers/misc/bcm-vk/bcm_vk_tty.c
index dae9eeed84a2..1b6076a89ca6 100644
--- a/drivers/misc/bcm-vk/bcm_vk_tty.c
+++ b/drivers/misc/bcm-vk/bcm_vk_tty.c
@@ -249,7 +249,7 @@ int bcm_vk_tty_init(struct bcm_vk *vk, char *name)
 	tty_drv->name = kstrdup(name, GFP_KERNEL);
 	if (!tty_drv->name) {
 		err = -ENOMEM;
-		goto err_put_tty_driver;
+		goto err_tty_driver_kref_put;
 	}
 	tty_drv->type = TTY_DRIVER_TYPE_SERIAL;
 	tty_drv->subtype = SERIAL_TYPE_NORMAL;
@@ -295,8 +295,8 @@ int bcm_vk_tty_init(struct bcm_vk *vk, char *name)
 	kfree(tty_drv->name);
 	tty_drv->name = NULL;
 
-err_put_tty_driver:
-	put_tty_driver(tty_drv);
+err_tty_driver_kref_put:
+	tty_driver_kref_put(tty_drv);
 
 	return err;
 }
@@ -317,7 +317,7 @@ void bcm_vk_tty_exit(struct bcm_vk *vk)
 	kfree(vk->tty_drv->name);
 	vk->tty_drv->name = NULL;
 
-	put_tty_driver(vk->tty_drv);
+	tty_driver_kref_put(vk->tty_drv);
 }
 
 void bcm_vk_tty_terminate_tty_user(struct bcm_vk *vk)
diff --git a/drivers/mmc/core/sdio_uart.c b/drivers/mmc/core/sdio_uart.c
index 04a57832e486..04c0823e0359 100644
--- a/drivers/mmc/core/sdio_uart.c
+++ b/drivers/mmc/core/sdio_uart.c
@@ -1165,7 +1165,7 @@ static int __init sdio_uart_init(void)
 err2:
 	tty_unregister_driver(tty_drv);
 err1:
-	put_tty_driver(tty_drv);
+	tty_driver_kref_put(tty_drv);
 	return ret;
 }
 
@@ -1173,7 +1173,7 @@ static void __exit sdio_uart_exit(void)
 {
 	sdio_unregister_driver(&sdio_uart_driver);
 	tty_unregister_driver(sdio_uart_tty_driver);
-	put_tty_driver(sdio_uart_tty_driver);
+	tty_driver_kref_put(sdio_uart_tty_driver);
 }
 
 module_init(sdio_uart_init);
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 29df4b34e002..d4cc5bc425c3 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -3282,7 +3282,7 @@ static int __init hso_init(void)
 err_unreg_tty:
 	tty_unregister_driver(tty_drv);
 err_free_tty:
-	put_tty_driver(tty_drv);
+	tty_driver_kref_put(tty_drv);
 	return result;
 }
 
@@ -3293,7 +3293,7 @@ static void __exit hso_exit(void)
 	tty_unregister_driver(tty_drv);
 	/* deregister the usb driver */
 	usb_deregister(&hso_driver);
-	put_tty_driver(tty_drv);
+	tty_driver_kref_put(tty_drv);
 }
 
 /* Module definitions */
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 3818a89aef5c..f356607835d8 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -1082,7 +1082,7 @@ static int __init tty3215_init(void)
 
 	ret = ccw_driver_register(&raw3215_ccw_driver);
 	if (ret) {
-		put_tty_driver(driver);
+		tty_driver_kref_put(driver);
 		return ret;
 	}
 	/*
@@ -1104,7 +1104,7 @@ static int __init tty3215_init(void)
 	tty_set_operations(driver, &tty3215_ops);
 	ret = tty_register_driver(driver);
 	if (ret) {
-		put_tty_driver(driver);
+		tty_driver_kref_put(driver);
 		return ret;
 	}
 	tty3215_driver = driver;
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index 48790f8fb3b1..971fbb52740b 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -509,14 +509,14 @@ sclp_tty_init(void)
 
 	rc = sclp_rw_init();
 	if (rc) {
-		put_tty_driver(driver);
+		tty_driver_kref_put(driver);
 		return rc;
 	}
 	/* Allocate pages for output buffering */
 	for (i = 0; i < MAX_KMEM_PAGES; i++) {
 		page = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
 		if (page == NULL) {
-			put_tty_driver(driver);
+			tty_driver_kref_put(driver);
 			return -ENOMEM;
 		}
 		list_add_tail((struct list_head *) page, &sclp_tty_pages);
@@ -532,7 +532,7 @@ sclp_tty_init(void)
 
 	rc = sclp_register(&sclp_input_event);
 	if (rc) {
-		put_tty_driver(driver);
+		tty_driver_kref_put(driver);
 		return rc;
 	}
 
@@ -552,7 +552,7 @@ sclp_tty_init(void)
 	tty_port_link_device(&sclp_port, driver, 0);
 	rc = tty_register_driver(driver);
 	if (rc) {
-		put_tty_driver(driver);
+		tty_driver_kref_put(driver);
 		tty_port_destroy(&sclp_port);
 		return rc;
 	}
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index c6a7ea32aa5c..29a6a0099f83 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -763,7 +763,7 @@ static int __init sclp_vt220_tty_init(void)
 out_init:
 	__sclp_vt220_cleanup();
 out_driver:
-	put_tty_driver(driver);
+	tty_driver_kref_put(driver);
 	return rc;
 }
 __initcall(sclp_vt220_tty_init);
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
index adc33846bf8e..5c83f71c1d0e 100644
--- a/drivers/s390/char/tty3270.c
+++ b/drivers/s390/char/tty3270.c
@@ -1935,7 +1935,7 @@ static int __init tty3270_init(void)
 	tty_set_operations(driver, &tty3270_ops);
 	ret = tty_register_driver(driver);
 	if (ret) {
-		put_tty_driver(driver);
+		tty_driver_kref_put(driver);
 		return ret;
 	}
 	tty3270_driver = driver;
@@ -1952,7 +1952,7 @@ tty3270_exit(void)
 	driver = tty3270_driver;
 	tty3270_driver = NULL;
 	tty_unregister_driver(driver);
-	put_tty_driver(driver);
+	tty_driver_kref_put(driver);
 	tty3270_del_views();
 }
 
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
index 38a280e876c2..e8fa7f53cd5e 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -2852,11 +2852,11 @@ static int __init fwserial_init(void)
 		tty_unregister_driver(fwloop_driver);
 put_loop:
 	if (create_loop_dev)
-		put_tty_driver(fwloop_driver);
+		tty_driver_kref_put(fwloop_driver);
 unregister_driver:
 	tty_unregister_driver(fwtty_driver);
 put_tty:
-	put_tty_driver(fwtty_driver);
+	tty_driver_kref_put(fwtty_driver);
 remove_debugfs:
 	debugfs_remove_recursive(fwserial_debugfs);
 
@@ -2871,10 +2871,10 @@ static void __exit fwserial_exit(void)
 	kmem_cache_destroy(fwtty_txn_cache);
 	if (create_loop_dev) {
 		tty_unregister_driver(fwloop_driver);
-		put_tty_driver(fwloop_driver);
+		tty_driver_kref_put(fwloop_driver);
 	}
 	tty_unregister_driver(fwtty_driver);
-	put_tty_driver(fwtty_driver);
+	tty_driver_kref_put(fwtty_driver);
 	debugfs_remove_recursive(fwserial_debugfs);
 }
 
diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
index 918575417264..04df6f9f5403 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -299,7 +299,7 @@ int register_lte_tty_driver(void)
 
 		ret = tty_register_driver(tty_driver);
 		if (ret) {
-			put_tty_driver(tty_driver);
+			tty_driver_kref_put(tty_driver);
 			return ret;
 		}
 
@@ -318,7 +318,7 @@ void unregister_lte_tty_driver(void)
 		tty_driver = gdm_driver[i];
 		if (tty_driver) {
 			tty_unregister_driver(tty_driver);
-			put_tty_driver(tty_driver);
+			tty_driver_kref_put(tty_driver);
 		}
 	}
 }
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 73f01ed1e5b7..e6d860a9678e 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -973,7 +973,7 @@ static int gb_tty_init(void)
 	return 0;
 
 fail_put_gb_tty:
-	put_tty_driver(gb_tty_driver);
+	tty_driver_kref_put(gb_tty_driver);
 fail_unregister_dev:
 	return retval;
 }
@@ -981,7 +981,7 @@ static int gb_tty_init(void)
 static void gb_tty_exit(void)
 {
 	tty_unregister_driver(gb_tty_driver);
-	put_tty_driver(gb_tty_driver);
+	tty_driver_kref_put(gb_tty_driver);
 	idr_destroy(&tty_minors);
 }
 
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 50f1a54ef35a..1e60dbef676c 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1519,7 +1519,7 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
 
 	error = tty_register_driver(driver);
 	if (error)
-		goto fail_put_tty_driver;
+		goto fail_tty_driver_kref_put;
 
 	printk(KERN_INFO "ttyS0 is the amiga builtin serial port\n");
 
@@ -1566,9 +1566,9 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
 	free_irq(IRQ_AMIGA_TBE, state);
 fail_unregister:
 	tty_unregister_driver(driver);
-fail_put_tty_driver:
+fail_tty_driver_kref_put:
 	tty_port_destroy(&state->tport);
-	put_tty_driver(driver);
+	tty_driver_kref_put(driver);
 	return error;
 }
 
@@ -1577,7 +1577,7 @@ static int __exit amiga_serial_remove(struct platform_device *pdev)
 	struct serial_state *state = platform_get_drvdata(pdev);
 
 	tty_unregister_driver(serial_driver);
-	put_tty_driver(serial_driver);
+	tty_driver_kref_put(serial_driver);
 	tty_port_destroy(&state->tport);
 
 	free_irq(IRQ_AMIGA_TBE, state);
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c
index f580a5de3c98..19d32cb6af84 100644
--- a/drivers/tty/ehv_bytechan.c
+++ b/drivers/tty/ehv_bytechan.c
@@ -791,7 +791,7 @@ static int __init ehv_bc_init(void)
 	ret = tty_register_driver(driver);
 	if (ret) {
 		pr_err("ehv-bc: could not register tty driver (ret=%i)\n", ret);
-		goto err_put_tty_driver;
+		goto err_tty_driver_kref_put;
 	}
 
 	ehv_bc_driver = driver;
@@ -808,8 +808,8 @@ static int __init ehv_bc_init(void)
 err_deregister_tty_driver:
 	ehv_bc_driver = NULL;
 	tty_unregister_driver(driver);
-err_put_tty_driver:
-	put_tty_driver(driver);
+err_tty_driver_kref_put:
+	tty_driver_kref_put(driver);
 err_free_bcs:
 	kfree(bcs);
 
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index 853083fcebb8..d24af649a8bb 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -274,7 +274,7 @@ static int goldfish_tty_create_driver(void)
 	return 0;
 
 err_tty_register_driver_failed:
-	put_tty_driver(tty);
+	tty_driver_kref_put(tty);
 err_tty_alloc_driver_failed:
 	kfree(goldfish_ttys);
 	goldfish_ttys = NULL;
@@ -285,7 +285,7 @@ static int goldfish_tty_create_driver(void)
 static void goldfish_tty_delete_driver(void)
 {
 	tty_unregister_driver(goldfish_tty_driver);
-	put_tty_driver(goldfish_tty_driver);
+	tty_driver_kref_put(goldfish_tty_driver);
 	goldfish_tty_driver = NULL;
 	kfree(goldfish_ttys);
 	goldfish_ttys = NULL;
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 9215dd4bd9f0..7b30d5a05e2f 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -1063,7 +1063,7 @@ static int hvc_init(void)
 	kthread_stop(hvc_task);
 	hvc_task = NULL;
 put_tty:
-	put_tty_driver(drv);
+	tty_driver_kref_put(drv);
 out:
 	return err;
 }
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index 23aebc964201..245da1dfd818 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -1509,7 +1509,7 @@ static int hvcs_initialize(void)
 register_fail:
 	hvcs_free_index_list();
 index_fail:
-	put_tty_driver(hvcs_tty_driver);
+	tty_driver_kref_put(hvcs_tty_driver);
 	hvcs_tty_driver = NULL;
 	mutex_unlock(&hvcs_init_mutex);
 	return rc;
@@ -1562,7 +1562,7 @@ static void __exit hvcs_module_exit(void)
 
 	hvcs_free_index_list();
 
-	put_tty_driver(hvcs_tty_driver);
+	tty_driver_kref_put(hvcs_tty_driver);
 
 	printk(KERN_INFO "HVCS: driver module removed.\n");
 }
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index d24404c222e0..9edd5ae17580 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -585,7 +585,7 @@ int ipwireless_tty_init(void)
 	if (result) {
 		printk(KERN_ERR IPWIRELESS_PCCARD_NAME
 		       ": failed to register tty driver\n");
-		put_tty_driver(ipw_tty_driver);
+		tty_driver_kref_put(ipw_tty_driver);
 		return result;
 	}
 
@@ -595,7 +595,7 @@ int ipwireless_tty_init(void)
 void ipwireless_tty_release(void)
 {
 	tty_unregister_driver(ipw_tty_driver);
-	put_tty_driver(ipw_tty_driver);
+	tty_driver_kref_put(ipw_tty_driver);
 }
 
 int ipwireless_tty_is_modem(struct ipw_tty *tty)
diff --git a/drivers/tty/mips_ejtag_fdc.c b/drivers/tty/mips_ejtag_fdc.c
index 3b5915b94fac..02c10a968de1 100644
--- a/drivers/tty/mips_ejtag_fdc.c
+++ b/drivers/tty/mips_ejtag_fdc.c
@@ -1042,7 +1042,7 @@ static int mips_ejtag_fdc_tty_probe(struct mips_cdmm_device *dev)
 		dport = &priv->ports[nport];
 		tty_port_destroy(&dport->port);
 	}
-	put_tty_driver(priv->driver);
+	tty_driver_kref_put(priv->driver);
 	return ret;
 }
 
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index 64b18177c790..776f78de0f82 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -1053,7 +1053,7 @@ static int __init moxa_init(void)
 
 	if (tty_register_driver(moxaDriver)) {
 		printk(KERN_ERR "can't register MOXA Smartio tty driver!\n");
-		put_tty_driver(moxaDriver);
+		tty_driver_kref_put(moxaDriver);
 		return -1;
 	}
 
@@ -1119,7 +1119,7 @@ static void __exit moxa_exit(void)
 	del_timer_sync(&moxaTimer);
 
 	tty_unregister_driver(moxaDriver);
-	put_tty_driver(moxaDriver);
+	tty_driver_kref_put(moxaDriver);
 }
 
 module_init(moxa_init);
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 650fc6fac88e..335e4e50d679 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -2008,7 +2008,7 @@ static int __init mxser_module_init(void)
 err_unr:
 	tty_unregister_driver(mxvar_sdriver);
 err_put:
-	put_tty_driver(mxvar_sdriver);
+	tty_driver_kref_put(mxvar_sdriver);
 	return retval;
 }
 
@@ -2016,7 +2016,7 @@ static void __exit mxser_module_exit(void)
 {
 	pci_unregister_driver(&mxser_driver);
 	tty_unregister_driver(mxvar_sdriver);
-	put_tty_driver(mxvar_sdriver);
+	tty_driver_kref_put(mxvar_sdriver);
 }
 
 module_init(mxser_module_init);
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 0308669c21c6..1d92d2a84889 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -3279,7 +3279,7 @@ static int __init gsm_init(void)
 			gsm_tty_driver->major, gsm_tty_driver->minor_start);
 	return 0;
 err_put_driver:
-	put_tty_driver(gsm_tty_driver);
+	tty_driver_kref_put(gsm_tty_driver);
 err_unreg_ldisc:
 	tty_unregister_ldisc(&tty_ldisc_packet);
 	return status;
@@ -3289,7 +3289,7 @@ static void __exit gsm_exit(void)
 {
 	tty_unregister_ldisc(&tty_ldisc_packet);
 	tty_unregister_driver(gsm_tty_driver);
-	put_tty_driver(gsm_tty_driver);
+	tty_driver_kref_put(gsm_tty_driver);
 }
 
 module_init(gsm_init);
diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index f3eb0aaec79b..0454c78deee6 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -1857,7 +1857,7 @@ static __init int nozomi_init(void)
 unr_tty:
 	tty_unregister_driver(ntty_driver);
 free_tty:
-	put_tty_driver(ntty_driver);
+	tty_driver_kref_put(ntty_driver);
 	return ret;
 }
 
@@ -1865,7 +1865,7 @@ static __exit void nozomi_exit(void)
 {
 	pci_unregister_driver(&nozomi_driver);
 	tty_unregister_driver(ntty_driver);
-	put_tty_driver(ntty_driver);
+	tty_driver_kref_put(ntty_driver);
 }
 
 module_init(nozomi_init);
diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
index 9209573a7e37..55c3c9db7462 100644
--- a/drivers/tty/serial/kgdb_nmi.c
+++ b/drivers/tty/serial/kgdb_nmi.c
@@ -355,7 +355,7 @@ int kgdb_register_nmi_console(void)
 
 	return 0;
 err_drv_reg:
-	put_tty_driver(kgdb_nmi_tty_driver);
+	tty_driver_kref_put(kgdb_nmi_tty_driver);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(kgdb_register_nmi_console);
@@ -373,7 +373,7 @@ int kgdb_unregister_nmi_console(void)
 		return ret;
 
 	tty_unregister_driver(kgdb_nmi_tty_driver);
-	put_tty_driver(kgdb_nmi_tty_driver);
+	tty_driver_kref_put(kgdb_nmi_tty_driver);
 
 	return 0;
 }
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index b03a883a21c5..17a6c2f4d806 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2560,7 +2560,7 @@ int uart_register_driver(struct uart_driver *drv)
 
 	for (i = 0; i < drv->nr; i++)
 		tty_port_destroy(&drv->state[i].port);
-	put_tty_driver(normal);
+	tty_driver_kref_put(normal);
 out_kfree:
 	kfree(drv->state);
 out:
@@ -2582,7 +2582,7 @@ void uart_unregister_driver(struct uart_driver *drv)
 	unsigned int i;
 
 	tty_unregister_driver(p);
-	put_tty_driver(p);
+	tty_driver_kref_put(p);
 	for (i = 0; i < drv->nr; i++)
 		tty_port_destroy(&drv->state[i].port);
 	kfree(drv->state);
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 525f3a568c32..c89f7de38d12 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -3650,7 +3650,7 @@ static void slgt_cleanup(void)
 		for (info=slgt_device_list ; info != NULL ; info=info->next_device)
 			tty_unregister_device(serial_driver, info->line);
 		tty_unregister_driver(serial_driver);
-		put_tty_driver(serial_driver);
+		tty_driver_kref_put(serial_driver);
 	}
 
 	/* reset devices */
@@ -3712,7 +3712,7 @@ static int __init slgt_init(void)
 	tty_set_operations(serial_driver, &ops);
 	if ((rc = tty_register_driver(serial_driver)) < 0) {
 		DBGERR(("%s can't register serial driver\n", driver_name));
-		put_tty_driver(serial_driver);
+		tty_driver_kref_put(serial_driver);
 		serial_driver = NULL;
 		goto error;
 	}
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 16e3fce6f88d..e8532006e960 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3438,12 +3438,6 @@ void tty_driver_kref_put(struct tty_driver *driver)
 }
 EXPORT_SYMBOL(tty_driver_kref_put);
 
-void put_tty_driver(struct tty_driver *d)
-{
-	tty_driver_kref_put(d);
-}
-EXPORT_SYMBOL(put_tty_driver);
-
 /*
  * Called by a tty driver to register itself.
  */
diff --git a/drivers/tty/ttynull.c b/drivers/tty/ttynull.c
index af3311a24917..1d4438472442 100644
--- a/drivers/tty/ttynull.c
+++ b/drivers/tty/ttynull.c
@@ -84,7 +84,7 @@ static int __init ttynull_init(void)
 
 	ret = tty_register_driver(driver);
 	if (ret < 0) {
-		put_tty_driver(driver);
+		tty_driver_kref_put(driver);
 		tty_port_destroy(&ttynull_port);
 		return ret;
 	}
@@ -99,7 +99,7 @@ static void __exit ttynull_exit(void)
 {
 	unregister_console(&ttynull_console);
 	tty_unregister_driver(ttynull_driver);
-	put_tty_driver(ttynull_driver);
+	tty_driver_kref_put(ttynull_driver);
 	tty_port_destroy(&ttynull_port);
 }
 
diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c
index d06bcc3b4c07..e11383ae1e7e 100644
--- a/drivers/tty/vcc.c
+++ b/drivers/tty/vcc.c
@@ -1028,7 +1028,7 @@ static int vcc_tty_init(void)
 	rv = tty_register_driver(vcc_tty_driver);
 	if (rv) {
 		pr_err("VCC: TTY driver registration failed\n");
-		put_tty_driver(vcc_tty_driver);
+		tty_driver_kref_put(vcc_tty_driver);
 		vcc_tty_driver = NULL;
 		return rv;
 	}
@@ -1041,7 +1041,7 @@ static int vcc_tty_init(void)
 static void vcc_tty_exit(void)
 {
 	tty_unregister_driver(vcc_tty_driver);
-	put_tty_driver(vcc_tty_driver);
+	tty_driver_kref_put(vcc_tty_driver);
 	vccdbg("VCC: TTY driver unregistered\n");
 
 	vcc_tty_driver = NULL;
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index c19b59583d9f..8bbd8e29e60d 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -2044,14 +2044,14 @@ static int __init acm_init(void)
 
 	retval = tty_register_driver(acm_tty_driver);
 	if (retval) {
-		put_tty_driver(acm_tty_driver);
+		tty_driver_kref_put(acm_tty_driver);
 		return retval;
 	}
 
 	retval = usb_register(&acm_driver);
 	if (retval) {
 		tty_unregister_driver(acm_tty_driver);
-		put_tty_driver(acm_tty_driver);
+		tty_driver_kref_put(acm_tty_driver);
 		return retval;
 	}
 
@@ -2064,7 +2064,7 @@ static void __exit acm_exit(void)
 {
 	usb_deregister(&acm_driver);
 	tty_unregister_driver(acm_tty_driver);
-	put_tty_driver(acm_tty_driver);
+	tty_driver_kref_put(acm_tty_driver);
 	idr_destroy(&acm_minors);
 }
 
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 74289f68a2ab..72961c1beeef 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -1491,7 +1491,7 @@ static int userial_init(void)
 
 	return status;
 fail:
-	put_tty_driver(driver);
+	tty_driver_kref_put(driver);
 	return status;
 }
 module_init(userial_init);
@@ -1499,7 +1499,7 @@ module_init(userial_init);
 static void userial_cleanup(void)
 {
 	tty_unregister_driver(gs_tty_driver);
-	put_tty_driver(gs_tty_driver);
+	tty_driver_kref_put(gs_tty_driver);
 	gs_tty_driver = NULL;
 }
 module_exit(userial_cleanup);
diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
index bef104511352..6e784f2fc26d 100644
--- a/drivers/usb/host/xhci-dbgtty.c
+++ b/drivers/usb/host/xhci-dbgtty.c
@@ -541,7 +541,7 @@ static int dbc_tty_init(void)
 	ret = tty_register_driver(dbc_tty_driver);
 	if (ret) {
 		pr_err("Can't register dbc tty driver\n");
-		put_tty_driver(dbc_tty_driver);
+		tty_driver_kref_put(dbc_tty_driver);
 	}
 	return ret;
 }
@@ -550,7 +550,7 @@ static void dbc_tty_exit(void)
 {
 	if (dbc_tty_driver) {
 		tty_unregister_driver(dbc_tty_driver);
-		put_tty_driver(dbc_tty_driver);
+		tty_driver_kref_put(dbc_tty_driver);
 		dbc_tty_driver = NULL;
 	}
 }
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 2f7855da645f..090a78c948f2 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1366,7 +1366,7 @@ static int __init usb_serial_init(void)
 
 exit_bus:
 	pr_err("%s - returning with error %d\n", __func__, result);
-	put_tty_driver(usb_serial_tty_driver);
+	tty_driver_kref_put(usb_serial_tty_driver);
 	return result;
 }
 
@@ -1378,7 +1378,7 @@ static void __exit usb_serial_exit(void)
 	usb_serial_generic_deregister();
 
 	tty_unregister_driver(usb_serial_tty_driver);
-	put_tty_driver(usb_serial_tty_driver);
+	tty_driver_kref_put(usb_serial_tty_driver);
 	bus_unregister(&usb_serial_bus_type);
 	idr_destroy(&serial_minors);
 }
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 6092ce9180aa..c20431d8def8 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -329,7 +329,6 @@ extern struct list_head tty_drivers;
 
 extern struct tty_driver *__tty_alloc_driver(unsigned int lines,
 		struct module *owner, unsigned long flags);
-extern void put_tty_driver(struct tty_driver *driver);
 extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
 
 extern void tty_driver_kref_put(struct tty_driver *driver);
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 8ec0600cd927..ebd78fdbd6e8 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -1146,7 +1146,7 @@ int __init rfcomm_init_ttys(void)
 	error = tty_register_driver(rfcomm_tty_driver);
 	if (error) {
 		BT_ERR("Can't register RFCOMM TTY driver");
-		put_tty_driver(rfcomm_tty_driver);
+		tty_driver_kref_put(rfcomm_tty_driver);
 		return error;
 	}
 
@@ -1158,5 +1158,5 @@ int __init rfcomm_init_ttys(void)
 void rfcomm_cleanup_ttys(void)
 {
 	tty_unregister_driver(rfcomm_tty_driver);
-	put_tty_driver(rfcomm_tty_driver);
+	tty_driver_kref_put(rfcomm_tty_driver);
 }
-- 
2.32.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 8/8] tty: pdc_cons, free tty_driver upon failure
  2021-07-23  7:43 [PATCH 0/8] Get rid of old tty_driver functions Jiri Slaby
                   ` (6 preceding siblings ...)
  2021-07-23  7:43 ` [PATCH 7/8] tty: drop put_tty_driver Jiri Slaby
@ 2021-07-23  7:43 ` Jiri Slaby
  2021-07-27 10:18 ` [PATCH 0/8] Get rid of old tty_driver functions Greg KH
  8 siblings, 0 replies; 22+ messages in thread
From: Jiri Slaby @ 2021-07-23  7:43 UTC (permalink / raw)
  To: gregkh
  Cc: linux-serial, linux-kernel, Jiri Slaby, James E.J. Bottomley,
	Helge Deller, linux-parisc

pdc_console_tty_driver_init() does not free the allocated tty driver in
case tty_register_driver() fails. Add one tty_driver_kref_put() to the
error path.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: linux-parisc@vger.kernel.org
---
 arch/parisc/kernel/pdc_cons.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index 70c2a1648fc1..2661cdd256ae 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -181,6 +181,7 @@ static int __init pdc_console_tty_driver_init(void)
 	if (err) {
 		printk(KERN_ERR "Unable to register the PDC console TTY driver\n");
 		tty_port_destroy(&tty_port);
+		tty_driver_kref_put(driver);
 		return err;
 	}
 
-- 
2.32.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/8] tty: stop using alloc_tty_driver
  2021-07-23  7:43 ` [PATCH 4/8] tty: stop using alloc_tty_driver Jiri Slaby
@ 2021-07-23  7:49   ` Samuel Iglesias Gonsálvez
  2021-07-23  7:57   ` Christian Borntraeger
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 22+ messages in thread
From: Samuel Iglesias Gonsálvez @ 2021-07-23  7:49 UTC (permalink / raw)
  To: Jiri Slaby, gregkh
  Cc: linux-serial, linux-kernel, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, Geert Uytterhoeven, James E.J. Bottomley,
	Helge Deller, Jeff Dike, Richard Weinberger, Anton Ivanov,
	Chris Zankel, Max Filippov, Jens Taprogge, Karsten Keil,
	Ulf Hansson, David S. Miller, Jakub Kicinski, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger, Laurentiu Tudor,
	Jiri Kosina, David Sterba, Shawn Guo, Sascha Hauer,
	Oliver Neukum, Felipe Balbi, Johan Hovold, Marcel Holtmann,
	Johan Hedberg, Luiz Augusto von Dentz

[-- Attachment #1: Type: text/plain, Size: 4290 bytes --]

On Fri, 2021-07-23 at 09:43 +0200, Jiri Slaby wrote:
> alloc_tty_driver was deprecated by tty_alloc_driver in commit
> 7f0bc6a68ed9 (TTY: pass flags to alloc_tty_driver) in 2012.
> 
> I never got into eliminating alloc_tty_driver until now. So we still
> have two functions for allocating drivers which might be confusing.
> So
> get rid of alloc_tty_driver uses to eliminate it for good in the next
> patch.
> 
> Note we need to switch return value checking as tty_alloc_driver uses
> ERR_PTR. And flags are now a parameter of tty_alloc_driver.
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Richard Henderson <rth@twiddle.net>(odd fixer:ALPHA PORT)
> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> Cc: Matt Turner <mattst88@gmail.com>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: Helge Deller <deller@gmx.de>
> Cc: Jeff Dike <jdike@addtoit.com>
> Cc: Richard Weinberger <richard@nod.at>
> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> Cc: Chris Zankel <chris@zankel.net>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
> Cc: Jens Taprogge <jens.taprogge@taprogge.org>
> Cc: Karsten Keil <isdn@linux-pingi.de>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Cc: Jiri Kosina <jikos@kernel.org>
> Cc: David Sterba <dsterba@suse.com>
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Oliver Neukum <oneukum@suse.com>
> Cc: Felipe Balbi <balbi@kernel.org>
> Cc: Johan Hovold <johan@kernel.org>
> Cc: Marcel Holtmann <marcel@holtmann.org>
> Cc: Johan Hedberg <johan.hedberg@gmail.com>
> Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
> ---
>  arch/alpha/kernel/srmcons.c            |  6 +++---
>  arch/m68k/emu/nfcon.c                  |  7 +++----
>  arch/parisc/kernel/pdc_cons.c          |  9 ++++-----
>  arch/um/drivers/line.c                 | 11 ++++++-----
>  arch/xtensa/platforms/iss/console.c    |  7 +++----
>  drivers/ipack/devices/ipoctal.c        |  9 ++++-----
>  drivers/isdn/capi/capi.c               | 10 ++++------
>  drivers/mmc/core/sdio_uart.c           |  8 ++++----
>  drivers/net/usb/hso.c                  |  8 ++++----
>  drivers/s390/char/con3215.c            |  7 +++----
>  drivers/s390/char/sclp_tty.c           |  7 +++----
>  drivers/s390/char/sclp_vt220.c         |  7 +++----
>  drivers/staging/gdm724x/gdm_tty.c      |  9 ++++-----
>  drivers/tty/amiserial.c                |  7 +++----
>  drivers/tty/ehv_bytechan.c             |  8 ++++----
>  drivers/tty/goldfish.c                 | 14 +++++++-------
>  drivers/tty/hvc/hvc_console.c          |  8 ++++----
>  drivers/tty/hvc/hvcs.c                 |  8 ++++----
>  drivers/tty/hvc/hvsi.c                 |  7 +++----
>  drivers/tty/ipwireless/tty.c           |  8 ++++----
>  drivers/tty/mxser.c                    |  8 ++++----
>  drivers/tty/n_gsm.c                    |  9 ++++-----
>  drivers/tty/nozomi.c                   |  8 ++++----
>  drivers/tty/serial/kgdb_nmi.c          |  7 +++----
>  drivers/tty/serial/serial_core.c       |  8 +++++---
>  drivers/tty/synclink_gt.c              |  8 ++++----
>  drivers/tty/vt/vt.c                    |  6 +++---
>  drivers/usb/class/cdc-acm.c            |  8 ++++----
>  drivers/usb/gadget/function/u_serial.c |  8 ++++----
>  drivers/usb/serial/usb-serial.c        |  9 ++++-----
>  net/bluetooth/rfcomm/tty.c             |  8 ++++----
>  31 files changed, 120 insertions(+), 132 deletions(-)

For ipack changes:

Acked-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>

Sam

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 7/8] tty: drop put_tty_driver
  2021-07-23  7:43 ` [PATCH 7/8] tty: drop put_tty_driver Jiri Slaby
@ 2021-07-23  7:49   ` Samuel Iglesias Gonsálvez
  2021-07-23  7:55   ` Christian Borntraeger
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 22+ messages in thread
From: Samuel Iglesias Gonsálvez @ 2021-07-23  7:49 UTC (permalink / raw)
  To: Jiri Slaby, gregkh
  Cc: linux-serial, linux-kernel, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, Geert Uytterhoeven, Jeff Dike, Richard Weinberger,
	Anton Ivanov, Chris Zankel, Max Filippov, Arnd Bergmann,
	Jens Taprogge, Karsten Keil, Scott Branden, Ulf Hansson,
	David S. Miller, Jakub Kicinski, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, David Lin, Johan Hovold, Alex Elder,
	Jiri Slaby, Laurentiu Tudor, Jiri Kosina, David Sterba,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Oliver Neukum, Felipe Balbi, Mathias Nyman,
	Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz

[-- Attachment #1: Type: text/plain, Size: 4785 bytes --]

On Fri, 2021-07-23 at 09:43 +0200, Jiri Slaby wrote:
> put_tty_driver() is an alias for tty_driver_kref_put(). There is no
> need
> for two exported identical functions, therefore switch all users of
> old put_tty_driver() to new tty_driver_kref_put() and remove the
> former
> for good.
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Richard Henderson <rth@twiddle.net>
> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> Cc: Matt Turner <mattst88@gmail.com>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Jeff Dike <jdike@addtoit.com>
> Cc: Richard Weinberger <richard@nod.at>
> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> Cc: Chris Zankel <chris@zankel.net>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
> Cc: Jens Taprogge <jens.taprogge@taprogge.org>
> Cc: Karsten Keil <isdn@linux-pingi.de>
> Cc: Scott Branden <scott.branden@broadcom.com>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: David Lin <dtwlin@gmail.com>
> Cc: Johan Hovold <johan@kernel.org>
> Cc: Alex Elder <elder@kernel.org>
> Cc: Jiri Slaby <jirislaby@kernel.org>
> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Cc: Jiri Kosina <jikos@kernel.org>
> Cc: David Sterba <dsterba@suse.com>
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: NXP Linux Team <linux-imx@nxp.com>
> Cc: Oliver Neukum <oneukum@suse.com>
> Cc: Felipe Balbi <balbi@kernel.org>
> Cc: Mathias Nyman <mathias.nyman@intel.com>
> Cc: Marcel Holtmann <marcel@holtmann.org>
> Cc: Johan Hedberg <johan.hedberg@gmail.com>
> Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
> ---
>  arch/alpha/kernel/srmcons.c            | 2 +-
>  arch/m68k/emu/nfcon.c                  | 4 ++--
>  arch/um/drivers/line.c                 | 2 +-
>  arch/xtensa/platforms/iss/console.c    | 2 +-
>  drivers/char/pcmcia/synclink_cs.c      | 4 ++--
>  drivers/char/ttyprintk.c               | 4 ++--
>  drivers/ipack/devices/ipoctal.c        | 4 ++--
>  drivers/isdn/capi/capi.c               | 4 ++--
>  drivers/misc/bcm-vk/bcm_vk_tty.c       | 8 ++++----
>  drivers/mmc/core/sdio_uart.c           | 4 ++--
>  drivers/net/usb/hso.c                  | 4 ++--
>  drivers/s390/char/con3215.c            | 4 ++--
>  drivers/s390/char/sclp_tty.c           | 8 ++++----
>  drivers/s390/char/sclp_vt220.c         | 2 +-
>  drivers/s390/char/tty3270.c            | 4 ++--
>  drivers/staging/fwserial/fwserial.c    | 8 ++++----
>  drivers/staging/gdm724x/gdm_tty.c      | 4 ++--
>  drivers/staging/greybus/uart.c         | 4 ++--
>  drivers/tty/amiserial.c                | 8 ++++----
>  drivers/tty/ehv_bytechan.c             | 6 +++---
>  drivers/tty/goldfish.c                 | 4 ++--
>  drivers/tty/hvc/hvc_console.c          | 2 +-
>  drivers/tty/hvc/hvcs.c                 | 4 ++--
>  drivers/tty/ipwireless/tty.c           | 4 ++--
>  drivers/tty/mips_ejtag_fdc.c           | 2 +-
>  drivers/tty/moxa.c                     | 4 ++--
>  drivers/tty/mxser.c                    | 4 ++--
>  drivers/tty/n_gsm.c                    | 4 ++--
>  drivers/tty/nozomi.c                   | 4 ++--
>  drivers/tty/serial/kgdb_nmi.c          | 4 ++--
>  drivers/tty/serial/serial_core.c       | 4 ++--
>  drivers/tty/synclink_gt.c              | 4 ++--
>  drivers/tty/tty_io.c                   | 6 ------
>  drivers/tty/ttynull.c                  | 4 ++--
>  drivers/tty/vcc.c                      | 4 ++--
>  drivers/usb/class/cdc-acm.c            | 6 +++---
>  drivers/usb/gadget/function/u_serial.c | 4 ++--
>  drivers/usb/host/xhci-dbgtty.c         | 4 ++--
>  drivers/usb/serial/usb-serial.c        | 4 ++--
>  include/linux/tty_driver.h             | 1 -
>  net/bluetooth/rfcomm/tty.c             | 4 ++--
>  41 files changed, 82 insertions(+), 89 deletions(-)

For ipack changes:

Acked-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>

Sam

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 7/8] tty: drop put_tty_driver
  2021-07-23  7:43 ` [PATCH 7/8] tty: drop put_tty_driver Jiri Slaby
  2021-07-23  7:49   ` Samuel Iglesias Gonsálvez
@ 2021-07-23  7:55   ` Christian Borntraeger
  2021-07-23 10:16   ` David Sterba
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 22+ messages in thread
From: Christian Borntraeger @ 2021-07-23  7:55 UTC (permalink / raw)
  To: Jiri Slaby, gregkh
  Cc: linux-serial, linux-kernel, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, Geert Uytterhoeven, Jeff Dike, Richard Weinberger,
	Anton Ivanov, Chris Zankel, Max Filippov, Arnd Bergmann,
	Samuel Iglesias Gonsalvez, Jens Taprogge, Karsten Keil,
	Scott Branden, Ulf Hansson, David S. Miller, Jakub Kicinski,
	Heiko Carstens, Vasily Gorbik, David Lin, Johan Hovold,
	Alex Elder, Jiri Slaby, Laurentiu Tudor, Jiri Kosina,
	David Sterba, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Oliver Neukum, Felipe Balbi,
	Mathias Nyman, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz



On 23.07.21 09:43, Jiri Slaby wrote:
> put_tty_driver() is an alias for tty_driver_kref_put(). There is no need
> for two exported identical functions, therefore switch all users of
> old put_tty_driver() to new tty_driver_kref_put() and remove the former
> for good.
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
[...]
for the s390 parts

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
>   drivers/s390/char/con3215.c            | 4 ++--
>   drivers/s390/char/sclp_tty.c           | 8 ++++----
>   drivers/s390/char/sclp_vt220.c         | 2 +-
>   drivers/s390/char/tty3270.c            | 4 ++--

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/8] tty: stop using alloc_tty_driver
  2021-07-23  7:43 ` [PATCH 4/8] tty: stop using alloc_tty_driver Jiri Slaby
  2021-07-23  7:49   ` Samuel Iglesias Gonsálvez
@ 2021-07-23  7:57   ` Christian Borntraeger
  2021-07-23 10:16   ` David Sterba
  2021-07-23 10:30   ` Max Filippov
  3 siblings, 0 replies; 22+ messages in thread
From: Christian Borntraeger @ 2021-07-23  7:57 UTC (permalink / raw)
  To: Jiri Slaby, gregkh
  Cc: linux-serial, linux-kernel, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, Geert Uytterhoeven, James E.J. Bottomley,
	Helge Deller, Jeff Dike, Richard Weinberger, Anton Ivanov,
	Chris Zankel, Max Filippov, Samuel Iglesias Gonsalvez,
	Jens Taprogge, Karsten Keil, Ulf Hansson, David S. Miller,
	Jakub Kicinski, Heiko Carstens, Vasily Gorbik, Laurentiu Tudor,
	Jiri Kosina, David Sterba, Shawn Guo, Sascha Hauer,
	Oliver Neukum, Felipe Balbi, Johan Hovold, Marcel Holtmann,
	Johan Hedberg, Luiz Augusto von Dentz



On 23.07.21 09:43, Jiri Slaby wrote:
> alloc_tty_driver was deprecated by tty_alloc_driver in commit
> 7f0bc6a68ed9 (TTY: pass flags to alloc_tty_driver) in 2012.
> 
> I never got into eliminating alloc_tty_driver until now. So we still
> have two functions for allocating drivers which might be confusing. So
> get rid of alloc_tty_driver uses to eliminate it for good in the next
> patch.
> 
> Note we need to switch return value checking as tty_alloc_driver uses
> ERR_PTR. And flags are now a parameter of tty_alloc_driver.
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
[..]
>   drivers/s390/char/con3215.c            |  7 +++----
>   drivers/s390/char/sclp_tty.c           |  7 +++----
>   drivers/s390/char/sclp_vt220.c         |  7 +++----

s390 parts look sane

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/8] tty: stop using alloc_tty_driver
  2021-07-23  7:43 ` [PATCH 4/8] tty: stop using alloc_tty_driver Jiri Slaby
  2021-07-23  7:49   ` Samuel Iglesias Gonsálvez
  2021-07-23  7:57   ` Christian Borntraeger
@ 2021-07-23 10:16   ` David Sterba
  2021-07-23 10:30   ` Max Filippov
  3 siblings, 0 replies; 22+ messages in thread
From: David Sterba @ 2021-07-23 10:16 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: gregkh, linux-serial, linux-kernel, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Geert Uytterhoeven,
	James E.J. Bottomley, Helge Deller, Jeff Dike,
	Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
	Samuel Iglesias Gonsalvez, Jens Taprogge, Karsten Keil,
	Ulf Hansson, David S. Miller, Jakub Kicinski, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger, Laurentiu Tudor,
	Jiri Kosina, David Sterba, Shawn Guo, Sascha Hauer,
	Oliver Neukum, Felipe Balbi, Johan Hovold, Marcel Holtmann,
	Johan Hedberg, Luiz Augusto von Dentz

On Fri, Jul 23, 2021 at 09:43:13AM +0200, Jiri Slaby wrote:

>  drivers/tty/ipwireless/tty.c           |  8 ++++----

Acked-by: David Sterba <dsterba@suse.com>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 7/8] tty: drop put_tty_driver
  2021-07-23  7:43 ` [PATCH 7/8] tty: drop put_tty_driver Jiri Slaby
  2021-07-23  7:49   ` Samuel Iglesias Gonsálvez
  2021-07-23  7:55   ` Christian Borntraeger
@ 2021-07-23 10:16   ` David Sterba
  2021-07-23 10:32   ` Max Filippov
  2021-07-23 12:50   ` Alex Elder
  4 siblings, 0 replies; 22+ messages in thread
From: David Sterba @ 2021-07-23 10:16 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: gregkh, linux-serial, linux-kernel, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Geert Uytterhoeven, Jeff Dike,
	Richard Weinberger, Anton Ivanov, Chris Zankel, Max Filippov,
	Arnd Bergmann, Samuel Iglesias Gonsalvez, Jens Taprogge,
	Karsten Keil, Scott Branden, Ulf Hansson, David S. Miller,
	Jakub Kicinski, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, David Lin, Johan Hovold, Alex Elder,
	Jiri Slaby, Laurentiu Tudor, Jiri Kosina, David Sterba,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Oliver Neukum, Felipe Balbi, Mathias Nyman,
	Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz

On Fri, Jul 23, 2021 at 09:43:16AM +0200, Jiri Slaby wrote:

>  drivers/tty/ipwireless/tty.c           | 4 ++--

Acked-by: David Sterba <dsterba@suse.com>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/8] xtensa: ISS: don't panic in rs_init
  2021-07-23  7:43 ` [PATCH 1/8] xtensa: ISS: don't panic in rs_init Jiri Slaby
@ 2021-07-23 10:18   ` Max Filippov
  0 siblings, 0 replies; 22+ messages in thread
From: Max Filippov @ 2021-07-23 10:18 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Greg Kroah-Hartman, linux-serial, LKML, Chris Zankel,
	open list:TENSILICA XTENSA PORT (xtensa)

On Fri, Jul 23, 2021 at 12:43 AM Jiri Slaby <jslaby@suse.cz> wrote:
>
> While alloc_tty_driver failure in rs_init would mean we have much bigger
> problem, there is no reason to panic when tty_register_driver fails
> there. It can fail for various reasons.
>
> So handle the failure gracefully. Actually handle them both while at it.
> This will make at least the console functional as it was enabled earlier
> by console_initcall in iss_console_init. Instead of shooting down the
> whole system.
>
> We move tty_port_init() after alloc_tty_driver(), so that we don't need
> to destroy the port in case the latter function fails.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Chris Zankel <chris@zankel.net>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: linux-xtensa@linux-xtensa.org
> ---
>  arch/xtensa/platforms/iss/console.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)

Acked-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 3/8] tty: don't store semi-state into tty drivers
  2021-07-23  7:43 ` [PATCH 3/8] tty: don't store semi-state into tty drivers Jiri Slaby
@ 2021-07-23 10:23   ` Max Filippov
  2021-07-23 16:37   ` Helge Deller
  1 sibling, 0 replies; 22+ messages in thread
From: Max Filippov @ 2021-07-23 10:23 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Greg Kroah-Hartman, linux-serial, LKML, Geert Uytterhoeven,
	James E.J. Bottomley, Helge Deller, Chris Zankel,
	Laurentiu Tudor, Felipe Balbi

On Fri, Jul 23, 2021 at 12:43 AM Jiri Slaby <jslaby@suse.cz> wrote:
>
> When a tty driver pointer is used as a return value of struct
> console's device() hook, don't store a semi-state into global variable
> which holds the tty driver. It could mean console::device() would return
> a bogus value. This is important esp. after the next patch where we
> switch from alloc_tty_driver to tty_alloc_driver. tty_alloc_driver
> returns ERR_PTR in case of error and that might have unexpected results
> as the code doesn't expect this.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: Helge Deller <deller@gmx.de>
> Cc: Chris Zankel <chris@zankel.net>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Cc: Felipe Balbi <balbi@kernel.org>
> ---
>  arch/m68k/emu/nfcon.c                  | 27 +++++++++++---------
>  arch/parisc/kernel/pdc_cons.c          | 28 +++++++++++----------
>  arch/xtensa/platforms/iss/console.c    | 33 +++++++++++++-----------
>  drivers/tty/amiserial.c                | 35 ++++++++++++++------------
>  drivers/tty/ehv_bytechan.c             | 28 ++++++++++++---------
>  drivers/tty/hvc/hvsi.c                 | 35 ++++++++++++++------------
>  drivers/usb/gadget/function/u_serial.c | 32 ++++++++++++-----------
>  7 files changed, 119 insertions(+), 99 deletions(-)

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/8] tty: stop using alloc_tty_driver
  2021-07-23  7:43 ` [PATCH 4/8] tty: stop using alloc_tty_driver Jiri Slaby
                     ` (2 preceding siblings ...)
  2021-07-23 10:16   ` David Sterba
@ 2021-07-23 10:30   ` Max Filippov
  3 siblings, 0 replies; 22+ messages in thread
From: Max Filippov @ 2021-07-23 10:30 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Greg Kroah-Hartman, linux-serial, LKML, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Geert Uytterhoeven,
	James E.J. Bottomley, Helge Deller, Jeff Dike,
	Richard Weinberger, Anton Ivanov, Chris Zankel,
	Samuel Iglesias Gonsalvez, Jens Taprogge, Karsten Keil,
	Ulf Hansson, David S. Miller, Jakub Kicinski, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger, Laurentiu Tudor,
	Jiri Kosina, David Sterba, Shawn Guo, Sascha Hauer,
	Oliver Neukum, Felipe Balbi, Johan Hovold, Marcel Holtmann,
	Johan Hedberg, Luiz Augusto von Dentz

On Fri, Jul 23, 2021 at 12:43 AM Jiri Slaby <jslaby@suse.cz> wrote:
>
> alloc_tty_driver was deprecated by tty_alloc_driver in commit
> 7f0bc6a68ed9 (TTY: pass flags to alloc_tty_driver) in 2012.
>
> I never got into eliminating alloc_tty_driver until now. So we still
> have two functions for allocating drivers which might be confusing. So
> get rid of alloc_tty_driver uses to eliminate it for good in the next
> patch.
>
> Note we need to switch return value checking as tty_alloc_driver uses
> ERR_PTR. And flags are now a parameter of tty_alloc_driver.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>

>  arch/xtensa/platforms/iss/console.c    |  7 +++----

Acked-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 7/8] tty: drop put_tty_driver
  2021-07-23  7:43 ` [PATCH 7/8] tty: drop put_tty_driver Jiri Slaby
                     ` (2 preceding siblings ...)
  2021-07-23 10:16   ` David Sterba
@ 2021-07-23 10:32   ` Max Filippov
  2021-07-23 12:50   ` Alex Elder
  4 siblings, 0 replies; 22+ messages in thread
From: Max Filippov @ 2021-07-23 10:32 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Greg Kroah-Hartman, linux-serial, LKML, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Geert Uytterhoeven, Jeff Dike,
	Richard Weinberger, Anton Ivanov, Chris Zankel, Arnd Bergmann,
	Samuel Iglesias Gonsalvez, Jens Taprogge, Karsten Keil,
	Scott Branden, Ulf Hansson, David S. Miller, Jakub Kicinski,
	Heiko Carstens, Vasily Gorbik, Christian Borntraeger, David Lin,
	Johan Hovold, Alex Elder, Jiri Slaby, Laurentiu Tudor,
	Jiri Kosina, David Sterba, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
	Oliver Neukum, Felipe Balbi, Mathias Nyman, Marcel Holtmann,
	Johan Hedberg, Luiz Augusto von Dentz

On Fri, Jul 23, 2021 at 12:43 AM Jiri Slaby <jslaby@suse.cz> wrote:
>
> put_tty_driver() is an alias for tty_driver_kref_put(). There is no need
> for two exported identical functions, therefore switch all users of
> old put_tty_driver() to new tty_driver_kref_put() and remove the former
> for good.

>  arch/xtensa/platforms/iss/console.c    | 2 +-

Acked-by: Max Filippov <jcmvbkbc@gmail.com>
-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 7/8] tty: drop put_tty_driver
  2021-07-23  7:43 ` [PATCH 7/8] tty: drop put_tty_driver Jiri Slaby
                     ` (3 preceding siblings ...)
  2021-07-23 10:32   ` Max Filippov
@ 2021-07-23 12:50   ` Alex Elder
  4 siblings, 0 replies; 22+ messages in thread
From: Alex Elder @ 2021-07-23 12:50 UTC (permalink / raw)
  To: Jiri Slaby, gregkh
  Cc: linux-serial, linux-kernel, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, Geert Uytterhoeven, Jeff Dike, Richard Weinberger,
	Anton Ivanov, Chris Zankel, Max Filippov, Arnd Bergmann,
	Samuel Iglesias Gonsalvez, Jens Taprogge, Karsten Keil,
	Scott Branden, Ulf Hansson, David S. Miller, Jakub Kicinski,
	Heiko Carstens, Vasily Gorbik, Christian Borntraeger, David Lin,
	Johan Hovold, Alex Elder, Jiri Slaby, Laurentiu Tudor,
	Jiri Kosina, David Sterba, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
	Oliver Neukum, Felipe Balbi, Mathias Nyman, Marcel Holtmann,
	Johan Hedberg, Luiz Augusto von Dentz

On 7/23/21 2:43 AM, Jiri Slaby wrote:
>   drivers/staging/greybus/uart.c         | 4 ++--

Acked-by: Alex Elder <elder@linaro.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 3/8] tty: don't store semi-state into tty drivers
  2021-07-23  7:43 ` [PATCH 3/8] tty: don't store semi-state into tty drivers Jiri Slaby
  2021-07-23 10:23   ` Max Filippov
@ 2021-07-23 16:37   ` Helge Deller
  1 sibling, 0 replies; 22+ messages in thread
From: Helge Deller @ 2021-07-23 16:37 UTC (permalink / raw)
  To: Jiri Slaby, gregkh
  Cc: linux-serial, linux-kernel, Geert Uytterhoeven,
	James E.J. Bottomley, Chris Zankel, Max Filippov,
	Laurentiu Tudor, Felipe Balbi

On 7/23/21 9:43 AM, Jiri Slaby wrote:
> When a tty driver pointer is used as a return value of struct
> console's device() hook, don't store a semi-state into global variable
> which holds the tty driver. It could mean console::device() would return
> a bogus value. This is important esp. after the next patch where we
> switch from alloc_tty_driver to tty_alloc_driver. tty_alloc_driver
> returns ERR_PTR in case of error and that might have unexpected results
> as the code doesn't expect this.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: Helge Deller <deller@gmx.de>
> Cc: Chris Zankel <chris@zankel.net>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Cc: Felipe Balbi <balbi@kernel.org>
> ---
>   arch/m68k/emu/nfcon.c                  | 27 +++++++++++---------
>   arch/parisc/kernel/pdc_cons.c          | 28 +++++++++++----------
>   arch/xtensa/platforms/iss/console.c    | 33 +++++++++++++-----------
>   drivers/tty/amiserial.c                | 35 ++++++++++++++------------
>   drivers/tty/ehv_bytechan.c             | 28 ++++++++++++---------
>   drivers/tty/hvc/hvsi.c                 | 35 ++++++++++++++------------
>   drivers/usb/gadget/function/u_serial.c | 32 ++++++++++++-----------
>   7 files changed, 119 insertions(+), 99 deletions(-)
>
...

You may add:

Acked-by: Helge Deller <deller@gmx.de>	# parisc

to the whole series (specifically patches 3, 4 and 8) regarding the parisc changes.

Thank you!
Helge

>
> diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
> index 39ccad063533..650cb01203de 100644
> --- a/arch/parisc/kernel/pdc_cons.c
> +++ b/arch/parisc/kernel/pdc_cons.c
> @@ -138,6 +138,7 @@ static struct tty_driver *pdc_console_tty_driver;
>
>   static int __init pdc_console_tty_driver_init(void)
>   {
> +	struct tty_driver *driver;
>   	int err;
>
>   	/* Check if the console driver is still registered.
> @@ -160,31 +161,32 @@ static int __init pdc_console_tty_driver_init(void)
>   	printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n");
>   	pdc_cons.flags &= ~CON_BOOT;
>
> -	pdc_console_tty_driver = alloc_tty_driver(1);
> -
> -	if (!pdc_console_tty_driver)
> +	driver = alloc_tty_driver(1);
> +	if (!driver)
>   		return -ENOMEM;
>
>   	tty_port_init(&tty_port);
>
> -	pdc_console_tty_driver->driver_name = "pdc_cons";
> -	pdc_console_tty_driver->name = "ttyB";
> -	pdc_console_tty_driver->major = MUX_MAJOR;
> -	pdc_console_tty_driver->minor_start = 0;
> -	pdc_console_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM;
> -	pdc_console_tty_driver->init_termios = tty_std_termios;
> -	pdc_console_tty_driver->flags = TTY_DRIVER_REAL_RAW |
> +	driver->driver_name = "pdc_cons";
> +	driver->name = "ttyB";
> +	driver->major = MUX_MAJOR;
> +	driver->minor_start = 0;
> +	driver->type = TTY_DRIVER_TYPE_SYSTEM;
> +	driver->init_termios = tty_std_termios;
> +	driver->flags = TTY_DRIVER_REAL_RAW |
>   		TTY_DRIVER_RESET_TERMIOS;
> -	tty_set_operations(pdc_console_tty_driver, &pdc_console_tty_ops);
> -	tty_port_link_device(&tty_port, pdc_console_tty_driver, 0);
> +	tty_set_operations(driver, &pdc_console_tty_ops);
> +	tty_port_link_device(&tty_port, driver, 0);
>
> -	err = tty_register_driver(pdc_console_tty_driver);
> +	err = tty_register_driver(driver);
>   	if (err) {
>   		printk(KERN_ERR "Unable to register the PDC console TTY driver\n");
>   		tty_port_destroy(&tty_port);
>   		return err;
>   	}
>
> +	pdc_console_tty_driver = driver;
> +
>   	return 0;
>   }
>   device_initcall(pdc_console_tty_driver_init);
...

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/8] Get rid of old tty_driver functions
  2021-07-23  7:43 [PATCH 0/8] Get rid of old tty_driver functions Jiri Slaby
                   ` (7 preceding siblings ...)
  2021-07-23  7:43 ` [PATCH 8/8] tty: pdc_cons, free tty_driver upon failure Jiri Slaby
@ 2021-07-27 10:18 ` Greg KH
  8 siblings, 0 replies; 22+ messages in thread
From: Greg KH @ 2021-07-27 10:18 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: linux-serial, linux-kernel

On Fri, Jul 23, 2021 at 09:43:09AM +0200, Jiri Slaby wrote:
> This series converts the rest of the drivers to use:
> * tty_alloc_driver instead of alloc_tty_driver, and
> * tty_driver_kref_put instead of put_tty_driver.
> 
> They were more of less interchangeable, alloc_tty_driver() and
> put_tty_driver() are older interfaces which weren't eliminated until
> now.

Nice, thanks for cleaning this up!

greg k-h

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2021-07-27 10:18 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23  7:43 [PATCH 0/8] Get rid of old tty_driver functions Jiri Slaby
2021-07-23  7:43 ` [PATCH 1/8] xtensa: ISS: don't panic in rs_init Jiri Slaby
2021-07-23 10:18   ` Max Filippov
2021-07-23  7:43 ` [PATCH 2/8] hvsi: don't panic on tty_register_driver failure Jiri Slaby
2021-07-23  7:43 ` [PATCH 3/8] tty: don't store semi-state into tty drivers Jiri Slaby
2021-07-23 10:23   ` Max Filippov
2021-07-23 16:37   ` Helge Deller
2021-07-23  7:43 ` [PATCH 4/8] tty: stop using alloc_tty_driver Jiri Slaby
2021-07-23  7:49   ` Samuel Iglesias Gonsálvez
2021-07-23  7:57   ` Christian Borntraeger
2021-07-23 10:16   ` David Sterba
2021-07-23 10:30   ` Max Filippov
2021-07-23  7:43 ` [PATCH 5/8] tty: drop alloc_tty_driver Jiri Slaby
2021-07-23  7:43 ` [PATCH 6/8] tty: make tty_set_operations an inline Jiri Slaby
2021-07-23  7:43 ` [PATCH 7/8] tty: drop put_tty_driver Jiri Slaby
2021-07-23  7:49   ` Samuel Iglesias Gonsálvez
2021-07-23  7:55   ` Christian Borntraeger
2021-07-23 10:16   ` David Sterba
2021-07-23 10:32   ` Max Filippov
2021-07-23 12:50   ` Alex Elder
2021-07-23  7:43 ` [PATCH 8/8] tty: pdc_cons, free tty_driver upon failure Jiri Slaby
2021-07-27 10:18 ` [PATCH 0/8] Get rid of old tty_driver functions Greg KH

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).