Commit 734cc178 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: use tty_port_register_device

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: default avatarJiri Slaby <jslaby@suse.cz>
Acked-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7e73eca6
...@@ -409,7 +409,8 @@ int setup_one_line(struct line *lines, int n, char *init, ...@@ -409,7 +409,8 @@ int setup_one_line(struct line *lines, int n, char *init,
line->valid = 1; line->valid = 1;
err = parse_chan_pair(new, line, n, opts, error_out); err = parse_chan_pair(new, line, n, opts, error_out);
if (!err) { 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)) { if (IS_ERR(d)) {
*error_out = "Failed to register device"; *error_out = "Failed to register device";
err = PTR_ERR(d); err = PTR_ERR(d);
......
...@@ -234,7 +234,8 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci) ...@@ -234,7 +234,8 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)
mp->minor = minor; 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)) if (IS_ERR(dev))
goto err_out2; goto err_out2;
......
...@@ -524,7 +524,8 @@ void gigaset_if_init(struct cardstate *cs) ...@@ -524,7 +524,8 @@ void gigaset_if_init(struct cardstate *cs)
tasklet_init(&cs->if_wake_tasklet, if_wake, (unsigned long) cs); tasklet_init(&cs->if_wake_tasklet, if_wake, (unsigned long) cs);
mutex_lock(&cs->mutex); 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)) if (!IS_ERR(cs->tty_dev))
dev_set_drvdata(cs->tty_dev, cs); dev_set_drvdata(cs->tty_dev, cs);
......
...@@ -1132,8 +1132,8 @@ static int sdio_uart_probe(struct sdio_func *func, ...@@ -1132,8 +1132,8 @@ static int sdio_uart_probe(struct sdio_func *func,
kfree(port); kfree(port);
} else { } else {
struct device *dev; struct device *dev;
dev = tty_register_device(sdio_uart_tty_driver, dev = tty_port_register_device(&port->port,
port->index, &func->dev); sdio_uart_tty_driver, port->index, &func->dev);
if (IS_ERR(dev)) { if (IS_ERR(dev)) {
sdio_uart_port_remove(port); sdio_uart_port_remove(port);
ret = PTR_ERR(dev); ret = PTR_ERR(dev);
......
...@@ -2287,9 +2287,11 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, ...@@ -2287,9 +2287,11 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
if (minor < 0) if (minor < 0)
goto exit; goto exit;
tty_port_init(&serial->port);
/* register our minor number */ /* register our minor number */
serial->parent->dev = tty_register_device(tty_drv, minor, serial->parent->dev = tty_port_register_device(&serial->port, tty_drv,
&serial->parent->interface->dev); minor, &serial->parent->interface->dev);
dev = serial->parent->dev; dev = serial->parent->dev;
dev_set_drvdata(dev, serial->parent); dev_set_drvdata(dev, serial->parent);
i = device_create_file(dev, &dev_attr_hsotype); 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, ...@@ -2298,7 +2300,6 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
serial->minor = minor; serial->minor = minor;
serial->magic = HSO_SERIAL_MAGIC; serial->magic = HSO_SERIAL_MAGIC;
spin_lock_init(&serial->serial_lock); spin_lock_init(&serial->serial_lock);
tty_port_init(&serial->port);
serial->num_rx_urbs = num_urbs; serial->num_rx_urbs = num_urbs;
/* RX, allocate urb and initialize */ /* RX, allocate urb and initialize */
......
...@@ -502,7 +502,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr, ...@@ -502,7 +502,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
ipoctal->pointer_read[i] = 0; ipoctal->pointer_read[i] = 0;
ipoctal->pointer_write[i] = 0; ipoctal->pointer_write[i] = 0;
ipoctal->nb_bytes[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 * Enable again the RX. TX will be enabled when
......
...@@ -3289,7 +3289,7 @@ static int __init cy_detect_isa(void) ...@@ -3289,7 +3289,7 @@ static int __init cy_detect_isa(void)
struct cyclades_card *card; struct cyclades_card *card;
unsigned short cy_isa_irq, nboard; unsigned short cy_isa_irq, nboard;
void __iomem *cy_isa_address; void __iomem *cy_isa_address;
unsigned short i, j, cy_isa_nchan; unsigned short i, j, k, cy_isa_nchan;
int isparam = 0; int isparam = 0;
nboard = 0; nboard = 0;
...@@ -3392,9 +3392,10 @@ static int __init cy_detect_isa(void) ...@@ -3392,9 +3392,10 @@ static int __init cy_detect_isa(void)
(unsigned long)(cy_isa_address + (CyISA_Ywin - 1)), (unsigned long)(cy_isa_address + (CyISA_Ywin - 1)),
cy_isa_irq, cy_isa_nchan, cy_next_channel); cy_isa_irq, cy_isa_nchan, cy_next_channel);
for (j = cy_next_channel; for (k = 0, j = cy_next_channel;
j < cy_next_channel + cy_isa_nchan; j++) j < cy_next_channel + cy_isa_nchan; j++, k++)
tty_register_device(cy_serial_driver, j, NULL); tty_port_register_device(&card->ports[k].port,
cy_serial_driver, j, NULL);
cy_next_channel += cy_isa_nchan; cy_next_channel += cy_isa_nchan;
} }
return nboard; return nboard;
...@@ -3698,7 +3699,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, ...@@ -3698,7 +3699,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
void __iomem *addr0 = NULL, *addr2 = NULL; void __iomem *addr0 = NULL, *addr2 = NULL;
char *card_name = NULL; char *card_name = NULL;
u32 uninitialized_var(mailbox); 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; unsigned char plx_ver;
int retval, irq; int retval, irq;
...@@ -3909,8 +3910,9 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, ...@@ -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 " dev_info(&pdev->dev, "%s/PCI #%d found: %d channels starting from "
"port %d.\n", card_name, card_no + 1, nchan, cy_next_channel); "port %d.\n", card_name, card_no + 1, nchan, cy_next_channel);
for (i = cy_next_channel; i < cy_next_channel + nchan; i++) for (j = 0, i = cy_next_channel; i < cy_next_channel + nchan; i++, j++)
tty_register_device(cy_serial_driver, i, &pdev->dev); tty_port_register_device(&card->ports[j].port,
cy_serial_driver, i, &pdev->dev);
cy_next_channel += nchan; cy_next_channel += nchan;
return 0; return 0;
......
...@@ -738,16 +738,17 @@ static int __devinit ehv_bc_tty_probe(struct platform_device *pdev) ...@@ -738,16 +738,17 @@ static int __devinit ehv_bc_tty_probe(struct platform_device *pdev)
goto error; 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)) { if (IS_ERR(bc->dev)) {
ret = PTR_ERR(bc->dev); ret = PTR_ERR(bc->dev);
dev_err(&pdev->dev, "could not register tty (ret=%i)\n", ret); dev_err(&pdev->dev, "could not register tty (ret=%i)\n", ret);
goto error; goto error;
} }
tty_port_init(&bc->port);
bc->port.ops = &ehv_bc_tty_port_ops;
dev_set_drvdata(&pdev->dev, bc); dev_set_drvdata(&pdev->dev, bc);
dev_info(&pdev->dev, "registered /dev/%s%u for byte channel %u\n", dev_info(&pdev->dev, "registered /dev/%s%u for byte channel %u\n",
......
...@@ -476,7 +476,7 @@ static int add_tty(int j, ...@@ -476,7 +476,7 @@ static int add_tty(int j,
mutex_init(&ttys[j]->ipw_tty_mutex); mutex_init(&ttys[j]->ipw_tty_mutex);
tty_port_init(&ttys[j]->port); 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]); ipwireless_associate_network_tty(network, channel_idx, ttys[j]);
if (secondary_channel_idx != -1) if (secondary_channel_idx != -1)
......
...@@ -1611,7 +1611,8 @@ static int __devinit isicom_probe(struct pci_dev *pdev, ...@@ -1611,7 +1611,8 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
goto errunri; goto errunri;
for (index = 0; index < board->port_count; index++) 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); &pdev->dev);
return 0; return 0;
......
...@@ -2625,7 +2625,8 @@ static int __devinit mxser_probe(struct pci_dev *pdev, ...@@ -2625,7 +2625,8 @@ static int __devinit mxser_probe(struct pci_dev *pdev,
goto err_rel3; goto err_rel3;
for (i = 0; i < brd->info->nports; i++) 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); pci_set_drvdata(pdev, brd);
...@@ -2722,7 +2723,8 @@ static int __init mxser_module_init(void) ...@@ -2722,7 +2723,8 @@ static int __init mxser_module_init(void)
brd->idx = m * MXSER_PORTS_PER_BOARD; brd->idx = m * MXSER_PORTS_PER_BOARD;
for (i = 0; i < brd->info->nports; i++) 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++; m++;
} }
......
...@@ -1473,8 +1473,8 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev, ...@@ -1473,8 +1473,8 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
port->dc = dc; port->dc = dc;
tty_port_init(&port->port); tty_port_init(&port->port);
port->port.ops = &noz_tty_port_ops; port->port.ops = &noz_tty_port_ops;
tty_dev = tty_register_device(ntty_driver, dc->index_start + i, tty_dev = tty_port_register_device(&port->port, ntty_driver,
&pdev->dev); dc->index_start + i, &pdev->dev);
if (IS_ERR(tty_dev)) { if (IS_ERR(tty_dev)) {
ret = PTR_ERR(tty_dev); ret = PTR_ERR(tty_dev);
......
...@@ -704,8 +704,8 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) ...@@ -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); spin_lock_init(&info->slock);
mutex_init(&info->write_mtx); mutex_init(&info->write_mtx);
rp_table[line] = info; rp_table[line] = info;
tty_register_device(rocket_driver, line, pci_dev ? &pci_dev->dev : tty_port_register_device(&info->port, rocket_driver, line,
NULL); pci_dev ? &pci_dev->dev : NULL);
} }
/* /*
......
...@@ -800,8 +800,8 @@ static int ifx_spi_create_port(struct ifx_spi_device *ifx_dev) ...@@ -800,8 +800,8 @@ static int ifx_spi_create_port(struct ifx_spi_device *ifx_dev)
tty_port_init(pport); tty_port_init(pport);
pport->ops = &ifx_tty_port_ops; pport->ops = &ifx_tty_port_ops;
ifx_dev->minor = IFX_SPI_TTY_ID; ifx_dev->minor = IFX_SPI_TTY_ID;
ifx_dev->tty_dev = tty_register_device(tty_drv, ifx_dev->minor, ifx_dev->tty_dev = tty_port_register_device(pport, tty_drv,
&ifx_dev->spi_dev->dev); ifx_dev->minor, &ifx_dev->spi_dev->dev);
if (IS_ERR(ifx_dev->tty_dev)) { if (IS_ERR(ifx_dev->tty_dev)) {
dev_dbg(&ifx_dev->spi_dev->dev, dev_dbg(&ifx_dev->spi_dev->dev,
"%s: registering tty device failed", __func__); "%s: registering tty device failed", __func__);
......
...@@ -223,9 +223,11 @@ static int __init smd_tty_init(void) ...@@ -223,9 +223,11 @@ static int __init smd_tty_init(void)
return ret; return ret;
for (i = 0; i < smd_tty_channels_len; i++) { for (i = 0; i < smd_tty_channels_len; i++) {
tty_port_init(&smd_tty[smd_tty_channels[i].id].port); struct tty_port *port = &smd_tty[smd_tty_channels[i].id].port;
smd_tty[smd_tty_channels[i].id].port.ops = &smd_tty_port_ops; tty_port_init(port);
tty_register_device(smd_tty_driver, smd_tty_channels[i].id, 0); port->ops = &smd_tty_port_ops;
tty_port_register_device(port, smd_tty_driver,
smd_tty_channels[i].id, NULL);
} }
return 0; return 0;
......
...@@ -2346,7 +2346,8 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport) ...@@ -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 * Register the port whether it's detected or not. This allows
* setserial to be used to alter this ports parameters. * 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))) { if (likely(!IS_ERR(tty_dev))) {
device_set_wakeup_capable(tty_dev, 1); device_set_wakeup_capable(tty_dev, 1);
} else { } else {
......
...@@ -3689,8 +3689,11 @@ static void device_init(int adapter_num, struct pci_dev *pdev) ...@@ -3689,8 +3689,11 @@ static void device_init(int adapter_num, struct pci_dev *pdev)
} }
} }
for (i=0; i < port_count; ++i) for (i = 0; i < port_count; ++i) {
tty_register_device(serial_driver, port_array[i]->line, &(port_array[i]->pdev->dev)); 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, static int __devinit init_one(struct pci_dev *dev,
......
...@@ -1298,7 +1298,8 @@ static int acm_probe(struct usb_interface *intf, ...@@ -1298,7 +1298,8 @@ static int acm_probe(struct usb_interface *intf,
usb_set_intfdata(data_interface, acm); usb_set_intfdata(data_interface, acm);
usb_get_intf(control_interface); 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; return 0;
alloc_fail7: alloc_fail7:
......
...@@ -1129,7 +1129,8 @@ int gserial_setup(struct usb_gadget *g, unsigned count) ...@@ -1129,7 +1129,8 @@ int gserial_setup(struct usb_gadget *g, unsigned count)
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
struct device *tty_dev; 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)) if (IS_ERR(tty_dev))
pr_warning("%s: no classdev for port %d, err %ld\n", pr_warning("%s: no classdev for port %d, err %ld\n",
__func__, i, PTR_ERR(tty_dev)); __func__, i, PTR_ERR(tty_dev));
......
...@@ -278,8 +278,8 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) ...@@ -278,8 +278,8 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
if (err < 0) if (err < 0)
goto free; 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)) { if (IS_ERR(dev->tty_dev)) {
err = PTR_ERR(dev->tty_dev); err = PTR_ERR(dev->tty_dev);
list_del(&dev->list); list_del(&dev->list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment