aboutsummaryrefslogtreecommitdiffstats
path: root/net/irda
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-08-07 15:48:02 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-13 19:53:14 -0400
commit9c650ffc27b444f5370ae5e8bc84df76584416a0 (patch)
treec039f858db9127b1c55b8fbeabbebc97d2bc76a2 /net/irda
parentee3b48da84261ce37ef339e27e353a512c93ce5f (diff)
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>
Diffstat (limited to 'net/irda')
-rw-r--r--net/irda/ircomm/ircomm_tty.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 7a0d6115d06f..96689906b93c 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -52,6 +52,8 @@
52#include <net/irda/ircomm_tty_attach.h> 52#include <net/irda/ircomm_tty_attach.h>
53#include <net/irda/ircomm_tty.h> 53#include <net/irda/ircomm_tty.h>
54 54
55static int ircomm_tty_install(struct tty_driver *driver,
56 struct tty_struct *tty);
55static int ircomm_tty_open(struct tty_struct *tty, struct file *filp); 57static int ircomm_tty_open(struct tty_struct *tty, struct file *filp);
56static void ircomm_tty_close(struct tty_struct * tty, struct file *filp); 58static void ircomm_tty_close(struct tty_struct * tty, struct file *filp);
57static int ircomm_tty_write(struct tty_struct * tty, 59static int ircomm_tty_write(struct tty_struct * tty,
@@ -82,6 +84,7 @@ static struct tty_driver *driver;
82static hashbin_t *ircomm_tty = NULL; 84static hashbin_t *ircomm_tty = NULL;
83 85
84static const struct tty_operations ops = { 86static const struct tty_operations ops = {
87 .install = ircomm_tty_install,
85 .open = ircomm_tty_open, 88 .open = ircomm_tty_open,
86 .close = ircomm_tty_close, 89 .close = ircomm_tty_close,
87 .write = ircomm_tty_write, 90 .write = ircomm_tty_write,
@@ -374,21 +377,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
374 return retval; 377 return retval;
375} 378}
376 379
377/* 380
378 * Function ircomm_tty_open (tty, filp) 381static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
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 */
384static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
385{ 382{
386 struct ircomm_tty_cb *self; 383 struct ircomm_tty_cb *self;
387 unsigned int line = tty->index; 384 unsigned int line = tty->index;
388 unsigned long flags;
389 int ret;
390
391 IRDA_DEBUG(2, "%s()\n", __func__ );
392 385
393 /* Check if instance already exists */ 386 /* Check if instance already exists */
394 self = hashbin_lock_find(ircomm_tty, line, NULL); 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 tty->termios.c_oflag = 0; 418 tty->termios.c_oflag = 0;
426 419
427 /* Insert into hash */ 420 /* Insert into hash */
428 /* FIXME there is a window from find to here */
429 hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL); 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 */
434static 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 /* ++ is not atomic, so this should be protected - Jean II */ 442 /* ++ is not atomic, so this should be protected - Jean II */
432 spin_lock_irqsave(&self->port.lock, flags); 443 spin_lock_irqsave(&self->port.lock, flags);
433 self->port.count++; 444 self->port.count++;
434
435 tty->driver_data = self;
436 spin_unlock_irqrestore(&self->port.lock, flags); 445 spin_unlock_irqrestore(&self->port.lock, flags);
437 tty_port_tty_set(&self->port, tty); 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 /* Check if this is a "normal" ircomm device, or an irlpt device */ 483 /* Check if this is a "normal" ircomm device, or an irlpt device */
475 if (line < 0x10) { 484 if (self->line < 0x10) {
476 self->service_type = IRCOMM_3_WIRE | IRCOMM_9_WIRE; 485 self->service_type = IRCOMM_3_WIRE | IRCOMM_9_WIRE;
477 self->settings.service_type = IRCOMM_9_WIRE; /* 9 wire as default */ 486 self->settings.service_type = IRCOMM_9_WIRE; /* 9 wire as default */
478 /* Jan Kiszka -> add DSR/RI -> Conform to IrCOMM spec */ 487 /* Jan Kiszka -> add DSR/RI -> Conform to IrCOMM spec */