|
52 | 52 | #include <net/irda/ircomm_tty_attach.h> |
53 | 53 | #include <net/irda/ircomm_tty.h> |
54 | 54 |
|
| 55 | +static int ircomm_tty_install(struct tty_driver *driver, |
| 56 | + struct tty_struct *tty); |
55 | 57 | static int ircomm_tty_open(struct tty_struct *tty, struct file *filp); |
56 | 58 | static void ircomm_tty_close(struct tty_struct * tty, struct file *filp); |
57 | 59 | static int ircomm_tty_write(struct tty_struct * tty, |
@@ -82,6 +84,7 @@ static struct tty_driver *driver; |
82 | 84 | static hashbin_t *ircomm_tty = NULL; |
83 | 85 |
|
84 | 86 | static const struct tty_operations ops = { |
| 87 | + .install = ircomm_tty_install, |
85 | 88 | .open = ircomm_tty_open, |
86 | 89 | .close = ircomm_tty_close, |
87 | 90 | .write = ircomm_tty_write, |
@@ -374,21 +377,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, |
374 | 377 | return retval; |
375 | 378 | } |
376 | 379 |
|
377 | | -/* |
378 | | - * Function ircomm_tty_open (tty, filp) |
379 | | - * |
380 | | - * This routine is called when a particular tty device is opened. This |
381 | | - * routine is mandatory; if this routine is not filled in, the attempted |
382 | | - * open will fail with ENODEV. |
383 | | - */ |
384 | | -static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) |
| 380 | + |
| 381 | +static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty) |
385 | 382 | { |
386 | 383 | struct ircomm_tty_cb *self; |
387 | 384 | unsigned int line = tty->index; |
388 | | - unsigned long flags; |
389 | | - int ret; |
390 | | - |
391 | | - IRDA_DEBUG(2, "%s()\n", __func__ ); |
392 | 385 |
|
393 | 386 | /* Check if instance already exists */ |
394 | 387 | self = hashbin_lock_find(ircomm_tty, line, NULL); |
@@ -425,14 +418,30 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) |
425 | 418 | tty->termios.c_oflag = 0; |
426 | 419 |
|
427 | 420 | /* Insert into hash */ |
428 | | - /* FIXME there is a window from find to here */ |
429 | 421 | hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL); |
430 | 422 | } |
| 423 | + |
| 424 | + return tty_port_install(&self->port, driver, tty); |
| 425 | +} |
| 426 | + |
| 427 | +/* |
| 428 | + * Function ircomm_tty_open (tty, filp) |
| 429 | + * |
| 430 | + * This routine is called when a particular tty device is opened. This |
| 431 | + * routine is mandatory; if this routine is not filled in, the attempted |
| 432 | + * open will fail with ENODEV. |
| 433 | + */ |
| 434 | +static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) |
| 435 | +{ |
| 436 | + struct ircomm_tty_cb *self = tty->driver_data; |
| 437 | + unsigned long flags; |
| 438 | + int ret; |
| 439 | + |
| 440 | + IRDA_DEBUG(2, "%s()\n", __func__ ); |
| 441 | + |
431 | 442 | /* ++ is not atomic, so this should be protected - Jean II */ |
432 | 443 | spin_lock_irqsave(&self->port.lock, flags); |
433 | 444 | self->port.count++; |
434 | | - |
435 | | - tty->driver_data = self; |
436 | 445 | spin_unlock_irqrestore(&self->port.lock, flags); |
437 | 446 | tty_port_tty_set(&self->port, tty); |
438 | 447 |
|
@@ -472,7 +481,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) |
472 | 481 | } |
473 | 482 |
|
474 | 483 | /* Check if this is a "normal" ircomm device, or an irlpt device */ |
475 | | - if (line < 0x10) { |
| 484 | + if (self->line < 0x10) { |
476 | 485 | self->service_type = IRCOMM_3_WIRE | IRCOMM_9_WIRE; |
477 | 486 | self->settings.service_type = IRCOMM_9_WIRE; /* 9 wire as default */ |
478 | 487 | /* Jan Kiszka -> add DSR/RI -> Conform to IrCOMM spec */ |
|
0 commit comments