mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-21 03:33:59 +08:00
TTY: moxa, convert to dynamic device
This allows us to provide the tty layer with information about tty_port for each link. We also provide a tty_port for the service port. For this one we allow only ioctl, so this is pretty ugly. 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>
This commit is contained in:
parent
cc93441eed
commit
793be8984f
@ -169,6 +169,7 @@ static DEFINE_SPINLOCK(moxa_lock);
|
||||
static unsigned long baseaddr[MAX_BOARDS];
|
||||
static unsigned int type[MAX_BOARDS];
|
||||
static unsigned int numports[MAX_BOARDS];
|
||||
static struct tty_port moxa_service_port;
|
||||
|
||||
MODULE_AUTHOR("William Chen");
|
||||
MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver");
|
||||
@ -834,7 +835,7 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
|
||||
const struct firmware *fw;
|
||||
const char *file;
|
||||
struct moxa_port *p;
|
||||
unsigned int i;
|
||||
unsigned int i, first_idx;
|
||||
int ret;
|
||||
|
||||
brd->ports = kcalloc(MAX_PORTS_PER_BOARD, sizeof(*brd->ports),
|
||||
@ -887,6 +888,11 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
|
||||
mod_timer(&moxaTimer, jiffies + HZ / 50);
|
||||
spin_unlock_bh(&moxa_lock);
|
||||
|
||||
first_idx = (brd - moxa_boards) * MAX_PORTS_PER_BOARD;
|
||||
for (i = 0; i < brd->numPorts; i++)
|
||||
tty_port_register_device(&brd->ports[i].port, moxaDriver,
|
||||
first_idx + i, dev);
|
||||
|
||||
return 0;
|
||||
err_free:
|
||||
kfree(brd->ports);
|
||||
@ -896,7 +902,7 @@ err:
|
||||
|
||||
static void moxa_board_deinit(struct moxa_board_conf *brd)
|
||||
{
|
||||
unsigned int a, opened;
|
||||
unsigned int a, opened, first_idx;
|
||||
|
||||
mutex_lock(&moxa_openlock);
|
||||
spin_lock_bh(&moxa_lock);
|
||||
@ -925,6 +931,10 @@ static void moxa_board_deinit(struct moxa_board_conf *brd)
|
||||
mutex_lock(&moxa_openlock);
|
||||
}
|
||||
|
||||
first_idx = (brd - moxa_boards) * MAX_PORTS_PER_BOARD;
|
||||
for (a = 0; a < brd->numPorts; a++)
|
||||
tty_unregister_device(moxaDriver, first_idx + a);
|
||||
|
||||
iounmap(brd->basemem);
|
||||
brd->basemem = NULL;
|
||||
kfree(brd->ports);
|
||||
@ -1031,7 +1041,12 @@ static int __init moxa_init(void)
|
||||
|
||||
printk(KERN_INFO "MOXA Intellio family driver version %s\n",
|
||||
MOXA_VERSION);
|
||||
moxaDriver = alloc_tty_driver(MAX_PORTS + 1);
|
||||
|
||||
tty_port_init(&moxa_service_port);
|
||||
|
||||
moxaDriver = tty_alloc_driver(MAX_PORTS + 1,
|
||||
TTY_DRIVER_REAL_RAW |
|
||||
TTY_DRIVER_DYNAMIC_DEV);
|
||||
if (!moxaDriver)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -1044,8 +1059,9 @@ static int __init moxa_init(void)
|
||||
moxaDriver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
|
||||
moxaDriver->init_termios.c_ispeed = 9600;
|
||||
moxaDriver->init_termios.c_ospeed = 9600;
|
||||
moxaDriver->flags = TTY_DRIVER_REAL_RAW;
|
||||
tty_set_operations(moxaDriver, &moxa_ops);
|
||||
/* Having one more port only for ioctls is ugly */
|
||||
tty_port_link_device(&moxa_service_port, moxaDriver, MAX_PORTS);
|
||||
|
||||
if (tty_register_driver(moxaDriver)) {
|
||||
printk(KERN_ERR "can't register MOXA Smartio tty driver!\n");
|
||||
|
Loading…
Reference in New Issue
Block a user