aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@web.de>2010-02-08 05:12:28 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-16 19:01:28 -0500
commit46324511809251adbedb874cc08692e247f7ed68 (patch)
treefc911aded2a75d50b7c922da86957b028cb189c8 /drivers/isdn
parent0159d5491fef4acadd116a989b671e1cd350382f (diff)
CAPI: Establish install/cleanup handlers for capiminor TTYs
Properly associate/disassociate a capiminor object with its TTY via the install/cleanup handlers instead of trying to guess first open and last close. Signed-off-by: Jan Kiszka <jan.kiszka@web.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn')
-rw-r--r--drivers/isdn/capi/capi.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 732cdb585b2d..3e4997ac67ae 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1005,16 +1005,34 @@ static const struct file_operations capi_fops =
1005#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 1005#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
1006/* -------- tty_operations for capincci ----------------------------- */ 1006/* -------- tty_operations for capincci ----------------------------- */
1007 1007
1008static int capinc_tty_open(struct tty_struct * tty, struct file * file) 1008static int
1009capinc_tty_install(struct tty_driver *driver, struct tty_struct *tty)
1009{ 1010{
1010 struct capiminor *mp; 1011 int idx = tty->index;
1011 unsigned long flags; 1012 struct capiminor *mp = capiminor_get(idx);
1013 int ret = tty_init_termios(tty);
1014
1015 if (ret == 0) {
1016 tty_driver_kref_get(driver);
1017 tty->count++;
1018 tty->driver_data = mp;
1019 driver->ttys[idx] = tty;
1020 } else
1021 capiminor_put(mp);
1022 return ret;
1023}
1012 1024
1013 mp = capiminor_get(iminor(file->f_path.dentry->d_inode)); 1025static void capinc_tty_cleanup(struct tty_struct *tty)
1014 if (mp->nccip == NULL) 1026{
1015 return -ENXIO; 1027 struct capiminor *mp = tty->driver_data;
1028 tty->driver_data = NULL;
1029 capiminor_put(mp);
1030}
1016 1031
1017 tty->driver_data = (void *)mp; 1032static int capinc_tty_open(struct tty_struct * tty, struct file * file)
1033{
1034 struct capiminor *mp = tty->driver_data;
1035 unsigned long flags;
1018 1036
1019 spin_lock_irqsave(&workaround_lock, flags); 1037 spin_lock_irqsave(&workaround_lock, flags);
1020 if (atomic_read(&mp->ttyopencount) == 0) 1038 if (atomic_read(&mp->ttyopencount) == 0)
@@ -1030,15 +1048,12 @@ static int capinc_tty_open(struct tty_struct * tty, struct file * file)
1030 1048
1031static void capinc_tty_close(struct tty_struct * tty, struct file * file) 1049static void capinc_tty_close(struct tty_struct * tty, struct file * file)
1032{ 1050{
1033 struct capiminor *mp; 1051 struct capiminor *mp = tty->driver_data;
1034 1052
1035 mp = (struct capiminor *)tty->driver_data;
1036 if (mp) {
1037 if (atomic_dec_and_test(&mp->ttyopencount)) { 1053 if (atomic_dec_and_test(&mp->ttyopencount)) {
1038#ifdef _DEBUG_REFCOUNT 1054#ifdef _DEBUG_REFCOUNT
1039 printk(KERN_DEBUG "capinc_tty_close lastclose\n"); 1055 printk(KERN_DEBUG "capinc_tty_close lastclose\n");
1040#endif 1056#endif
1041 tty->driver_data = NULL;
1042 mp->tty = NULL; 1057 mp->tty = NULL;
1043 } 1058 }
1044#ifdef _DEBUG_REFCOUNT 1059#ifdef _DEBUG_REFCOUNT
@@ -1047,9 +1062,6 @@ static void capinc_tty_close(struct tty_struct * tty, struct file * file)
1047 if (mp->nccip == NULL) 1062 if (mp->nccip == NULL)
1048 capiminor_free(mp); 1063 capiminor_free(mp);
1049 1064
1050 capiminor_put(mp);
1051 }
1052
1053#ifdef _DEBUG_REFCOUNT 1065#ifdef _DEBUG_REFCOUNT
1054 printk(KERN_DEBUG "capinc_tty_close\n"); 1066 printk(KERN_DEBUG "capinc_tty_close\n");
1055#endif 1067#endif
@@ -1333,6 +1345,8 @@ static const struct tty_operations capinc_ops = {
1333 .flush_buffer = capinc_tty_flush_buffer, 1345 .flush_buffer = capinc_tty_flush_buffer,
1334 .set_ldisc = capinc_tty_set_ldisc, 1346 .set_ldisc = capinc_tty_set_ldisc,
1335 .send_xchar = capinc_tty_send_xchar, 1347 .send_xchar = capinc_tty_send_xchar,
1348 .install = capinc_tty_install,
1349 .cleanup = capinc_tty_cleanup,
1336}; 1350};
1337 1351
1338static int __init capinc_tty_init(void) 1352static int __init capinc_tty_init(void)