mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: David Miller <davem@davemloft.net>, Karsten Keil <isdn@linux-pingi.de>
Cc: linux-kernel@vger.kernel.org,
	i4ldeveloper@listserv.isdn4linux.de,
	isdn4linux@listserv.isdn4linux.de, netdev@vger.kernel.org
Subject: [PATCH 20/31] CAPI: Drop atomic ttyopencount
Date: Fri, 8 Jan 2010 11:38:58 +0100	[thread overview]
Message-ID: <136f269e37529d1e40fc54ef3da02facd7bda21a.1264201407.git.jan.kiszka@web.de> (raw)
In-Reply-To: <cover.1264201406.git.jan.kiszka@web.de>

Not needed, tty->count keeps track of this information. At this chance,
drop traces of ancient attempts to debug this logic via _DEBUG_REFCOUNT.

Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
---
 drivers/isdn/capi/capi.c |   31 +++----------------------------
 1 files changed, 3 insertions(+), 28 deletions(-)

diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index b53cead..7710a66 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -44,7 +44,6 @@ MODULE_DESCRIPTION("CAPI4Linux: Userspace /dev/capi20 interface");
 MODULE_AUTHOR("Carsten Paeth");
 MODULE_LICENSE("GPL");
 
-#undef _DEBUG_REFCOUNT		/* alloc/free and open/close debug */
 #undef _DEBUG_TTYFUNCS		/* call to tty_driver */
 #undef _DEBUG_DATAFLOW		/* data flow */
 
@@ -98,7 +97,6 @@ struct capiminor {
 	int                ttyinstop;
 	int                ttyoutstop;
 	struct sk_buff    *ttyskb;
-	atomic_t           ttyopencount;
 
 	struct sk_buff_head inqueue;
 	int                 inbytes;
@@ -224,7 +222,6 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)
 	mp->ap = ap;
 	mp->ncci = ncci;
 	mp->msgid = 0;
-	atomic_set(&mp->ttyopencount,0);
 	INIT_LIST_HEAD(&mp->ackqueue);
 	spin_lock_init(&mp->ackqlock);
 
