1
0
Fork 0

TTY: synclink_cs, use dynamic tty devices

This allows us to provide the tty layer with information about
tty_port for each link. And it also allows us to get rid of the
remove_device loop in synclink_cs_exit because we had to reorder
pcmcia and tty driver registration in init. This was because we need
to have serial_driver initialized when calling
tty_port_register_device from pcmcia ->probe.

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>
hifive-unleashed-5.1
Jiri Slaby 2012-08-07 21:47:53 +02:00 committed by Greg Kroah-Hartman
parent 737586fe51
commit 16a1065f21
1 changed files with 15 additions and 12 deletions

View File

@ -2731,6 +2731,8 @@ static void mgslpc_add_device(MGSLPC_INFO *info)
#if SYNCLINK_GENERIC_HDLC #if SYNCLINK_GENERIC_HDLC
hdlcdev_init(info); hdlcdev_init(info);
#endif #endif
tty_port_register_device(&info->port, serial_driver, info->line,
&info->p_dev.dev);
} }
static void mgslpc_remove_device(MGSLPC_INFO *remove_info) static void mgslpc_remove_device(MGSLPC_INFO *remove_info)
@ -2744,6 +2746,7 @@ static void mgslpc_remove_device(MGSLPC_INFO *remove_info)
last->next_device = info->next_device; last->next_device = info->next_device;
else else
mgslpc_device_list = info->next_device; mgslpc_device_list = info->next_device;
tty_unregister_device(serial_driver, info->line);
#if SYNCLINK_GENERIC_HDLC #if SYNCLINK_GENERIC_HDLC
hdlcdev_exit(info); hdlcdev_exit(info);
#endif #endif
@ -2807,13 +2810,12 @@ static int __init synclink_cs_init(void)
BREAKPOINT(); BREAKPOINT();
} }
if ((rc = pcmcia_register_driver(&mgslpc_driver)) < 0) serial_driver = tty_alloc_driver(MAX_DEVICE_COUNT,
return rc; TTY_DRIVER_REAL_RAW |
TTY_DRIVER_DYNAMIC_DEV);
serial_driver = alloc_tty_driver(MAX_DEVICE_COUNT);
if (!serial_driver) { if (!serial_driver) {
rc = -ENOMEM; rc = -ENOMEM;
goto err_pcmcia_drv; goto err;
} }
/* Initialize the tty_driver structure */ /* Initialize the tty_driver structure */
@ -2827,7 +2829,6 @@ static int __init synclink_cs_init(void)
serial_driver->init_termios = tty_std_termios; serial_driver->init_termios = tty_std_termios;
serial_driver->init_termios.c_cflag = serial_driver->init_termios.c_cflag =
B9600 | CS8 | CREAD | HUPCL | CLOCAL; B9600 | CS8 | CREAD | HUPCL | CLOCAL;
serial_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(serial_driver, &mgslpc_ops); tty_set_operations(serial_driver, &mgslpc_ops);
if ((rc = tty_register_driver(serial_driver)) < 0) { if ((rc = tty_register_driver(serial_driver)) < 0) {
@ -2836,26 +2837,28 @@ static int __init synclink_cs_init(void)
goto err_put_tty; goto err_put_tty;
} }
rc = pcmcia_register_driver(&mgslpc_driver);
if (rc < 0)
goto err_unreg_tty;
printk("%s %s, tty major#%d\n", printk("%s %s, tty major#%d\n",
driver_name, driver_version, driver_name, driver_version,
serial_driver->major); serial_driver->major);
return 0; return 0;
err_unreg_tty:
tty_unregister_driver(serial_driver);
err_put_tty: err_put_tty:
put_tty_driver(serial_driver); put_tty_driver(serial_driver);
err_pcmcia_drv: err:
pcmcia_unregister_driver(&mgslpc_driver);
return rc; return rc;
} }
static void __exit synclink_cs_exit(void) static void __exit synclink_cs_exit(void)
{ {
while (mgslpc_device_list) pcmcia_unregister_driver(&mgslpc_driver);
mgslpc_remove_device(mgslpc_device_list);
tty_unregister_driver(serial_driver); tty_unregister_driver(serial_driver);
put_tty_driver(serial_driver); put_tty_driver(serial_driver);
pcmcia_unregister_driver(&mgslpc_driver);
} }
module_init(synclink_cs_init); module_init(synclink_cs_init);