Skip to content

Commit 9c650ff

Browse files
Jiri Slabygregkh
authored andcommitted
TTY: ircomm_tty, add tty install
This has two outcomes: * we give the TTY layer a tty_port * we do not find the info structure every time open is called on that tty Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Samuel Ortiz <samuel@sortiz.org> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ee3b48d commit 9c650ff

1 file changed

Lines changed: 25 additions & 16 deletions

File tree

‎net/irda/ircomm/ircomm_tty.c‎

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
#include <net/irda/ircomm_tty_attach.h>
5353
#include <net/irda/ircomm_tty.h>
5454

55+
static int ircomm_tty_install(struct tty_driver *driver,
56+
struct tty_struct *tty);
5557
static int ircomm_tty_open(struct tty_struct *tty, struct file *filp);
5658
static void ircomm_tty_close(struct tty_struct * tty, struct file *filp);
5759
static int ircomm_tty_write(struct tty_struct * tty,
@@ -82,6 +84,7 @@ static struct tty_driver *driver;
8284
static hashbin_t *ircomm_tty = NULL;
8385

8486
static const struct tty_operations ops = {
87+
.install = ircomm_tty_install,
8588
.open = ircomm_tty_open,
8689
.close = ircomm_tty_close,
8790
.write = ircomm_tty_write,
@@ -374,21 +377,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
374377
return retval;
375378
}
376379

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)
385382
{
386383
struct ircomm_tty_cb *self;
387384
unsigned int line = tty->index;
388-
unsigned long flags;
389-
int ret;
390-
391-
IRDA_DEBUG(2, "%s()\n", __func__ );
392385

393386
/* Check if instance already exists */
394387
self = hashbin_lock_find(ircomm_tty, line, NULL);
@@ -425,14 +418,30 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
425418
tty->termios.c_oflag = 0;
426419

427420
/* Insert into hash */
428-
/* FIXME there is a window from find to here */
429421
hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL);
430422
}
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+
431442
/* ++ is not atomic, so this should be protected - Jean II */
432443
spin_lock_irqsave(&self->port.lock, flags);
433444
self->port.count++;
434-
435-
tty->driver_data = self;
436445
spin_unlock_irqrestore(&self->port.lock, flags);
437446
tty_port_tty_set(&self->port, tty);
438447

@@ -472,7 +481,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
472481
}
473482

474483
/* Check if this is a "normal" ircomm device, or an irlpt device */
475-
if (line < 0x10) {
484+
if (self->line < 0x10) {
476485
self->service_type = IRCOMM_3_WIRE | IRCOMM_9_WIRE;
477486
self->settings.service_type = IRCOMM_9_WIRE; /* 9 wire as default */
478487
/* Jan Kiszka -> add DSR/RI -> Conform to IrCOMM spec */

0 commit comments

Comments
 (0)