Get rid of old tty_driver functions
Subsystems (27)
cover Get rid of old tty_driver functions
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(-)
Signature · 1 line
2.32.0
PATCH 1/8 xtensa: ISS: don't panic in rs_init
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.
--- arch/xtensa/platforms/iss/console.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
arch/xtensa/platforms/iss/console.c +14 -3
@@ -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 ; }
Signature · 1 line
2.32.0
Re: [PATCH 1/8] xtensa: ISS: don't panic in rs_init
Quoted 13 lines · Jiri Slaby
While
alloc_tty_driverfailure inrs_initwould mean we have much bigger problem, there is no reason to panic whentty_register_driverfails 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_initcalliniss_console_init. Instead of shooting down the whole system.We move
tty_port_init()afteralloc_tty_driver(), so that we don't need to destroy the port in case the latter function fails.
Quoted 7 lines
Signed-off-by Jiri Slaby <[email protected]>Cc Chris Zankel <[email protected]>Cc Max Filippov <[email protected]>--- arch/xtensa/platforms/iss/console.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
Signature · 2 lines
Thanks. -- Max
PATCH 2/8 hvsi: don't panic on tty_register_driver failure
In reply to Jiri SlabyThe 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().
--- drivers/tty/hvc/hvsi.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/tty/hvc/hvsi.c +16 -3
@@ -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);
Signature · 1 line
2.32.0
PATCH 3/8 tty: don't store semi-state into tty drivers
In reply to Jiri SlabyWhen 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.
--- 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(-)
arch/m68k/emu/nfcon.c +15 -12
@@ -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);
arch/parisc/kernel/pdc_cons.c +15 -13
@@ -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);
arch/xtensa/platforms/iss/console.c +18 -15
@@ -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 ; }
drivers/tty/amiserial.c +19 -16
@@ -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; }
drivers/tty/ehv_bytechan.c +16 -12
@@ -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);
drivers/tty/hvc/hvsi.c +19 -16
@@ -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; }
drivers/usb/gadget/function/u_serial.c +17 -15
@@ -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);
Signature · 1 line
2.32.0
Re: [PATCH 3/8] tty: don't store semi-state into tty drivers
Quoted 17 lines · Jiri Slaby
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 meanconsole::device()would return a bogus value. This is important esp. after the next patch where we switch fromalloc_tty_drivertotty_alloc_driver.tty_alloc_driverreturnsERR_PTRin case of error and that might have unexpected results as the code doesn't expect this.Signed-off-by Jiri Slaby <[email protected]>Cc Geert Uytterhoeven <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc Helge Deller <[email protected]>Cc Chris Zankel <[email protected]>Cc Max Filippov <[email protected]>Cc Laurentiu Tudor <[email protected]>Cc Felipe Balbi <[email protected]>
Quoted 9 lines
--- 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(-)
Signature · 2 lines
Thanks. -- Max
Re: [PATCH 3/8] tty: don't store semi-state into tty drivers
In reply to Jiri SlabyQuoted 16 lines · Jiri Slaby
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 meanconsole::device()would return a bogus value. This is important esp. after the next patch where we switch fromalloc_tty_drivertotty_alloc_driver.tty_alloc_driverreturnsERR_PTRin case of error and that might have unexpected results as the code doesn't expect this.Signed-off-by Jiri Slaby <[email protected]>Cc Geert Uytterhoeven <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc Helge Deller <[email protected]>Cc Chris Zankel <[email protected]>Cc Max Filippov <[email protected]>Cc Laurentiu Tudor <[email protected]>Cc Felipe Balbi <[email protected]>
Quoted 10 lines
--- 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:
to the whole series (specifically patches 3, 4 and 8) regarding the parisc changes.
Thank you!
Helge
Quoted 59 lines
arch/parisc/kernel/pdc_cons.c +15
-13@@ -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);
...
PATCH 4/8 tty: stop using alloc_tty_driver
In reply to Jiri Slabyalloc_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.
--- 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(-)
arch/alpha/kernel/srmcons.c +3 -3
@@ -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);
arch/m68k/emu/nfcon.c +3 -4
@@ -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 );
arch/parisc/kernel/pdc_cons.c +4 -5
@@ -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 );
arch/um/drivers/line.c +6 -5
@@ -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;
arch/xtensa/platforms/iss/console.c +3 -4
@@ -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 );
drivers/ipack/devices/ipoctal.c +4 -5
@@ -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 ;
drivers/isdn/capi/capi.c +4 -6
@@ -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);
drivers/mmc/core/sdio_uart.c +4 -4
@@ -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 ;
drivers/net/usb/hso.c +4 -4
@@ -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);
drivers/s390/char/con3215.c +3 -4
@@ -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) {
drivers/s390/char/sclp_tty.c +3 -4
@@ -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);
drivers/s390/char/sclp_vt220.c +3 -4
@@ -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 );
drivers/staging/gdm724x/gdm_tty.c +4 -5
@@ -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 ;
drivers/tty/amiserial.c +3 -4
@@ -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));
drivers/tty/ehv_bytechan.c +4 -4
@@ -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);
drivers/tty/goldfish.c +7 -7
@@ -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:
drivers/tty/hvc/hvc_console.c +4 -4
@@ -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
drivers/tty/hvc/hvcs.c +4 -4
@@ -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);
drivers/tty/hvc/hvsi.c +3 -4
@@ -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++) {
drivers/tty/ipwireless/tty.c +4 -4
@@ -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 ;
drivers/tty/mxser.c +4 -4
@@ -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);
drivers/tty/n_gsm.c +4 -5
@@ -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 ;
drivers/tty/nozomi.c +4 -4
@@ -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 ;
drivers/tty/serial/kgdb_nmi.c +3 -4
@@ -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 );
drivers/tty/serial/serial_core.c +5 -3
@@ -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);
drivers/tty/synclink_gt.c +4 -4
@@ -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));
drivers/tty/vt/vt.c +3 -3
@@ -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" );
drivers/usb/class/cdc-acm.c +4 -4
@@ -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 ;
drivers/usb/gadget/function/u_serial.c +4 -4
@@ -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
drivers/usb/serial/usb-serial.c +4 -5
@@ -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 ;
net/bluetooth/rfcomm/tty.c +4 -4
@@ -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 ;
Signature · 1 line
2.32.0
Re: [PATCH 4/8] tty: stop using alloc_tty_driver
Quoted 76 lines · Jiri Slaby
alloc_tty_driverwas deprecated bytty_alloc_driverin commit7f0bc6a68ed9(TTY: pass flags toalloc_tty_driver) in 2012.I never got into eliminating
alloc_tty_driveruntil now. So we still have two functions for allocating drivers which might be confusing. So
get rid ofalloc_tty_driveruses to eliminate it for good in the next patch.Note we need to switch return value checking as
tty_alloc_driverusesERR_PTR. And flags are now a parameter oftty_alloc_driver.Signed-off-by Jiri Slaby <[email protected]>Cc Richard Henderson <[email protected]>(odd fixer:ALPHA PORT)Cc Ivan Kokshaysky <[email protected]>Cc Matt Turner <[email protected]>Cc Geert Uytterhoeven <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc Helge Deller <[email protected]>Cc Jeff Dike <[email protected]>Cc Richard Weinberger <[email protected]>Cc Anton Ivanov <[email protected]>Cc Chris Zankel <[email protected]>Cc Max Filippov <[email protected]>Cc Samuel Iglesias Gonsalvez <[email protected]>Cc Jens Taprogge <[email protected]>Cc Karsten Keil <[email protected]>Cc Ulf Hansson <[email protected]>Cc "David S. Miller" <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Heiko Carstens <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Laurentiu Tudor <[email protected]>Cc Jiri Kosina <[email protected]>Cc David Sterba <[email protected]>Cc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Cc Oliver Neukum <[email protected]>Cc Felipe Balbi <[email protected]>Cc Johan Hovold <[email protected]>Cc Marcel Holtmann <[email protected]>Cc Johan Hedberg <[email protected]>Cc Luiz Augusto von Dentz <[email protected]>---
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 ++++----
Quoted 1 line
31 files changed, 120 insertions(+), 132 deletions(-)
For ipack changes:
Sam
Re: [PATCH 4/8] tty: stop using alloc_tty_driver
In reply to Jiri SlabyQuoted 12 lines · Jiri Slaby
alloc_tty_driverwas deprecated bytty_alloc_driverin commit7f0bc6a68ed9(TTY: pass flags toalloc_tty_driver) in 2012.I never got into eliminating
alloc_tty_driveruntil now. So we still have two functions for allocating drivers which might be confusing. So get rid ofalloc_tty_driveruses to eliminate it for good in the next patch.Note we need to switch return value checking as
tty_alloc_driverusesERR_PTR. And flags are now a parameter oftty_alloc_driver.Signed-off-by Jiri Slaby <[email protected]>
[..]
Quoted 3 lines
drivers/s390/char/con3215.c | 7 +++---- drivers/s390/char/sclp_tty.c | 7 +++---- drivers/s390/char/sclp_vt220.c | 7 +++----
s390 parts look sane
Re: [PATCH 4/8] tty: stop using alloc_tty_driver
In reply to Jiri SlabyQuoted 1 line · Jiri Slaby
drivers/tty/ipwireless/tty.c | 8 ++++----
Re: [PATCH 4/8] tty: stop using alloc_tty_driver
In reply to Jiri SlabyQuoted 9 lines · Jiri Slaby
alloc_tty_driverwas deprecated bytty_alloc_driverin commit7f0bc6a68ed9(TTY: pass flags toalloc_tty_driver) in 2012.I never got into eliminating
alloc_tty_driveruntil now. So we still have two functions for allocating drivers which might be confusing. So get rid ofalloc_tty_driveruses to eliminate it for good in the next patch.
Quoted 6 lines
Note we need to switch return value checking as
tty_alloc_driverusesERR_PTR. And flags are now a parameter oftty_alloc_driver.Signed-off-by Jiri Slaby <[email protected]>arch/xtensa/platforms/iss/console.c | 7 +++----
Signature · 2 lines
Thanks. -- Max
PATCH 5/8 tty: drop alloc_tty_driver
In reply to Jiri SlabyNoone uses this deprecated function now. So we can remove it.
--- include/linux/tty_driver.h | 12 ------------ 1 file changed, 12 deletions(-)
include/linux/tty_driver.h +0 -12
@@ -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);
Signature · 1 line
2.32.0
PATCH 6/8 tty: make tty_set_operations an inline
In reply to Jiri SlabySince 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.
--- drivers/tty/tty_io.c | 7 ------- include/linux/tty_driver.h | 8 ++++++-- 2 files changed, 6 insertions(+), 9 deletions(-)
drivers/tty/tty_io.c +0 -7
@@ -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);
include/linux/tty_driver.h +6 -2
@@ -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
Signature · 1 line
2.32.0
PATCH 7/8 tty: drop put_tty_driver
In reply to Jiri Slabyput_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/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(-)
arch/alpha/kernel/srmcons.c +1 -1
@@ -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; }
arch/m68k/emu/nfcon.c +2 -2
@@ -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); }
arch/um/drivers/line.c +1 -1
@@ -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;
arch/xtensa/platforms/iss/console.c +1 -1
@@ -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); }
drivers/char/pcmcia/synclink_cs.c +2 -2
@@ -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);
drivers/char/ttyprintk.c +2 -2
@@ -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); }
drivers/ipack/devices/ipoctal.c +2 -2
@@ -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); }
drivers/isdn/capi/capi.c +2 -2
@@ -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); }
drivers/misc/bcm-vk/bcm_vk_tty.c +4 -4
@@ -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)
drivers/mmc/core/sdio_uart.c +2 -2
@@ -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);
drivers/net/usb/hso.c +2 -2
@@ -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 */
drivers/s390/char/con3215.c +2 -2
@@ -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;
drivers/s390/char/sclp_tty.c +4 -4
@@ -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; }
drivers/s390/char/sclp_vt220.c +1 -1
@@ -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);
drivers/s390/char/tty3270.c +2 -2
@@ -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 (); }
drivers/staging/fwserial/fwserial.c +4 -4
@@ -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); }
drivers/staging/gdm724x/gdm_tty.c +2 -2
@@ -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); } } }
drivers/staging/greybus/uart.c +2 -2
@@ -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); }
drivers/tty/amiserial.c +4 -4
@@ -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);
drivers/tty/ehv_bytechan.c +3 -3
@@ -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);
drivers/tty/goldfish.c +2 -2
@@ -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 ;
drivers/tty/hvc/hvc_console.c +1 -1
@@ -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; }
drivers/tty/hvc/hvcs.c +2 -2
@@ -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" ); }
drivers/tty/ipwireless/tty.c +2 -2
@@ -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)
drivers/tty/mips_ejtag_fdc.c +1 -1
@@ -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; }
drivers/tty/moxa.c +2 -2
@@ -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);
drivers/tty/mxser.c +2 -2
@@ -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);
drivers/tty/n_gsm.c +2 -2
@@ -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);
drivers/tty/nozomi.c +2 -2
@@ -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);
drivers/tty/serial/kgdb_nmi.c +2 -2
@@ -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 ; }
drivers/tty/serial/serial_core.c +2 -2
@@ -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);
drivers/tty/synclink_gt.c +2 -2
@@ -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; }
drivers/tty/tty_io.c +0 -6
@@ -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. */
drivers/tty/ttynull.c +2 -2
@@ -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); }
drivers/tty/vcc.c +2 -2
@@ -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 ;
drivers/usb/class/cdc-acm.c +3 -3
@@ -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); }
drivers/usb/gadget/function/u_serial.c +2 -2
@@ -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);
drivers/usb/host/xhci-dbgtty.c +2 -2
@@ -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 ; } }
drivers/usb/serial/usb-serial.c +2 -2
@@ -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); }
include/linux/tty_driver.h +0 -1
@@ -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);
net/bluetooth/rfcomm/tty.c +2 -2
@@ -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); }
Signature · 1 line
2.32.0
Re: [PATCH 7/8] tty: drop put_tty_driver
Quoted 89 lines · Jiri Slaby
put_tty_driver()is an alias fortty_driver_kref_put(). There is no need
for two exported identical functions, therefore switch all users of oldput_tty_driver()to newtty_driver_kref_put()and remove the former
for good.Signed-off-by Jiri Slaby <[email protected]>Cc Richard Henderson <[email protected]>Cc Ivan Kokshaysky <[email protected]>Cc Matt Turner <[email protected]>Cc Geert Uytterhoeven <[email protected]>Cc Jeff Dike <[email protected]>Cc Richard Weinberger <[email protected]>Cc Anton Ivanov <[email protected]>Cc Chris Zankel <[email protected]>Cc Max Filippov <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Samuel Iglesias Gonsalvez <[email protected]>Cc Jens Taprogge <[email protected]>Cc Karsten Keil <[email protected]>Cc Scott Branden <[email protected]>Cc Ulf Hansson <[email protected]>Cc "David S. Miller" <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Heiko Carstens <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Christian Borntraeger <[email protected]>Cc David Lin <[email protected]>Cc Johan Hovold <[email protected]>Cc Alex Elder <[email protected]>Cc Jiri Slaby <[email protected]>Cc Laurentiu Tudor <[email protected]>Cc Jiri Kosina <[email protected]>Cc David Sterba <[email protected]>Cc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Cc Pengutronix Kernel Team <[email protected]>Cc Fabio Estevam <[email protected]>Cc NXP Linux Team <[email protected]>Cc Oliver Neukum <[email protected]>Cc Felipe Balbi <[email protected]>Cc Mathias Nyman <[email protected]>Cc Marcel Holtmann <[email protected]>Cc Johan Hedberg <[email protected]>Cc Luiz Augusto von Dentz <[email protected]>---
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 ++--
Quoted 1 line
41 files changed, 82 insertions(+), 89 deletions(-)
For ipack changes:
Sam
Re: [PATCH 7/8] tty: drop put_tty_driver
In reply to Jiri SlabyQuoted 6 lines · Jiri Slaby
put_tty_driver()is an alias fortty_driver_kref_put(). There is no need for two exported identical functions, therefore switch all users of oldput_tty_driver()to newtty_driver_kref_put()and remove the former for good.Signed-off-by Jiri Slaby <[email protected]>
[...]
for the s390 parts
Quoted 4 lines
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 ++--
Re: [PATCH 7/8] tty: drop put_tty_driver
In reply to Jiri SlabyQuoted 1 line · Jiri Slaby
drivers/tty/ipwireless/tty.c | 4 ++--
Re: [PATCH 7/8] tty: drop put_tty_driver
In reply to Jiri SlabyQuoted 7 lines · Jiri Slaby
put_tty_driver()is an alias fortty_driver_kref_put(). There is no need for two exported identical functions, therefore switch all users of oldput_tty_driver()to newtty_driver_kref_put()and remove the former for good.arch/xtensa/platforms/iss/console.c | 2 +-
Signature · 2 lines
Thanks. -- Max
Re: [PATCH 7/8] tty: drop put_tty_driver
In reply to Jiri SlabyQuoted 1 line · Jiri Slaby
drivers/staging/greybus/uart.c | 4 ++--
PATCH 8/8 tty: pdc_cons, free tty_driver upon failure
In reply to Jiri Slabypdc_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.
--- arch/parisc/kernel/pdc_cons.c | 1 + 1 file changed, 1 insertion(+)
arch/parisc/kernel/pdc_cons.c +1 -0
@@ -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; }
Signature · 1 line
2.32.0
Greg KH
maintainerQuoted 7 lines · Jiri Slaby
This series converts the rest of the drivers to use:
*tty_alloc_driverinstead ofalloc_tty_driver, and
*tty_driver_kref_putinstead ofput_tty_driver.They were more of less interchangeable,
alloc_tty_driver()andput_tty_driver()are older interfaces which weren't eliminated until now.
Nice, thanks for cleaning this up!
greg k-h