Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 325662
b: refs/heads/master
c: 793be89
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Slaby authored and Greg Kroah-Hartman committed Aug 13, 2012
1 parent 012aea5 commit 8c4bce9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cc93441eed0d39af9d99ba1642b9f733b195435c
refs/heads/master: 793be8984fb979ae8887609862842cbb1f60bfaf
24 changes: 20 additions & 4 deletions trunk/drivers/tty/moxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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);
Expand All @@ -896,7 +902,7 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)

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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand All @@ -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");
Expand Down

0 comments on commit 8c4bce9

Please sign in to comment.