TTY: use tty_port_register_device
authorJiri Slaby <jslaby@suse.cz>
Tue, 7 Aug 2012 19:47:47 +0000 (21:47 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Aug 2012 23:50:19 +0000 (16:50 -0700)
Currently we have no way to assign tty->port while performing tty
installation. There are two ways to provide the link tty_struct =>
tty_port. Either by calling tty_port_install from tty->ops->install or
tty_port_register_device called instead of tty_register_device when
the device is being set up after connected.

In this patch we modify most of the drivers to do the latter. When the
drivers use tty_register_device and we have tty_port already, we
switch to tty_port_register_device. So we have the tty_struct =>
tty_port link for free for those.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 files changed:
arch/um/drivers/line.c
drivers/isdn/capi/capi.c
drivers/isdn/gigaset/interface.c
drivers/mmc/card/sdio_uart.c
drivers/net/usb/hso.c
drivers/staging/ipack/devices/ipoctal.c
drivers/tty/cyclades.c
drivers/tty/ehv_bytechan.c
drivers/tty/ipwireless/tty.c
drivers/tty/isicom.c
drivers/tty/mxser.c
drivers/tty/nozomi.c
drivers/tty/rocket.c
drivers/tty/serial/ifx6x60.c
drivers/tty/serial/msm_smd_tty.c
drivers/tty/serial/serial_core.c
drivers/tty/synclink_gt.c
drivers/usb/class/cdc-acm.c
drivers/usb/gadget/u_serial.c
net/bluetooth/rfcomm/tty.c

index bbaf2c59830ac3561c432d8ac23d6f64bf62dd79..457475f98414392ece09be3dcfbf0578c31f1215 100644 (file)
@@ -409,7 +409,8 @@ int setup_one_line(struct line *lines, int n, char *init,
                line->valid = 1;
                err = parse_chan_pair(new, line, n, opts, error_out);
                if (!err) {
-                       struct device *d = tty_register_device(driver, n, NULL);
+                       struct device *d = tty_port_register_device(&line->port,
+                                       driver, n, NULL);
                        if (IS_ERR(d)) {
                                *error_out = "Failed to register device";
                                err = PTR_ERR(d);
index 38c4bd87b2c98a2b0bfc45692823e8d62c8ca1b3..c679867c2ccd3f37682ef75def8481588dfbec9a 100644 (file)
@@ -234,7 +234,8 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)
 
        mp->minor = minor;
 
-       dev = tty_register_device(capinc_tty_driver, minor, NULL);
+       dev = tty_port_register_device(&mp->port, capinc_tty_driver, minor,
+                       NULL);
        if (IS_ERR(dev))
                goto err_out2;
 
index f9aab7490868e76e5ec126d3ff1121bfe857b764..67abf3ff45e812eec6ce416a917cacec5a650b39 100644 (file)
@@ -524,7 +524,8 @@ void gigaset_if_init(struct cardstate *cs)
        tasklet_init(&cs->if_wake_tasklet, if_wake, (unsigned long) cs);
 
        mutex_lock(&cs->mutex);
-       cs->tty_dev = tty_register_device(drv->tty, cs->minor_index, NULL);
+       cs->tty_dev = tty_port_register_device(&cs->port, drv->tty,
+                       cs->minor_index, NULL);
 
        if (!IS_ERR(cs->tty_dev))
                dev_set_drvdata(cs->tty_dev, cs);
index 372c0325c1494f09ea564fe88d719eecbdec9a3b..d2339ea378152070ce8496e25f1dc15f0cbe9f14 100644 (file)
@@ -1132,8 +1132,8 @@ static int sdio_uart_probe(struct sdio_func *func,
                kfree(port);
        } else {
                struct device *dev;
-               dev = tty_register_device(sdio_uart_tty_driver,
-                                               port->index, &func->dev);
+               dev = tty_port_register_device(&port->port,
+                               sdio_uart_tty_driver, port->index, &func->dev);
                if (IS_ERR(dev)) {
                        sdio_uart_port_remove(port);
                        ret = PTR_ERR(dev);
index 7736af75e12bd0b4670c97f71856ffdf000a5d52..605a4baa9b7b89083e27c5a5d8b76ef938959dd4 100644 (file)
@@ -2287,9 +2287,11 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
        if (minor < 0)
                goto exit;
 
+       tty_port_init(&serial->port);
+
        /* register our minor number */
-       serial->parent->dev = tty_register_device(tty_drv, minor,
-                                       &serial->parent->interface->dev);
+       serial->parent->dev = tty_port_register_device(&serial->port, tty_drv,
+                       minor, &serial->parent->interface->dev);
        dev = serial->parent->dev;
        dev_set_drvdata(dev, serial->parent);
        i = device_create_file(dev, &dev_attr_hsotype);
@@ -2298,7 +2300,6 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
        serial->minor = minor;
        serial->magic = HSO_SERIAL_MAGIC;
        spin_lock_init(&serial->serial_lock);
-       tty_port_init(&serial->port);
        serial->num_rx_urbs = num_urbs;
 
        /* RX, allocate urb and initialize */
index 394f5deca34e17995e9d802b1e28be14c3349366..a68d981c259fe6eb517d85df0667f7d9cad7c96a 100644 (file)
@@ -502,7 +502,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
                ipoctal->pointer_read[i] = 0;
                ipoctal->pointer_write[i] = 0;
                ipoctal->nb_bytes[i] = 0;
-               tty_register_device(tty, i, NULL);
+               tty_port_register_device(&ipoctal->tty_port[i], tty, i, NULL);
 
                /*
                 * Enable again the RX. TX will be enabled when
index c8850ea832af3ae2c9231ece5e853f1fd8f36d25..e3954dae50641026943b8497f7eae8a357a54350 100644 (file)
@@ -3289,7 +3289,7 @@ static int __init cy_detect_isa(void)
        struct cyclades_card *card;
        unsigned short cy_isa_irq, nboard;
        void __iomem *cy_isa_address;
-       unsigned short i, j, cy_isa_nchan;
+       unsigned short i, j, k, cy_isa_nchan;
        int isparam = 0;
 
        nboard = 0;
@@ -3392,9 +3392,10 @@ static int __init cy_detect_isa(void)
                        (unsigned long)(cy_isa_address + (CyISA_Ywin - 1)),
                        cy_isa_irq, cy_isa_nchan, cy_next_channel);
 
-               for (j = cy_next_channel;
-                               j < cy_next_channel + cy_isa_nchan; j++)
-                       tty_register_device(cy_serial_driver, j, NULL);
+               for (k = 0, j = cy_next_channel;
+                               j < cy_next_channel + cy_isa_nchan; j++, k++)
+                       tty_port_register_device(&card->ports[k].port,
+                                       cy_serial_driver, j, NULL);
                cy_next_channel += cy_isa_nchan;
        }
        return nboard;
@@ -3698,7 +3699,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
        void __iomem *addr0 = NULL, *addr2 = NULL;
        char *card_name = NULL;
        u32 uninitialized_var(mailbox);
-       unsigned int device_id, nchan = 0, card_no, i;
+       unsigned int device_id, nchan = 0, card_no, i, j;
        unsigned char plx_ver;
        int retval, irq;
 
@@ -3909,8 +3910,9 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
 
        dev_info(&pdev->dev, "%s/PCI #%d found: %d channels starting from "
                "port %d.\n", card_name, card_no + 1, nchan, cy_next_channel);
-       for (i = cy_next_channel; i < cy_next_channel + nchan; i++)
-               tty_register_device(cy_serial_driver, i, &pdev->dev);
+       for (j = 0, i = cy_next_channel; i < cy_next_channel + nchan; i++, j++)
+               tty_port_register_device(&card->ports[j].port,
+                               cy_serial_driver, i, &pdev->dev);
        cy_next_channel += nchan;
 
        return 0;
index 4813684cb634ed2c7cf5fae1f0dc4b946426a099..4ab936b7aac66d342f726b37d58844462fbc142d 100644 (file)
@@ -738,16 +738,17 @@ static int __devinit ehv_bc_tty_probe(struct platform_device *pdev)
                goto error;
        }
 
-       bc->dev = tty_register_device(ehv_bc_driver, i, &pdev->dev);
+       tty_port_init(&bc->port);
+       bc->port.ops = &ehv_bc_tty_port_ops;
+
+       bc->dev = tty_port_register_device(&bc->port, ehv_bc_driver, i,
+                       &pdev->dev);
        if (IS_ERR(bc->dev)) {
                ret = PTR_ERR(bc->dev);
                dev_err(&pdev->dev, "could not register tty (ret=%i)\n", ret);
                goto error;
        }
 
-       tty_port_init(&bc->port);
-       bc->port.ops = &ehv_bc_tty_port_ops;
-
        dev_set_drvdata(&pdev->dev, bc);
 
        dev_info(&pdev->dev, "registered /dev/%s%u for byte channel %u\n",
index f8b5fa0093a3bf3a9f74c3f4b7662a05d89ee547..160f0ad9589d2a17071b9de8f3e6739a022b843f 100644 (file)
@@ -476,7 +476,7 @@ static int add_tty(int j,
        mutex_init(&ttys[j]->ipw_tty_mutex);
        tty_port_init(&ttys[j]->port);
 
-       tty_register_device(ipw_tty_driver, j, NULL);
+       tty_port_register_device(&ttys[j]->port, ipw_tty_driver, j, NULL);
        ipwireless_associate_network_tty(network, channel_idx, ttys[j]);
 
        if (secondary_channel_idx != -1)
index d593a7d18ad5f462ee7c00ad022ee3b4b2b399da..99cf22e5f2b6634bcf809ccecf37e463b4c620ab 100644 (file)
@@ -1611,7 +1611,8 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
                goto errunri;
 
        for (index = 0; index < board->port_count; index++)
-               tty_register_device(isicom_normal, board->index * 16 + index,
+               tty_port_register_device(&board->ports[index].port,
+                               isicom_normal, board->index * 16 + index,
                                &pdev->dev);
 
        return 0;
index e64fe40618cd90b0b83beb18c78c551460374810..8bc265154ad7977605d391d652410ee854fcc788 100644 (file)
@@ -2625,7 +2625,8 @@ static int __devinit mxser_probe(struct pci_dev *pdev,
                goto err_rel3;
 
        for (i = 0; i < brd->info->nports; i++)
-               tty_register_device(mxvar_sdriver, brd->idx + i, &pdev->dev);
+               tty_port_register_device(&brd->ports[i].port, mxvar_sdriver,
+                               brd->idx + i, &pdev->dev);
 
        pci_set_drvdata(pdev, brd);
 
@@ -2722,7 +2723,8 @@ static int __init mxser_module_init(void)
 
                brd->idx = m * MXSER_PORTS_PER_BOARD;
                for (i = 0; i < brd->info->nports; i++)
-                       tty_register_device(mxvar_sdriver, brd->idx + i, NULL);
+                       tty_port_register_device(&brd->ports[i].port,
+                                       mxvar_sdriver, brd->idx + i, NULL);
 
                m++;
        }
index e7592f9037daca81455e9b94d7c31d62fdc5c934..b917c942495474dd91c3f600979537a396e6897b 100644 (file)
@@ -1473,8 +1473,8 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
                port->dc = dc;
                tty_port_init(&port->port);
                port->port.ops = &noz_tty_port_ops;
-               tty_dev = tty_register_device(ntty_driver, dc->index_start + i,
-                                                       &pdev->dev);
+               tty_dev = tty_port_register_device(&port->port, ntty_driver,
+                               dc->index_start + i, &pdev->dev);
 
                if (IS_ERR(tty_dev)) {
                        ret = PTR_ERR(tty_dev);
index 016984a460e0c968a5f3e305341d69e36b28715b..9700d34b20a3182794d5f6a4ab5eef8ed050321d 100644 (file)
@@ -704,8 +704,8 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
        spin_lock_init(&info->slock);
        mutex_init(&info->write_mtx);
        rp_table[line] = info;
-       tty_register_device(rocket_driver, line, pci_dev ? &pci_dev->dev :
-                       NULL);
+       tty_port_register_device(&info->port, rocket_driver, line,
+                       pci_dev ? &pci_dev->dev : NULL);
 }
 
 /*
index 144cd3987d4cb5c6c108d0488a41a0e1ba8eca73..3f0c256d8ef786ec64a22ba9a1fe72c797185e4d 100644 (file)
@@ -800,8 +800,8 @@ static int ifx_spi_create_port(struct ifx_spi_device *ifx_dev)
        tty_port_init(pport);
        pport->ops = &ifx_tty_port_ops;
        ifx_dev->minor = IFX_SPI_TTY_ID;
-       ifx_dev->tty_dev = tty_register_device(tty_drv, ifx_dev->minor,
-                                              &ifx_dev->spi_dev->dev);
+       ifx_dev->tty_dev = tty_port_register_device(pport, tty_drv,
+                       ifx_dev->minor, &ifx_dev->spi_dev->dev);
        if (IS_ERR(ifx_dev->tty_dev)) {
                dev_dbg(&ifx_dev->spi_dev->dev,
                        "%s: registering tty device failed", __func__);
index b25e6ee7144374e258b646608a41978f1d2f1a3b..925d1fa153db328a3d75a45583cfe6415a11f0af 100644 (file)
@@ -223,9 +223,11 @@ static int __init smd_tty_init(void)
                return ret;
 
        for (i = 0; i < smd_tty_channels_len; i++) {
-               tty_port_init(&smd_tty[smd_tty_channels[i].id].port);
-               smd_tty[smd_tty_channels[i].id].port.ops = &smd_tty_port_ops;
-               tty_register_device(smd_tty_driver, smd_tty_channels[i].id, 0);
+               struct tty_port *port = &smd_tty[smd_tty_channels[i].id].port;
+               tty_port_init(port);
+               port->ops = &smd_tty_port_ops;
+               tty_port_register_device(port, smd_tty_driver,
+                               smd_tty_channels[i].id, NULL);
        }
 
        return 0;
index d98b1bd407f6f1e84420cf8b99813858d0e2db12..5b308c87b68cb8124f04593874123bfd968bfc36 100644 (file)
@@ -2346,7 +2346,8 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
         * Register the port whether it's detected or not.  This allows
         * setserial to be used to alter this ports parameters.
         */
-       tty_dev = tty_register_device(drv->tty_driver, uport->line, uport->dev);
+       tty_dev = tty_port_register_device(port, drv->tty_driver, uport->line,
+                       uport->dev);
        if (likely(!IS_ERR(tty_dev))) {
                device_set_wakeup_capable(tty_dev, 1);
        } else {
index 913025369fe783a4eb388400e31c6ce6d981d86e..45f6136f4e51eb58c91b91455c7292d78e39463d 100644 (file)
@@ -3689,8 +3689,11 @@ static void device_init(int adapter_num, struct pci_dev *pdev)
                }
        }
 
-       for (i=0; i < port_count; ++i)
-               tty_register_device(serial_driver, port_array[i]->line, &(port_array[i]->pdev->dev));
+       for (i = 0; i < port_count; ++i) {
+               struct slgt_info *info = port_array[i];
+               tty_port_register_device(&info->port, serial_driver, info->line,
+                               &info->pdev->dev);
+       }
 }
 
 static int __devinit init_one(struct pci_dev *dev,
index 18f4e62aaa75863b817d94842caf99f00fa2b069..455ef1649231b21fe6e2c092d0d312fde9286f0c 100644 (file)
@@ -1298,7 +1298,8 @@ skip_countries:
        usb_set_intfdata(data_interface, acm);
 
        usb_get_intf(control_interface);
-       tty_register_device(acm_tty_driver, minor, &control_interface->dev);
+       tty_port_register_device(&acm->port, acm_tty_driver, minor,
+                       &control_interface->dev);
 
        return 0;
 alloc_fail7:
index 5b3f5fffea92d241b50587b885c24bf69f83e878..2b5534c2ab8446bbb69b92ffe36c0c80b32ee77c 100644 (file)
@@ -1129,7 +1129,8 @@ int gserial_setup(struct usb_gadget *g, unsigned count)
        for (i = 0; i < count; i++) {
                struct device   *tty_dev;
 
-               tty_dev = tty_register_device(gs_tty_driver, i, &g->dev);
+               tty_dev = tty_port_register_device(&ports[i].port->port,
+                               gs_tty_driver, i, &g->dev);
                if (IS_ERR(tty_dev))
                        pr_warning("%s: no classdev for port %d, err %ld\n",
                                __func__, i, PTR_ERR(tty_dev));
index b54c86a2e66bdfa045c6e65cfd7f7c244fdccefa..18a80b94a8bdc4b413004a74bcbe5b3c93cb096e 100644 (file)
@@ -278,8 +278,8 @@ out:
        if (err < 0)
                goto free;
 
-       dev->tty_dev = tty_register_device(rfcomm_tty_driver, dev->id, NULL);
-
+       dev->tty_dev = tty_port_register_device(&dev->port, rfcomm_tty_driver,
+                       dev->id, NULL);
        if (IS_ERR(dev->tty_dev)) {
                err = PTR_ERR(dev->tty_dev);
                list_del(&dev->list);