diff options
41 files changed, 139 insertions, 40 deletions
diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c index 5d5865204a1d..59b7bbad8394 100644 --- a/arch/alpha/kernel/srmcons.c +++ b/arch/alpha/kernel/srmcons.c | |||
@@ -205,7 +205,6 @@ static const struct tty_operations srmcons_ops = { | |||
205 | static int __init | 205 | static int __init |
206 | srmcons_init(void) | 206 | srmcons_init(void) |
207 | { | 207 | { |
208 | tty_port_init(&srmcons_singleton.port); | ||
209 | setup_timer(&srmcons_singleton.timer, srmcons_receive_chars, | 208 | setup_timer(&srmcons_singleton.timer, srmcons_receive_chars, |
210 | (unsigned long)&srmcons_singleton); | 209 | (unsigned long)&srmcons_singleton); |
211 | if (srm_is_registered_console) { | 210 | if (srm_is_registered_console) { |
@@ -215,6 +214,9 @@ srmcons_init(void) | |||
215 | driver = alloc_tty_driver(MAX_SRM_CONSOLE_DEVICES); | 214 | driver = alloc_tty_driver(MAX_SRM_CONSOLE_DEVICES); |
216 | if (!driver) | 215 | if (!driver) |
217 | return -ENOMEM; | 216 | return -ENOMEM; |
217 | |||
218 | tty_port_init(&srmcons_singleton.port); | ||
219 | |||
218 | driver->driver_name = "srm"; | 220 | driver->driver_name = "srm"; |
219 | driver->name = "srm"; | 221 | driver->name = "srm"; |
220 | driver->major = 0; /* dynamic */ | 222 | driver->major = 0; /* dynamic */ |
@@ -227,6 +229,7 @@ srmcons_init(void) | |||
227 | err = tty_register_driver(driver); | 229 | err = tty_register_driver(driver); |
228 | if (err) { | 230 | if (err) { |
229 | put_tty_driver(driver); | 231 | put_tty_driver(driver); |
232 | tty_port_destroy(&srmcons_singleton.port); | ||
230 | return err; | 233 | return err; |
231 | } | 234 | } |
232 | srmcons_driver = driver; | 235 | srmcons_driver = driver; |
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c index ec536e4e36c9..fc3924d18c1f 100644 --- a/arch/ia64/hp/sim/simserial.c +++ b/arch/ia64/hp/sim/simserial.c | |||
@@ -555,6 +555,7 @@ static int __init simrs_init(void) | |||
555 | return 0; | 555 | return 0; |
556 | err_free_tty: | 556 | err_free_tty: |
557 | put_tty_driver(hp_simserial_driver); | 557 | put_tty_driver(hp_simserial_driver); |
558 | tty_port_destroy(&state->port); | ||
558 | return retval; | 559 | return retval; |
559 | } | 560 | } |
560 | 561 | ||
diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c index 16d170f53bfd..6685bf45c2c3 100644 --- a/arch/m68k/emu/nfcon.c +++ b/arch/m68k/emu/nfcon.c | |||
@@ -120,8 +120,6 @@ static int __init nfcon_init(void) | |||
120 | { | 120 | { |
121 | int res; | 121 | int res; |
122 | 122 | ||
123 | tty_port_init(&nfcon_tty_port); | ||
124 | |||
125 | stderr_id = nf_get_id("NF_STDERR"); | 123 | stderr_id = nf_get_id("NF_STDERR"); |
126 | if (!stderr_id) | 124 | if (!stderr_id) |
127 | return -ENODEV; | 125 | return -ENODEV; |
@@ -130,6 +128,8 @@ static int __init nfcon_init(void) | |||
130 | if (!nfcon_tty_driver) | 128 | if (!nfcon_tty_driver) |
131 | return -ENOMEM; | 129 | return -ENOMEM; |
132 | 130 | ||
131 | tty_port_init(&nfcon_tty_port); | ||
132 | |||
133 | nfcon_tty_driver->driver_name = "nfcon"; | 133 | nfcon_tty_driver->driver_name = "nfcon"; |
134 | nfcon_tty_driver->name = "nfcon"; | 134 | nfcon_tty_driver->name = "nfcon"; |
135 | nfcon_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM; | 135 | nfcon_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM; |
@@ -143,6 +143,7 @@ static int __init nfcon_init(void) | |||
143 | if (res) { | 143 | if (res) { |
144 | pr_err("failed to register nfcon tty driver\n"); | 144 | pr_err("failed to register nfcon tty driver\n"); |
145 | put_tty_driver(nfcon_tty_driver); | 145 | put_tty_driver(nfcon_tty_driver); |
146 | tty_port_destroy(&nfcon_tty_port); | ||
146 | return res; | 147 | return res; |
147 | } | 148 | } |
148 | 149 | ||
@@ -157,6 +158,7 @@ static void __exit nfcon_exit(void) | |||
157 | unregister_console(&nf_console); | 158 | unregister_console(&nf_console); |
158 | tty_unregister_driver(nfcon_tty_driver); | 159 | tty_unregister_driver(nfcon_tty_driver); |
159 | put_tty_driver(nfcon_tty_driver); | 160 | put_tty_driver(nfcon_tty_driver); |
161 | tty_port_destroy(&nfcon_tty_port); | ||
160 | } | 162 | } |
161 | 163 | ||
162 | module_init(nfcon_init); | 164 | module_init(nfcon_init); |
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c index 88238638aee6..efc5e7d30530 100644 --- a/arch/parisc/kernel/pdc_cons.c +++ b/arch/parisc/kernel/pdc_cons.c | |||
@@ -186,13 +186,13 @@ static int __init pdc_console_tty_driver_init(void) | |||
186 | printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n"); | 186 | printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n"); |
187 | pdc_cons.flags &= ~CON_BOOT; | 187 | pdc_cons.flags &= ~CON_BOOT; |
188 | 188 | ||
189 | tty_port_init(&tty_port); | ||
190 | |||
191 | pdc_console_tty_driver = alloc_tty_driver(1); | 189 | pdc_console_tty_driver = alloc_tty_driver(1); |
192 | 190 | ||
193 | if (!pdc_console_tty_driver) | 191 | if (!pdc_console_tty_driver) |
194 | return -ENOMEM; | 192 | return -ENOMEM; |
195 | 193 | ||
194 | tty_port_init(&tty_port); | ||
195 | |||
196 | pdc_console_tty_driver->driver_name = "pdc_cons"; | 196 | pdc_console_tty_driver->driver_name = "pdc_cons"; |
197 | pdc_console_tty_driver->name = "ttyB"; | 197 | pdc_console_tty_driver->name = "ttyB"; |
198 | pdc_console_tty_driver->major = MUX_MAJOR; | 198 | pdc_console_tty_driver->major = MUX_MAJOR; |
@@ -207,6 +207,7 @@ static int __init pdc_console_tty_driver_init(void) | |||
207 | err = tty_register_driver(pdc_console_tty_driver); | 207 | err = tty_register_driver(pdc_console_tty_driver); |
208 | if (err) { | 208 | if (err) { |
209 | printk(KERN_ERR "Unable to register the PDC console TTY driver\n"); | 209 | printk(KERN_ERR "Unable to register the PDC console TTY driver\n"); |
210 | tty_port_destroy(&tty_port); | ||
210 | return err; | 211 | return err; |
211 | } | 212 | } |
212 | 213 | ||
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index fd9a15b318af..9ffc28bd4b7a 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c | |||
@@ -584,6 +584,8 @@ int register_lines(struct line_driver *line_driver, | |||
584 | printk(KERN_ERR "register_lines : can't register %s driver\n", | 584 | printk(KERN_ERR "register_lines : can't register %s driver\n", |
585 | line_driver->name); | 585 | line_driver->name); |
586 | put_tty_driver(driver); | 586 | put_tty_driver(driver); |
587 | for (i = 0; i < nlines; i++) | ||
588 | tty_port_destroy(&lines[i].port); | ||
587 | return err; | 589 | return err; |
588 | } | 590 | } |
589 | 591 | ||
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index 7e74895eee04..8207a119eee9 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c | |||
@@ -221,6 +221,7 @@ static __exit void rs_exit(void) | |||
221 | printk("ISS_SERIAL: failed to unregister serial driver (%d)\n", | 221 | printk("ISS_SERIAL: failed to unregister serial driver (%d)\n", |
222 | error); | 222 | error); |
223 | put_tty_driver(serial_driver); | 223 | put_tty_driver(serial_driver); |
224 | tty_port_destroy(&serial_port); | ||
224 | } | 225 | } |
225 | 226 | ||
226 | 227 | ||
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 21721d25e388..b66eaa04f8cb 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -549,8 +549,10 @@ static int mgslpc_probe(struct pcmcia_device *link) | |||
549 | /* Initialize the struct pcmcia_device structure */ | 549 | /* Initialize the struct pcmcia_device structure */ |
550 | 550 | ||
551 | ret = mgslpc_config(link); | 551 | ret = mgslpc_config(link); |
552 | if (ret) | 552 | if (ret) { |
553 | tty_port_destroy(&info->port); | ||
553 | return ret; | 554 | return ret; |
555 | } | ||
554 | 556 | ||
555 | mgslpc_add_device(info); | 557 | mgslpc_add_device(info); |
556 | 558 | ||
@@ -2757,6 +2759,7 @@ static void mgslpc_remove_device(MGSLPC_INFO *remove_info) | |||
2757 | hdlcdev_exit(info); | 2759 | hdlcdev_exit(info); |
2758 | #endif | 2760 | #endif |
2759 | release_resources(info); | 2761 | release_resources(info); |
2762 | tty_port_destroy(&info->port); | ||
2760 | kfree(info); | 2763 | kfree(info); |
2761 | mgslpc_device_count--; | 2764 | mgslpc_device_count--; |
2762 | return; | 2765 | return; |
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c index af98f6d6509b..4945bd3d18d0 100644 --- a/drivers/char/ttyprintk.c +++ b/drivers/char/ttyprintk.c | |||
@@ -179,7 +179,6 @@ static int __init ttyprintk_init(void) | |||
179 | { | 179 | { |
180 | int ret = -ENOMEM; | 180 | int ret = -ENOMEM; |
181 | 181 | ||
182 | tty_port_init(&tpk_port.port); | ||
183 | tpk_port.port.ops = &null_ops; | 182 | tpk_port.port.ops = &null_ops; |
184 | mutex_init(&tpk_port.port_write_mutex); | 183 | mutex_init(&tpk_port.port_write_mutex); |
185 | 184 | ||
@@ -190,6 +189,8 @@ static int __init ttyprintk_init(void) | |||
190 | if (IS_ERR(ttyprintk_driver)) | 189 | if (IS_ERR(ttyprintk_driver)) |
191 | return PTR_ERR(ttyprintk_driver); | 190 | return PTR_ERR(ttyprintk_driver); |
192 | 191 | ||
192 | tty_port_init(&tpk_port.port); | ||
193 | |||
193 | ttyprintk_driver->driver_name = "ttyprintk"; | 194 | ttyprintk_driver->driver_name = "ttyprintk"; |
194 | ttyprintk_driver->name = "ttyprintk"; | 195 | ttyprintk_driver->name = "ttyprintk"; |
195 | ttyprintk_driver->major = TTYAUX_MAJOR; | 196 | ttyprintk_driver->major = TTYAUX_MAJOR; |
@@ -211,6 +212,7 @@ static int __init ttyprintk_init(void) | |||
211 | error: | 212 | error: |
212 | tty_unregister_driver(ttyprintk_driver); | 213 | tty_unregister_driver(ttyprintk_driver); |
213 | put_tty_driver(ttyprintk_driver); | 214 | put_tty_driver(ttyprintk_driver); |
215 | tty_port_destroy(&tpk_port.port); | ||
214 | ttyprintk_driver = NULL; | 216 | ttyprintk_driver = NULL; |
215 | return ret; | 217 | return ret; |
216 | } | 218 | } |
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c index 30a6b174fbb0..bc9d89a8c4f6 100644 --- a/drivers/isdn/gigaset/common.c +++ b/drivers/isdn/gigaset/common.c | |||
@@ -518,6 +518,7 @@ f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]"); | |||
518 | kfree(cs->bcs); | 518 | kfree(cs->bcs); |
519 | f_cs: gig_dbg(DEBUG_INIT, "freeing cs"); | 519 | f_cs: gig_dbg(DEBUG_INIT, "freeing cs"); |
520 | mutex_unlock(&cs->mutex); | 520 | mutex_unlock(&cs->mutex); |
521 | tty_port_destroy(&cs->port); | ||
521 | free_cs(cs); | 522 | free_cs(cs); |
522 | } | 523 | } |
523 | EXPORT_SYMBOL_GPL(gigaset_freecs); | 524 | EXPORT_SYMBOL_GPL(gigaset_freecs); |
@@ -751,14 +752,14 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
751 | gig_dbg(DEBUG_INIT, "setting up iif"); | 752 | gig_dbg(DEBUG_INIT, "setting up iif"); |
752 | if (gigaset_isdn_regdev(cs, modulename) < 0) { | 753 | if (gigaset_isdn_regdev(cs, modulename) < 0) { |
753 | pr_err("error registering ISDN device\n"); | 754 | pr_err("error registering ISDN device\n"); |
754 | goto error; | 755 | goto error_port; |
755 | } | 756 | } |
756 | 757 | ||
757 | make_valid(cs, VALID_ID); | 758 | make_valid(cs, VALID_ID); |
758 | ++cs->cs_init; | 759 | ++cs->cs_init; |
759 | gig_dbg(DEBUG_INIT, "setting up hw"); | 760 | gig_dbg(DEBUG_INIT, "setting up hw"); |
760 | if (cs->ops->initcshw(cs) < 0) | 761 | if (cs->ops->initcshw(cs) < 0) |
761 | goto error; | 762 | goto error_port; |
762 | 763 | ||
763 | ++cs->cs_init; | 764 | ++cs->cs_init; |
764 | 765 | ||
@@ -773,7 +774,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
773 | gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i); | 774 | gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i); |
774 | if (gigaset_initbcs(cs->bcs + i, cs, i) < 0) { | 775 | if (gigaset_initbcs(cs->bcs + i, cs, i) < 0) { |
775 | pr_err("could not allocate channel %d data\n", i); | 776 | pr_err("could not allocate channel %d data\n", i); |
776 | goto error; | 777 | goto error_port; |
777 | } | 778 | } |
778 | } | 779 | } |
779 | 780 | ||
@@ -786,7 +787,8 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
786 | 787 | ||
787 | gig_dbg(DEBUG_INIT, "cs initialized"); | 788 | gig_dbg(DEBUG_INIT, "cs initialized"); |
788 | return cs; | 789 | return cs; |
789 | 790 | error_port: | |
791 | tty_port_destroy(&cs->port); | ||
790 | error: | 792 | error: |
791 | gig_dbg(DEBUG_INIT, "failed"); | 793 | gig_dbg(DEBUG_INIT, "failed"); |
792 | gigaset_freecs(cs); | 794 | gigaset_freecs(cs); |
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index b817809f763c..e09dc8a5e743 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c | |||
@@ -1849,6 +1849,8 @@ err_unregister: | |||
1849 | kfree(info->fax); | 1849 | kfree(info->fax); |
1850 | #endif | 1850 | #endif |
1851 | kfree(info->port.xmit_buf - 4); | 1851 | kfree(info->port.xmit_buf - 4); |
1852 | info->port.xmit_buf = NULL; | ||
1853 | tty_port_destroy(&info->port); | ||
1852 | } | 1854 | } |
1853 | tty_unregister_driver(m->tty_modem); | 1855 | tty_unregister_driver(m->tty_modem); |
1854 | err: | 1856 | err: |
@@ -1870,6 +1872,8 @@ isdn_tty_exit(void) | |||
1870 | kfree(info->fax); | 1872 | kfree(info->fax); |
1871 | #endif | 1873 | #endif |
1872 | kfree(info->port.xmit_buf - 4); | 1874 | kfree(info->port.xmit_buf - 4); |
1875 | info->port.xmit_buf = NULL; | ||
1876 | tty_port_destroy(&info->port); | ||
1873 | } | 1877 | } |
1874 | tty_unregister_driver(dev->mdm.tty_modem); | 1878 | tty_unregister_driver(dev->mdm.tty_modem); |
1875 | put_tty_driver(dev->mdm.tty_modem); | 1879 | put_tty_driver(dev->mdm.tty_modem); |
diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c index 4999b34b7a60..a1f0d174e687 100644 --- a/drivers/misc/pti.c +++ b/drivers/misc/pti.c | |||
@@ -882,11 +882,14 @@ err: | |||
882 | static void __devexit pti_pci_remove(struct pci_dev *pdev) | 882 | static void __devexit pti_pci_remove(struct pci_dev *pdev) |
883 | { | 883 | { |
884 | struct pti_dev *drv_data = pci_get_drvdata(pdev); | 884 | struct pti_dev *drv_data = pci_get_drvdata(pdev); |
885 | unsigned int a; | ||
885 | 886 | ||
886 | unregister_console(&pti_console); | 887 | unregister_console(&pti_console); |
887 | 888 | ||
888 | tty_unregister_device(pti_tty_driver, 0); | 889 | for (a = 0; a < PTITTY_MINOR_NUM; a++) { |
889 | tty_unregister_device(pti_tty_driver, 1); | 890 | tty_unregister_device(pti_tty_driver, a); |
891 | tty_port_destroy(&drv_data->port[a]); | ||
892 | } | ||
890 | 893 | ||
891 | iounmap(drv_data->pti_ioaddr); | 894 | iounmap(drv_data->pti_ioaddr); |
892 | pci_set_drvdata(pdev, NULL); | 895 | pci_set_drvdata(pdev, NULL); |
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 605a4baa9b7b..cd8ccb240f4b 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c | |||
@@ -2274,6 +2274,7 @@ static void hso_serial_common_free(struct hso_serial *serial) | |||
2274 | /* unlink and free TX URB */ | 2274 | /* unlink and free TX URB */ |
2275 | usb_free_urb(serial->tx_urb); | 2275 | usb_free_urb(serial->tx_urb); |
2276 | kfree(serial->tx_data); | 2276 | kfree(serial->tx_data); |
2277 | tty_port_destroy(&serial->port); | ||
2277 | } | 2278 | } |
2278 | 2279 | ||
2279 | static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, | 2280 | static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, |
@@ -2283,12 +2284,12 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, | |||
2283 | int minor; | 2284 | int minor; |
2284 | int i; | 2285 | int i; |
2285 | 2286 | ||
2287 | tty_port_init(&serial->port); | ||
2288 | |||
2286 | minor = get_free_serial_index(); | 2289 | minor = get_free_serial_index(); |
2287 | if (minor < 0) | 2290 | if (minor < 0) |
2288 | goto exit; | 2291 | goto exit; |
2289 | 2292 | ||
2290 | tty_port_init(&serial->port); | ||
2291 | |||
2292 | /* register our minor number */ | 2293 | /* register our minor number */ |
2293 | serial->parent->dev = tty_port_register_device(&serial->port, tty_drv, | 2294 | serial->parent->dev = tty_port_register_device(&serial->port, tty_drv, |
2294 | minor, &serial->parent->interface->dev); | 2295 | minor, &serial->parent->interface->dev); |
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 9ffb6d5f17aa..8fb014f32e4c 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c | |||
@@ -677,6 +677,7 @@ static void raw3215_free_info(struct raw3215_info *raw) | |||
677 | { | 677 | { |
678 | kfree(raw->inbuf); | 678 | kfree(raw->inbuf); |
679 | kfree(raw->buffer); | 679 | kfree(raw->buffer); |
680 | tty_port_destroy(&raw->port); | ||
680 | kfree(raw); | 681 | kfree(raw); |
681 | } | 682 | } |
682 | 683 | ||
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c index 30ec09e3d037..877fbc37c1e7 100644 --- a/drivers/s390/char/sclp_tty.c +++ b/drivers/s390/char/sclp_tty.c | |||
@@ -547,7 +547,6 @@ sclp_tty_init(void) | |||
547 | sclp_tty_tolower = 1; | 547 | sclp_tty_tolower = 1; |
548 | } | 548 | } |
549 | sclp_tty_chars_count = 0; | 549 | sclp_tty_chars_count = 0; |
550 | tty_port_init(&sclp_port); | ||
551 | 550 | ||
552 | rc = sclp_register(&sclp_input_event); | 551 | rc = sclp_register(&sclp_input_event); |
553 | if (rc) { | 552 | if (rc) { |
@@ -555,6 +554,8 @@ sclp_tty_init(void) | |||
555 | return rc; | 554 | return rc; |
556 | } | 555 | } |
557 | 556 | ||
557 | tty_port_init(&sclp_port); | ||
558 | |||
558 | driver->driver_name = "sclp_line"; | 559 | driver->driver_name = "sclp_line"; |
559 | driver->name = "sclp_line"; | 560 | driver->name = "sclp_line"; |
560 | driver->major = TTY_MAJOR; | 561 | driver->major = TTY_MAJOR; |
@@ -571,6 +572,7 @@ sclp_tty_init(void) | |||
571 | rc = tty_register_driver(driver); | 572 | rc = tty_register_driver(driver); |
572 | if (rc) { | 573 | if (rc) { |
573 | put_tty_driver(driver); | 574 | put_tty_driver(driver); |
575 | tty_port_destroy(&sclp_port); | ||
574 | return rc; | 576 | return rc; |
575 | } | 577 | } |
576 | sclp_tty_driver = driver; | 578 | sclp_tty_driver = driver; |
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index 7e60f3d2f3f9..effcc8756e0a 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c | |||
@@ -615,6 +615,7 @@ static void __init __sclp_vt220_cleanup(void) | |||
615 | return; | 615 | return; |
616 | sclp_unregister(&sclp_vt220_register); | 616 | sclp_unregister(&sclp_vt220_register); |
617 | __sclp_vt220_free_pages(); | 617 | __sclp_vt220_free_pages(); |
618 | tty_port_destroy(&sclp_vt220_port); | ||
618 | } | 619 | } |
619 | 620 | ||
620 | /* Allocate buffer pages and register with sclp core. Controlled by init | 621 | /* Allocate buffer pages and register with sclp core. Controlled by init |
@@ -650,6 +651,7 @@ out: | |||
650 | if (rc) { | 651 | if (rc) { |
651 | __sclp_vt220_free_pages(); | 652 | __sclp_vt220_free_pages(); |
652 | sclp_vt220_init_count--; | 653 | sclp_vt220_init_count--; |
654 | tty_port_destroy(&sclp_vt220_port); | ||
653 | } | 655 | } |
654 | return rc; | 656 | return rc; |
655 | } | 657 | } |
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c index 482ee028f842..43ea0593bdb0 100644 --- a/drivers/s390/char/tty3270.c +++ b/drivers/s390/char/tty3270.c | |||
@@ -722,6 +722,7 @@ out_pages: | |||
722 | while (pages--) | 722 | while (pages--) |
723 | free_pages((unsigned long) tp->freemem_pages[pages], 0); | 723 | free_pages((unsigned long) tp->freemem_pages[pages], 0); |
724 | kfree(tp->freemem_pages); | 724 | kfree(tp->freemem_pages); |
725 | tty_port_destroy(&tp->port); | ||
725 | out_tp: | 726 | out_tp: |
726 | kfree(tp); | 727 | kfree(tp); |
727 | out_err: | 728 | out_err: |
@@ -744,6 +745,7 @@ tty3270_free_view(struct tty3270 *tp) | |||
744 | for (pages = 0; pages < TTY3270_STRING_PAGES; pages++) | 745 | for (pages = 0; pages < TTY3270_STRING_PAGES; pages++) |
745 | free_pages((unsigned long) tp->freemem_pages[pages], 0); | 746 | free_pages((unsigned long) tp->freemem_pages[pages], 0); |
746 | kfree(tp->freemem_pages); | 747 | kfree(tp->freemem_pages); |
748 | tty_port_destroy(&tp->port); | ||
747 | kfree(tp); | 749 | kfree(tp); |
748 | } | 750 | } |
749 | 751 | ||
diff --git a/drivers/staging/ccg/u_serial.c b/drivers/staging/ccg/u_serial.c index 5b3f5fffea92..373c40656b52 100644 --- a/drivers/staging/ccg/u_serial.c +++ b/drivers/staging/ccg/u_serial.c | |||
@@ -1140,8 +1140,10 @@ int gserial_setup(struct usb_gadget *g, unsigned count) | |||
1140 | 1140 | ||
1141 | return status; | 1141 | return status; |
1142 | fail: | 1142 | fail: |
1143 | while (count--) | 1143 | while (count--) { |
1144 | tty_port_destroy(&ports[count].port->port); | ||
1144 | kfree(ports[count].port); | 1145 | kfree(ports[count].port); |
1146 | } | ||
1145 | put_tty_driver(gs_tty_driver); | 1147 | put_tty_driver(gs_tty_driver); |
1146 | gs_tty_driver = NULL; | 1148 | gs_tty_driver = NULL; |
1147 | return status; | 1149 | return status; |
@@ -1195,6 +1197,7 @@ void gserial_cleanup(void) | |||
1195 | 1197 | ||
1196 | WARN_ON(port->port_usb != NULL); | 1198 | WARN_ON(port->port_usb != NULL); |
1197 | 1199 | ||
1200 | tty_port_destroy(&port->port); | ||
1198 | kfree(port); | 1201 | kfree(port); |
1199 | } | 1202 | } |
1200 | n_ports = 0; | 1203 | n_ports = 0; |
diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index db91f676508a..c214078a89e9 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c | |||
@@ -752,6 +752,8 @@ static int dgrp_add_id(long id) | |||
752 | 752 | ||
753 | return 0; | 753 | return 0; |
754 | 754 | ||
755 | /* FIXME this guy should free the tty driver stored in nd and destroy | ||
756 | * all channel ports */ | ||
755 | error_out: | 757 | error_out: |
756 | kfree(nd); | 758 | kfree(nd); |
757 | return ret; | 759 | return ret; |
diff --git a/drivers/staging/dgrp/dgrp_tty.c b/drivers/staging/dgrp/dgrp_tty.c index e125b03598d7..0db4c0514f63 100644 --- a/drivers/staging/dgrp/dgrp_tty.c +++ b/drivers/staging/dgrp/dgrp_tty.c | |||
@@ -3119,6 +3119,7 @@ static void dgrp_tty_hangup(struct tty_struct *tty) | |||
3119 | void | 3119 | void |
3120 | dgrp_tty_uninit(struct nd_struct *nd) | 3120 | dgrp_tty_uninit(struct nd_struct *nd) |
3121 | { | 3121 | { |
3122 | unsigned int i; | ||
3122 | char id[3]; | 3123 | char id[3]; |
3123 | 3124 | ||
3124 | ID_TO_CHAR(nd->nd_ID, id); | 3125 | ID_TO_CHAR(nd->nd_ID, id); |
@@ -3152,6 +3153,8 @@ dgrp_tty_uninit(struct nd_struct *nd) | |||
3152 | put_tty_driver(nd->nd_xprint_ttdriver); | 3153 | put_tty_driver(nd->nd_xprint_ttdriver); |
3153 | nd->nd_ttdriver_flags &= ~XPRINT_TTDRV_REG; | 3154 | nd->nd_ttdriver_flags &= ~XPRINT_TTDRV_REG; |
3154 | } | 3155 | } |
3156 | for (i = 0; i < CHAN_MAX; i++) | ||
3157 | tty_port_destroy(&nd->nd_chan[i].port); | ||
3155 | } | 3158 | } |
3156 | 3159 | ||
3157 | 3160 | ||
@@ -3335,7 +3338,6 @@ dgrp_tty_init(struct nd_struct *nd) | |||
3335 | init_waitqueue_head(&(ch->ch_pun.un_open_wait)); | 3338 | init_waitqueue_head(&(ch->ch_pun.un_open_wait)); |
3336 | init_waitqueue_head(&(ch->ch_pun.un_close_wait)); | 3339 | init_waitqueue_head(&(ch->ch_pun.un_close_wait)); |
3337 | tty_port_init(&ch->port); | 3340 | tty_port_init(&ch->port); |
3338 | tty_port_init(&ch->port); | ||
3339 | } | 3341 | } |
3340 | return 0; | 3342 | return 0; |
3341 | } | 3343 | } |
diff --git a/drivers/staging/ipack/devices/ipoctal.c b/drivers/staging/ipack/devices/ipoctal.c index d751edfda839..729cb642840a 100644 --- a/drivers/staging/ipack/devices/ipoctal.c +++ b/drivers/staging/ipack/devices/ipoctal.c | |||
@@ -446,6 +446,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr, | |||
446 | tty_dev = tty_port_register_device(&channel->tty_port, tty, i, NULL); | 446 | tty_dev = tty_port_register_device(&channel->tty_port, tty, i, NULL); |
447 | if (IS_ERR(tty_dev)) { | 447 | if (IS_ERR(tty_dev)) { |
448 | dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n"); | 448 | dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n"); |
449 | tty_port_destroy(&channel->tty_port); | ||
449 | continue; | 450 | continue; |
450 | } | 451 | } |
451 | dev_set_drvdata(tty_dev, channel); | 452 | dev_set_drvdata(tty_dev, channel); |
@@ -741,6 +742,7 @@ static void __ipoctal_remove(struct ipoctal *ipoctal) | |||
741 | struct ipoctal_channel *channel = &ipoctal->channel[i]; | 742 | struct ipoctal_channel *channel = &ipoctal->channel[i]; |
742 | tty_unregister_device(ipoctal->tty_drv, i); | 743 | tty_unregister_device(ipoctal->tty_drv, i); |
743 | tty_port_free_xmit_buf(&channel->tty_port); | 744 | tty_port_free_xmit_buf(&channel->tty_port); |
745 | tty_port_destroy(&channel->tty_port); | ||
744 | } | 746 | } |
745 | 747 | ||
746 | tty_unregister_driver(ipoctal->tty_drv); | 748 | tty_unregister_driver(ipoctal->tty_drv); |
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 42d0a2581a87..9d7d00cdfecb 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c | |||
@@ -1771,6 +1771,7 @@ fail_free_irq: | |||
1771 | fail_unregister: | 1771 | fail_unregister: |
1772 | tty_unregister_driver(serial_driver); | 1772 | tty_unregister_driver(serial_driver); |
1773 | fail_put_tty_driver: | 1773 | fail_put_tty_driver: |
1774 | tty_port_destroy(&state->tport); | ||
1774 | put_tty_driver(serial_driver); | 1775 | put_tty_driver(serial_driver); |
1775 | return error; | 1776 | return error; |
1776 | } | 1777 | } |
@@ -1785,6 +1786,7 @@ static int __exit amiga_serial_remove(struct platform_device *pdev) | |||
1785 | printk("SERIAL: failed to unregister serial driver (%d)\n", | 1786 | printk("SERIAL: failed to unregister serial driver (%d)\n", |
1786 | error); | 1787 | error); |
1787 | put_tty_driver(serial_driver); | 1788 | put_tty_driver(serial_driver); |
1789 | tty_port_destroy(&state->tport); | ||
1788 | 1790 | ||
1789 | free_irq(IRQ_AMIGA_TBE, state); | 1791 | free_irq(IRQ_AMIGA_TBE, state); |
1790 | free_irq(IRQ_AMIGA_RBF, state); | 1792 | free_irq(IRQ_AMIGA_RBF, state); |
diff --git a/drivers/tty/bfin_jtag_comm.c b/drivers/tty/bfin_jtag_comm.c index 02b7d3a09696..1cfcdbf1d0cc 100644 --- a/drivers/tty/bfin_jtag_comm.c +++ b/drivers/tty/bfin_jtag_comm.c | |||
@@ -240,8 +240,6 @@ static int __init bfin_jc_init(void) | |||
240 | { | 240 | { |
241 | int ret; | 241 | int ret; |
242 | 242 | ||
243 | tty_port_init(&port); | ||
244 | |||
245 | bfin_jc_kthread = kthread_create(bfin_jc_emudat_manager, NULL, DRV_NAME); | 243 | bfin_jc_kthread = kthread_create(bfin_jc_emudat_manager, NULL, DRV_NAME); |
246 | if (IS_ERR(bfin_jc_kthread)) | 244 | if (IS_ERR(bfin_jc_kthread)) |
247 | return PTR_ERR(bfin_jc_kthread); | 245 | return PTR_ERR(bfin_jc_kthread); |
@@ -257,6 +255,8 @@ static int __init bfin_jc_init(void) | |||
257 | if (!bfin_jc_driver) | 255 | if (!bfin_jc_driver) |
258 | goto err_driver; | 256 | goto err_driver; |
259 | 257 | ||
258 | tty_port_init(&port); | ||
259 | |||
260 | bfin_jc_driver->driver_name = DRV_NAME; | 260 | bfin_jc_driver->driver_name = DRV_NAME; |
261 | bfin_jc_driver->name = DEV_NAME; | 261 | bfin_jc_driver->name = DEV_NAME; |
262 | bfin_jc_driver->type = TTY_DRIVER_TYPE_SERIAL; | 262 | bfin_jc_driver->type = TTY_DRIVER_TYPE_SERIAL; |
@@ -274,6 +274,7 @@ static int __init bfin_jc_init(void) | |||
274 | return 0; | 274 | return 0; |
275 | 275 | ||
276 | err: | 276 | err: |
277 | tty_port_destroy(&port); | ||
277 | put_tty_driver(bfin_jc_driver); | 278 | put_tty_driver(bfin_jc_driver); |
278 | err_driver: | 279 | err_driver: |
279 | kfree(bfin_jc_write_buf.buf); | 280 | kfree(bfin_jc_write_buf.buf); |
@@ -289,6 +290,7 @@ static void __exit bfin_jc_exit(void) | |||
289 | kfree(bfin_jc_write_buf.buf); | 290 | kfree(bfin_jc_write_buf.buf); |
290 | tty_unregister_driver(bfin_jc_driver); | 291 | tty_unregister_driver(bfin_jc_driver); |
291 | put_tty_driver(bfin_jc_driver); | 292 | put_tty_driver(bfin_jc_driver); |
293 | tty_port_destroy(&port); | ||
292 | } | 294 | } |
293 | module_exit(bfin_jc_exit); | 295 | module_exit(bfin_jc_exit); |
294 | 296 | ||
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c index 0a6a0bc1b598..de25774b5ec6 100644 --- a/drivers/tty/cyclades.c +++ b/drivers/tty/cyclades.c | |||
@@ -3934,7 +3934,7 @@ err: | |||
3934 | static void __devexit cy_pci_remove(struct pci_dev *pdev) | 3934 | static void __devexit cy_pci_remove(struct pci_dev *pdev) |
3935 | { | 3935 | { |
3936 | struct cyclades_card *cinfo = pci_get_drvdata(pdev); | 3936 | struct cyclades_card *cinfo = pci_get_drvdata(pdev); |
3937 | unsigned int i; | 3937 | unsigned int i, channel; |
3938 | 3938 | ||
3939 | /* non-Z with old PLX */ | 3939 | /* non-Z with old PLX */ |
3940 | if (!cy_is_Z(cinfo) && (readb(cinfo->base_addr + CyPLX_VER) & 0x0f) == | 3940 | if (!cy_is_Z(cinfo) && (readb(cinfo->base_addr + CyPLX_VER) & 0x0f) == |
@@ -3960,9 +3960,11 @@ static void __devexit cy_pci_remove(struct pci_dev *pdev) | |||
3960 | pci_release_regions(pdev); | 3960 | pci_release_regions(pdev); |
3961 | 3961 | ||
3962 | cinfo->base_addr = NULL; | 3962 | cinfo->base_addr = NULL; |
3963 | for (i = cinfo->first_line; i < cinfo->first_line + | 3963 | for (channel = 0, i = cinfo->first_line; i < cinfo->first_line + |
3964 | cinfo->nports; i++) | 3964 | cinfo->nports; i++, channel++) { |
3965 | tty_unregister_device(cy_serial_driver, i); | 3965 | tty_unregister_device(cy_serial_driver, i); |
3966 | tty_port_destroy(&cinfo->ports[channel].port); | ||
3967 | } | ||
3966 | cinfo->nports = 0; | 3968 | cinfo->nports = 0; |
3967 | kfree(cinfo->ports); | 3969 | kfree(cinfo->ports); |
3968 | } | 3970 | } |
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c index 4ab936b7aac6..4193afb74a02 100644 --- a/drivers/tty/ehv_bytechan.c +++ b/drivers/tty/ehv_bytechan.c | |||
@@ -757,6 +757,7 @@ static int __devinit ehv_bc_tty_probe(struct platform_device *pdev) | |||
757 | return 0; | 757 | return 0; |
758 | 758 | ||
759 | error: | 759 | error: |
760 | tty_port_destroy(&bc->port); | ||
760 | irq_dispose_mapping(bc->tx_irq); | 761 | irq_dispose_mapping(bc->tx_irq); |
761 | irq_dispose_mapping(bc->rx_irq); | 762 | irq_dispose_mapping(bc->rx_irq); |
762 | 763 | ||
@@ -770,6 +771,7 @@ static int ehv_bc_tty_remove(struct platform_device *pdev) | |||
770 | 771 | ||
771 | tty_unregister_device(ehv_bc_driver, bc - bcs); | 772 | tty_unregister_device(ehv_bc_driver, bc - bcs); |
772 | 773 | ||
774 | tty_port_destroy(&bc->port); | ||
773 | irq_dispose_mapping(bc->tx_irq); | 775 | irq_dispose_mapping(bc->tx_irq); |
774 | irq_dispose_mapping(bc->rx_irq); | 776 | irq_dispose_mapping(bc->rx_irq); |
775 | 777 | ||
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c index 5b95b4f28cf3..68357a6e4de9 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c | |||
@@ -1218,6 +1218,7 @@ static int __init hvsi_console_init(void) | |||
1218 | if (hp->virq == 0) { | 1218 | if (hp->virq == 0) { |
1219 | printk(KERN_ERR "%s: couldn't create irq mapping for 0x%x\n", | 1219 | printk(KERN_ERR "%s: couldn't create irq mapping for 0x%x\n", |
1220 | __func__, irq[0]); | 1220 | __func__, irq[0]); |
1221 | tty_port_destroy(&hp->port); | ||
1221 | continue; | 1222 | continue; |
1222 | } | 1223 | } |
1223 | 1224 | ||
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c index 160f0ad9589d..2cde13ddf9fc 100644 --- a/drivers/tty/ipwireless/tty.c +++ b/drivers/tty/ipwireless/tty.c | |||
@@ -566,6 +566,7 @@ void ipwireless_tty_free(struct ipw_tty *tty) | |||
566 | ipwireless_disassociate_network_ttys(network, | 566 | ipwireless_disassociate_network_ttys(network, |
567 | ttyj->channel_idx); | 567 | ttyj->channel_idx); |
568 | tty_unregister_device(ipw_tty_driver, j); | 568 | tty_unregister_device(ipw_tty_driver, j); |
569 | tty_port_destroy(&ttyj->port); | ||
569 | ttys[j] = NULL; | 570 | ttys[j] = NULL; |
570 | mutex_unlock(&ttyj->ipw_tty_mutex); | 571 | mutex_unlock(&ttyj->ipw_tty_mutex); |
571 | kfree(ttyj); | 572 | kfree(ttyj); |
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index 9b57aae139f6..d628176fb6d8 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c | |||
@@ -895,6 +895,8 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev) | |||
895 | 895 | ||
896 | return 0; | 896 | return 0; |
897 | err_free: | 897 | err_free: |
898 | for (i = 0; i < MAX_PORTS_PER_BOARD; i++) | ||
899 | tty_port_destroy(&brd->ports[i].port); | ||
898 | kfree(brd->ports); | 900 | kfree(brd->ports); |
899 | err: | 901 | err: |
900 | return ret; | 902 | return ret; |
@@ -919,6 +921,8 @@ static void moxa_board_deinit(struct moxa_board_conf *brd) | |||
919 | tty_kref_put(tty); | 921 | tty_kref_put(tty); |
920 | } | 922 | } |
921 | } | 923 | } |
924 | for (a = 0; a < MAX_PORTS_PER_BOARD; a++) | ||
925 | tty_port_destroy(&brd->ports[a].port); | ||
922 | while (1) { | 926 | while (1) { |
923 | opened = 0; | 927 | opened = 0; |
924 | for (a = 0; a < brd->numPorts; a++) | 928 | for (a = 0; a < brd->numPorts; a++) |
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index cfda47dabd28..802a248e7ab9 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c | |||
@@ -2411,14 +2411,27 @@ static int __devinit mxser_initbrd(struct mxser_board *brd, | |||
2411 | 2411 | ||
2412 | retval = request_irq(brd->irq, mxser_interrupt, IRQF_SHARED, "mxser", | 2412 | retval = request_irq(brd->irq, mxser_interrupt, IRQF_SHARED, "mxser", |
2413 | brd); | 2413 | brd); |
2414 | if (retval) | 2414 | if (retval) { |
2415 | for (i = 0; i < brd->info->nports; i++) | ||
2416 | tty_port_destroy(&brd->ports[i].port); | ||
2415 | printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may " | 2417 | printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may " |
2416 | "conflict with another device.\n", | 2418 | "conflict with another device.\n", |
2417 | brd->info->name, brd->irq); | 2419 | brd->info->name, brd->irq); |
2420 | } | ||
2418 | 2421 | ||
2419 | return retval; | 2422 | return retval; |
2420 | } | 2423 | } |
2421 | 2424 | ||
2425 | static void mxser_board_remove(struct mxser_board *brd) | ||
2426 | { | ||
2427 | unsigned int i; | ||
2428 | |||
2429 | for (i = 0; i < brd->info->nports; i++) { | ||
2430 | tty_unregister_device(mxvar_sdriver, brd->idx + i); | ||
2431 | tty_port_destroy(&brd->ports[i].port); | ||
2432 | } | ||
2433 | } | ||
2434 | |||
2422 | static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd) | 2435 | static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd) |
2423 | { | 2436 | { |
2424 | int id, i, bits, ret; | 2437 | int id, i, bits, ret; |
@@ -2649,10 +2662,8 @@ static void __devexit mxser_remove(struct pci_dev *pdev) | |||
2649 | { | 2662 | { |
2650 | #ifdef CONFIG_PCI | 2663 | #ifdef CONFIG_PCI |
2651 | struct mxser_board *brd = pci_get_drvdata(pdev); | 2664 | struct mxser_board *brd = pci_get_drvdata(pdev); |
2652 | unsigned int i; | ||
2653 | 2665 | ||
2654 | for (i = 0; i < brd->info->nports; i++) | 2666 | mxser_board_remove(brd); |
2655 | tty_unregister_device(mxvar_sdriver, brd->idx + i); | ||
2656 | 2667 | ||
2657 | free_irq(pdev->irq, brd); | 2668 | free_irq(pdev->irq, brd); |
2658 | pci_release_region(pdev, 2); | 2669 | pci_release_region(pdev, 2); |
@@ -2748,15 +2759,13 @@ err_put: | |||
2748 | 2759 | ||
2749 | static void __exit mxser_module_exit(void) | 2760 | static void __exit mxser_module_exit(void) |
2750 | { | 2761 | { |
2751 | unsigned int i, j; | 2762 | unsigned int i; |
2752 | 2763 | ||
2753 | pci_unregister_driver(&mxser_driver); | 2764 | pci_unregister_driver(&mxser_driver); |
2754 | 2765 | ||
2755 | for (i = 0; i < MXSER_BOARDS; i++) /* ISA remains */ | 2766 | for (i = 0; i < MXSER_BOARDS; i++) /* ISA remains */ |
2756 | if (mxser_boards[i].info != NULL) | 2767 | if (mxser_boards[i].info != NULL) |
2757 | for (j = 0; j < mxser_boards[i].info->nports; j++) | 2768 | mxser_board_remove(&mxser_boards[i]); |
2758 | tty_unregister_device(mxvar_sdriver, | ||
2759 | mxser_boards[i].idx + j); | ||
2760 | tty_unregister_driver(mxvar_sdriver); | 2769 | tty_unregister_driver(mxvar_sdriver); |
2761 | put_tty_driver(mxvar_sdriver); | 2770 | put_tty_driver(mxvar_sdriver); |
2762 | 2771 | ||
diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index b917c9424954..cb764d297756 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c | |||
@@ -1479,6 +1479,7 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev, | |||
1479 | if (IS_ERR(tty_dev)) { | 1479 | if (IS_ERR(tty_dev)) { |
1480 | ret = PTR_ERR(tty_dev); | 1480 | ret = PTR_ERR(tty_dev); |
1481 | dev_err(&pdev->dev, "Could not allocate tty?\n"); | 1481 | dev_err(&pdev->dev, "Could not allocate tty?\n"); |
1482 | tty_port_destroy(&port->port); | ||
1482 | goto err_free_tty; | 1483 | goto err_free_tty; |
1483 | } | 1484 | } |
1484 | } | 1485 | } |
@@ -1486,8 +1487,10 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev, | |||
1486 | return 0; | 1487 | return 0; |
1487 | 1488 | ||
1488 | err_free_tty: | 1489 | err_free_tty: |
1489 | for (i = dc->index_start; i < dc->index_start + MAX_PORT; ++i) | 1490 | for (i = 0; i < MAX_PORT; ++i) { |
1490 | tty_unregister_device(ntty_driver, i); | 1491 | tty_unregister_device(ntty_driver, dc->index_start + i); |
1492 | tty_port_destroy(&dc->port[i].port); | ||
1493 | } | ||
1491 | err_free_kfifo: | 1494 | err_free_kfifo: |
1492 | for (i = 0; i < MAX_PORT; i++) | 1495 | for (i = 0; i < MAX_PORT; i++) |
1493 | kfifo_free(&dc->port[i].fifo_ul); | 1496 | kfifo_free(&dc->port[i].fifo_ul); |
@@ -1520,8 +1523,10 @@ static void __devexit tty_exit(struct nozomi *dc) | |||
1520 | complete off a hangup method ? */ | 1523 | complete off a hangup method ? */ |
1521 | while (dc->open_ttys) | 1524 | while (dc->open_ttys) |
1522 | msleep(1); | 1525 | msleep(1); |
1523 | for (i = dc->index_start; i < dc->index_start + MAX_PORT; ++i) | 1526 | for (i = 0; i < MAX_PORT; ++i) { |
1524 | tty_unregister_device(ntty_driver, i); | 1527 | tty_unregister_device(ntty_driver, dc->index_start + i); |
1528 | tty_port_destroy(&dc->port[i].port); | ||
1529 | } | ||
1525 | } | 1530 | } |
1526 | 1531 | ||
1527 | /* Deallocate memory for one device */ | 1532 | /* Deallocate memory for one device */ |
diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c index 9700d34b20a3..d9056dac4ea1 100644 --- a/drivers/tty/rocket.c +++ b/drivers/tty/rocket.c | |||
@@ -673,6 +673,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) | |||
673 | if (sInitChan(ctlp, &info->channel, aiop, chan) == 0) { | 673 | if (sInitChan(ctlp, &info->channel, aiop, chan) == 0) { |
674 | printk(KERN_ERR "RocketPort sInitChan(%d, %d, %d) failed!\n", | 674 | printk(KERN_ERR "RocketPort sInitChan(%d, %d, %d) failed!\n", |
675 | board, aiop, chan); | 675 | board, aiop, chan); |
676 | tty_port_destroy(&info->port); | ||
676 | kfree(info); | 677 | kfree(info); |
677 | return; | 678 | return; |
678 | } | 679 | } |
@@ -2357,6 +2358,7 @@ static void rp_cleanup_module(void) | |||
2357 | for (i = 0; i < MAX_RP_PORTS; i++) | 2358 | for (i = 0; i < MAX_RP_PORTS; i++) |
2358 | if (rp_table[i]) { | 2359 | if (rp_table[i]) { |
2359 | tty_unregister_device(rocket_driver, i); | 2360 | tty_unregister_device(rocket_driver, i); |
2361 | tty_port_destroy(&rp_table[i]->port); | ||
2360 | kfree(rp_table[i]); | 2362 | kfree(rp_table[i]); |
2361 | } | 2363 | } |
2362 | 2364 | ||
diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c index 66c38a3f74ce..f99a84526f82 100644 --- a/drivers/tty/serial/68328serial.c +++ b/drivers/tty/serial/68328serial.c | |||
@@ -1225,6 +1225,8 @@ rs68328_init(void) | |||
1225 | 1225 | ||
1226 | if (tty_register_driver(serial_driver)) { | 1226 | if (tty_register_driver(serial_driver)) { |
1227 | put_tty_driver(serial_driver); | 1227 | put_tty_driver(serial_driver); |
1228 | for (i = 0; i < NR_PORTS; i++) | ||
1229 | tty_port_destroy(&m68k_soft[i].tport); | ||
1228 | printk(KERN_ERR "Couldn't register serial driver\n"); | 1230 | printk(KERN_ERR "Couldn't register serial driver\n"); |
1229 | return -ENOMEM; | 1231 | return -ENOMEM; |
1230 | } | 1232 | } |
diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c index 1754c147a94c..91125bb151cf 100644 --- a/drivers/tty/serial/ifx6x60.c +++ b/drivers/tty/serial/ifx6x60.c | |||
@@ -829,6 +829,7 @@ static void ifx_spi_free_port(struct ifx_spi_device *ifx_dev) | |||
829 | { | 829 | { |
830 | if (ifx_dev->tty_dev) | 830 | if (ifx_dev->tty_dev) |
831 | tty_unregister_device(tty_drv, ifx_dev->minor); | 831 | tty_unregister_device(tty_drv, ifx_dev->minor); |
832 | tty_port_destroy(&ifx_dev->tty_port); | ||
832 | kfifo_free(&ifx_dev->tx_fifo); | 833 | kfifo_free(&ifx_dev->tx_fifo); |
833 | } | 834 | } |
834 | 835 | ||
@@ -862,10 +863,12 @@ static int ifx_spi_create_port(struct ifx_spi_device *ifx_dev) | |||
862 | dev_dbg(&ifx_dev->spi_dev->dev, | 863 | dev_dbg(&ifx_dev->spi_dev->dev, |
863 | "%s: registering tty device failed", __func__); | 864 | "%s: registering tty device failed", __func__); |
864 | ret = PTR_ERR(ifx_dev->tty_dev); | 865 | ret = PTR_ERR(ifx_dev->tty_dev); |
865 | goto error_ret; | 866 | goto error_port; |
866 | } | 867 | } |
867 | return 0; | 868 | return 0; |
868 | 869 | ||
870 | error_port: | ||
871 | tty_port_destroy(pport); | ||
869 | error_ret: | 872 | error_ret: |
870 | ifx_spi_free_port(ifx_dev); | 873 | ifx_spi_free_port(ifx_dev); |
871 | return ret; | 874 | return ret; |
diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index d185247ba1aa..6ac2b797a764 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c | |||
@@ -266,6 +266,7 @@ static int kgdb_nmi_tty_install(struct tty_driver *drv, struct tty_struct *tty) | |||
266 | } | 266 | } |
267 | return 0; | 267 | return 0; |
268 | err: | 268 | err: |
269 | tty_port_destroy(&priv->port); | ||
269 | kfree(priv); | 270 | kfree(priv); |
270 | return ret; | 271 | return ret; |
271 | } | 272 | } |
@@ -275,6 +276,7 @@ static void kgdb_nmi_tty_cleanup(struct tty_struct *tty) | |||
275 | struct kgdb_nmi_tty_priv *priv = tty->driver_data; | 276 | struct kgdb_nmi_tty_priv *priv = tty->driver_data; |
276 | 277 | ||
277 | tty->driver_data = NULL; | 278 | tty->driver_data = NULL; |
279 | tty_port_destroy(&priv->port); | ||
278 | kfree(priv); | 280 | kfree(priv); |
279 | } | 281 | } |
280 | 282 | ||
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 63b33889d515..61ba24089ef7 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c | |||
@@ -2297,6 +2297,8 @@ int uart_register_driver(struct uart_driver *drv) | |||
2297 | if (retval >= 0) | 2297 | if (retval >= 0) |
2298 | return retval; | 2298 | return retval; |
2299 | 2299 | ||
2300 | for (i = 0; i < drv->nr; i++) | ||
2301 | tty_port_destroy(&drv->state[i].port); | ||
2300 | put_tty_driver(normal); | 2302 | put_tty_driver(normal); |
2301 | out_kfree: | 2303 | out_kfree: |
2302 | kfree(drv->state); | 2304 | kfree(drv->state); |
@@ -2316,8 +2318,12 @@ out: | |||
2316 | void uart_unregister_driver(struct uart_driver *drv) | 2318 | void uart_unregister_driver(struct uart_driver *drv) |
2317 | { | 2319 | { |
2318 | struct tty_driver *p = drv->tty_driver; | 2320 | struct tty_driver *p = drv->tty_driver; |
2321 | unsigned int i; | ||
2322 | |||
2319 | tty_unregister_driver(p); | 2323 | tty_unregister_driver(p); |
2320 | put_tty_driver(p); | 2324 | put_tty_driver(p); |
2325 | for (i = 0; i < drv->nr; i++) | ||
2326 | tty_port_destroy(&drv->state[i].port); | ||
2321 | kfree(drv->state); | 2327 | kfree(drv->state); |
2322 | drv->state = NULL; | 2328 | drv->state = NULL; |
2323 | drv->tty_driver = NULL; | 2329 | drv->tty_driver = NULL; |
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index 70e3a525bc82..e4b5c39fc4ec 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c | |||
@@ -4425,6 +4425,7 @@ static void synclink_cleanup(void) | |||
4425 | mgsl_release_resources(info); | 4425 | mgsl_release_resources(info); |
4426 | tmp = info; | 4426 | tmp = info; |
4427 | info = info->next_device; | 4427 | info = info->next_device; |
4428 | tty_port_destroy(&tmp->port); | ||
4428 | kfree(tmp); | 4429 | kfree(tmp); |
4429 | } | 4430 | } |
4430 | 4431 | ||
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index b38e954eedd3..6e4c34011b7e 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c | |||
@@ -3645,8 +3645,10 @@ static void device_init(int adapter_num, struct pci_dev *pdev) | |||
3645 | for (i=0; i < port_count; ++i) { | 3645 | for (i=0; i < port_count; ++i) { |
3646 | port_array[i] = alloc_dev(adapter_num, i, pdev); | 3646 | port_array[i] = alloc_dev(adapter_num, i, pdev); |
3647 | if (port_array[i] == NULL) { | 3647 | if (port_array[i] == NULL) { |
3648 | for (--i; i >= 0; --i) | 3648 | for (--i; i >= 0; --i) { |
3649 | tty_port_destroy(&port_array[i]->port); | ||
3649 | kfree(port_array[i]); | 3650 | kfree(port_array[i]); |
3651 | } | ||
3650 | return; | 3652 | return; |
3651 | } | 3653 | } |
3652 | } | 3654 | } |
@@ -3773,6 +3775,7 @@ static void slgt_cleanup(void) | |||
3773 | release_resources(info); | 3775 | release_resources(info); |
3774 | tmp = info; | 3776 | tmp = info; |
3775 | info = info->next_device; | 3777 | info = info->next_device; |
3778 | tty_port_destroy(&tmp->port); | ||
3776 | kfree(tmp); | 3779 | kfree(tmp); |
3777 | } | 3780 | } |
3778 | 3781 | ||
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index f17d9f3d84a2..40745beb2585 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c | |||
@@ -3843,8 +3843,10 @@ static void device_init(int adapter_num, struct pci_dev *pdev) | |||
3843 | for ( port = 0; port < SCA_MAX_PORTS; ++port ) { | 3843 | for ( port = 0; port < SCA_MAX_PORTS; ++port ) { |
3844 | port_array[port] = alloc_dev(adapter_num,port,pdev); | 3844 | port_array[port] = alloc_dev(adapter_num,port,pdev); |
3845 | if( port_array[port] == NULL ) { | 3845 | if( port_array[port] == NULL ) { |
3846 | for ( --port; port >= 0; --port ) | 3846 | for (--port; port >= 0; --port) { |
3847 | tty_port_destroy(&port_array[port]->port); | ||
3847 | kfree(port_array[port]); | 3848 | kfree(port_array[port]); |
3849 | } | ||
3848 | return; | 3850 | return; |
3849 | } | 3851 | } |
3850 | } | 3852 | } |
@@ -3953,6 +3955,7 @@ static void synclinkmp_cleanup(void) | |||
3953 | } | 3955 | } |
3954 | tmp = info; | 3956 | tmp = info; |
3955 | info = info->next_device; | 3957 | info = info->next_device; |
3958 | tty_port_destroy(&tmp->port); | ||
3956 | kfree(tmp); | 3959 | kfree(tmp); |
3957 | } | 3960 | } |
3958 | 3961 | ||
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index f87d7e8964bf..607636b4734d 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c | |||
@@ -779,6 +779,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ | |||
779 | con_set_default_unimap(vc); | 779 | con_set_default_unimap(vc); |
780 | vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); | 780 | vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); |
781 | if (!vc->vc_screenbuf) { | 781 | if (!vc->vc_screenbuf) { |
782 | tty_port_destroy(&vc->port); | ||
782 | kfree(vc); | 783 | kfree(vc); |
783 | vc_cons[currcons].d = NULL; | 784 | vc_cons[currcons].d = NULL; |
784 | return -ENOMEM; | 785 | return -ENOMEM; |
@@ -999,8 +1000,10 @@ void vc_deallocate(unsigned int currcons) | |||
999 | put_pid(vc->vt_pid); | 1000 | put_pid(vc->vt_pid); |
1000 | module_put(vc->vc_sw->owner); | 1001 | module_put(vc->vc_sw->owner); |
1001 | kfree(vc->vc_screenbuf); | 1002 | kfree(vc->vc_screenbuf); |
1002 | if (currcons >= MIN_NR_CONSOLES) | 1003 | if (currcons >= MIN_NR_CONSOLES) { |
1004 | tty_port_destroy(&vc->port); | ||
1003 | kfree(vc); | 1005 | kfree(vc); |
1006 | } | ||
1004 | vc_cons[currcons].d = NULL; | 1007 | vc_cons[currcons].d = NULL; |
1005 | } | 1008 | } |
1006 | } | 1009 | } |
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c index f1739526820f..d0f95482f40e 100644 --- a/drivers/usb/gadget/u_serial.c +++ b/drivers/usb/gadget/u_serial.c | |||
@@ -1145,8 +1145,10 @@ int gserial_setup(struct usb_gadget *g, unsigned count) | |||
1145 | 1145 | ||
1146 | return status; | 1146 | return status; |
1147 | fail: | 1147 | fail: |
1148 | while (count--) | 1148 | while (count--) { |
1149 | tty_port_destroy(&ports[count].port->port); | ||
1149 | kfree(ports[count].port); | 1150 | kfree(ports[count].port); |
1151 | } | ||
1150 | put_tty_driver(gs_tty_driver); | 1152 | put_tty_driver(gs_tty_driver); |
1151 | gs_tty_driver = NULL; | 1153 | gs_tty_driver = NULL; |
1152 | return status; | 1154 | return status; |
@@ -1200,6 +1202,7 @@ void gserial_cleanup(void) | |||
1200 | 1202 | ||
1201 | WARN_ON(port->port_usb != NULL); | 1203 | WARN_ON(port->port_usb != NULL); |
1202 | 1204 | ||
1205 | tty_port_destroy(&port->port); | ||
1203 | kfree(port); | 1206 | kfree(port); |
1204 | } | 1207 | } |
1205 | n_ports = 0; | 1208 | n_ports = 0; |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 73b8e0569164..64bda135ba7e 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -597,6 +597,7 @@ static void port_release(struct device *dev) | |||
597 | kfifo_free(&port->write_fifo); | 597 | kfifo_free(&port->write_fifo); |
598 | kfree(port->interrupt_in_buffer); | 598 | kfree(port->interrupt_in_buffer); |
599 | kfree(port->interrupt_out_buffer); | 599 | kfree(port->interrupt_out_buffer); |
600 | tty_port_destroy(&port->port); | ||
600 | kfree(port); | 601 | kfree(port); |
601 | } | 602 | } |
602 | 603 | ||
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 496ce2cebcd7..a68c88cdec6e 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c | |||
@@ -183,6 +183,7 @@ static void __exit __ircomm_tty_cleanup(struct ircomm_tty_cb *self) | |||
183 | ircomm_tty_shutdown(self); | 183 | ircomm_tty_shutdown(self); |
184 | 184 | ||
185 | self->magic = 0; | 185 | self->magic = 0; |
186 | tty_port_destroy(&self->port); | ||
186 | kfree(self); | 187 | kfree(self); |
187 | } | 188 | } |
188 | 189 | ||