@@ -294,9 +291,6 @@ static void capincci_alloc_minor(struct capidev *cdev, struct capincci *np)
 	mp = np->minorp = capiminor_alloc(&cdev->ap, np->ncci);
 	if (mp) {
 		mp->nccip = np;
-#ifdef _DEBUG_REFCOUNT
-		printk(KERN_DEBUG "set mp->nccipn");
-#endif
 		mp->capifs_dentry =
 			capifs_new_ncci(mp->minor,
 					MKDEV(capi_ttymajor, mp->minor));
@@ -316,9 +310,6 @@ static void capincci_free_minor(struct capincci *np)
 		capifs_free_ncci(mp->capifs_dentry);
 		if (mp->tty) {
 			mp->nccip = NULL;
-#ifdef _DEBUG_REFCOUNT
-			printk(KERN_DEBUG "reset mp->nccipn");
-#endif
 			tty_hangup(mp->tty);
 		} else {
 			capiminor_free(mp);
@@ -332,7 +323,7 @@ static inline unsigned int capincci_minor_opencount(struct capincci *np)
 {
 	struct capiminor *mp = np->minorp;
 
-	return mp ? atomic_read(&mp->ttyopencount) : 0;
+	return (mp && mp->tty) ? mp->tty->count : 0;
 }
 
 #else /* !CONFIG_ISDN_CAPI_MIDDLEWARE */
@@ -998,14 +989,9 @@ static int capinc_tty_open(struct tty_struct * tty, struct file * file)
 	}
 
 	tty->driver_data = mp;
+	mp->tty = tty;
 
 	spin_lock_irqsave(&workaround_lock, flags);
-	if (atomic_read(&mp->ttyopencount) == 0)
-		mp->tty = tty;
-	atomic_inc(&mp->ttyopencount);
-#ifdef _DEBUG_REFCOUNT
-	printk(KERN_DEBUG "capinc_tty_open ocount=%dn", atomic_read(&mp->ttyopencount));
-#endif
 	handle_minor_recv(mp);
 	spin_unlock_irqrestore(&workaround_lock, flags);
 
@@ -1020,23 +1006,12 @@ static void capinc_tty_close(struct tty_struct * tty, struct file * file)
 
 	mutex_lock(&glue_lock);
 
-	if (atomic_dec_and_test(&mp->ttyopencount)) {
-#ifdef _DEBUG_REFCOUNT
-		printk(KERN_DEBUG "capinc_tty_close lastclosen");
-#endif
+	if (tty->count == 1)
 		mp->tty = NULL;
-	}
-#ifdef _DEBUG_REFCOUNT
-		printk(KERN_DEBUG "capinc_tty_close ocount=%dn", atomic_read(&mp->ttyopencount));
-#endif
 	if (!mp->nccip)
 		capiminor_free(mp);
 
 	mutex_unlock(&glue_lock);
-
-#ifdef _DEBUG_REFCOUNT
-	printk(KERN_DEBUG "capinc_tty_closen");
-#endif
 }
 
 static int capinc_tty_write(struct tty_struct * tty,
-- 
1.6.0.2


  parent reply	other threads:[~2010-01-22 23:26 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-22 23:03 [PATCH 00/31] CAPI: Major rework, tons of bug fixes Jan Kiszka
2010-01-06 10:43 ` [PATCH 01/31] CAPI: Fix leaks in capifs_new_ncci Jan Kiszka
2010-01-06 10:47 ` [PATCH 05/31] CAPI: Reduce chattiness during module loading/removal Jan Kiszka
2010-01-06 13:38 ` [PATCH 02/31] CAPI: Sanitize capifs API Jan Kiszka
2010-01-06 13:49 ` [PATCH 03/31] CAPI: Eliminate capifs_root variable Jan Kiszka
2010-01-06 14:03 ` [PATCH 04/31] CAPI: Pin capifs instead of mounting it Jan Kiszka
2010-01-06 18:02 ` [PATCH 07/31] CAPI: Convert capi drivers rwlock into mutex Jan Kiszka
2010-01-06 18:55 ` [PATCH 06/31] CAPI: Call a controller 'controller', not 'card' Jan Kiszka
2010-01-07 10:53 ` [PATCH 08/31] CAPI: Rework capi_ctr_ready/down Jan Kiszka
2010-01-07 11:04 ` [PATCH 10/31] CAPI: Rework locking of controller data structures Jan Kiszka
2010-01-07 12:36 ` [PATCH 11/31] CAPI: Rework application locking Jan Kiszka
2010-01-07 17:42 ` [PATCH 12/31] CAPI: Reduce #ifdef mess around CONFIG_ISDN_CAPI_MIDDLEWARE Jan Kiszka
2010-01-07 18:16 ` [PATCH 13/31] CAPI: Convert capidev_list_lock into a mutex Jan Kiszka
2010-01-07 18:24 ` [PATCH 14/31] CAPI: Clean up capi_open/release Jan Kiszka
2010-01-07 19:12 ` [PATCH 15/31] CAPI: Rework locking of capidev members Jan Kiszka
2010-01-07 19:21 ` [PATCH 16/31] CAPI: Use non-atomic allocation during NCCI setup Jan Kiszka
2010-01-07 19:38 ` [PATCH 17/31] CAPI: Fix racy capi_read Jan Kiszka
2010-01-07 20:52 ` [PATCH 18/31] CAPI: Switch NCCI list to standard doubly linked list Jan Kiszka
2010-01-08  9:45 ` [PATCH 19/31] CAPI: Fix locking around glueing capiminor and capidev Jan Kiszka
2010-01-08 10:38 ` Jan Kiszka [this message]
2010-01-08 11:00 ` [PATCH 21/31] CAPI: Remove useless checks for tty->driver_data or hung up state Jan Kiszka
2010-01-08 11:39 ` [PATCH 23/31] CAPI: Rename datahandle_queue -> ackqueue_entry Jan Kiszka
2010-01-08 11:46 ` [PATCH 24/31] CAPI: Use atomics for capiminor's datahandle and msgid Jan Kiszka
2010-01-08 11:57 ` [PATCH 25/31] CAPI: Drop capiminor's unused inbytes counter Jan Kiszka
2010-01-08 12:43 ` [PATCH 26/31] CAPI: Fix locking around capiminor's output queue Jan Kiszka
2010-01-08 12:49 ` [PATCH 27/31] CAPI: Clean up capiminor_*_ack Jan Kiszka
2010-01-08 13:38 ` [PATCH 22/31] CAPI: Rework tty locking in RX and TX path of capiminor Jan Kiszka
2010-01-08 14:11 ` [PATCH 28/31] CAPI: Drop handle_minor_send return value Jan Kiszka
2010-01-10 10:24 ` [PATCH 09/31] CAPI: Rework controller state notifier Jan Kiszka
2010-01-10 13:07 ` [PATCH 29/31] CAPI: Drop special controller lookup from capi20_put_message Jan Kiszka
2010-01-10 13:12 ` [PATCH 30/31] CAPI: Remove experimental tag from middleware feature Jan Kiszka
2010-01-23 12:23   ` Alan Cox
2010-01-23 13:13     ` Jan Kiszka
2010-01-23 13:56       ` Alan Cox
2010-01-10 13:21 ` [PATCH 31/31] CAPI: Officially claim char major 191 Jan Kiszka
2010-01-23 12:24   ` Alan Cox
2010-01-23 12:48     ` Marcel Holtmann
2010-01-23 13:13       ` Jan Kiszka
2010-01-23 14:25         ` Marcel Holtmann
2010-01-23 13:32       ` Karsten Keil
2010-01-23 14:28         ` Marcel Holtmann
2010-01-23 14:49           ` Jan Kiszka
2010-01-23  9:18 ` [PATCH 00/31] CAPI: Major rework, tons of bug fixes David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=136f269e37529d1e40fc54ef3da02facd7bda21a.1264201407.git.jan.kiszka@web.de \
    --to=jan.kiszka@web.de \
    --cc=davem@davemloft.net \
    --cc=i4ldeveloper@listserv.isdn4linux.de \
    --cc=isdn4linux@listserv.isdn4linux.de \
    --cc=isdn@linux-pingi.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®