From patchwork Fri Jan 8 10:38:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 43536 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 6AD5CB7CCD for ; Sat, 23 Jan 2010 10:27:39 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756193Ab0AVX0Y (ORCPT ); Fri, 22 Jan 2010 18:26:24 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756244Ab0AVX0U (ORCPT ); Fri, 22 Jan 2010 18:26:20 -0500 Received: from fmmailgate02.web.de ([217.72.192.227]:49661 "EHLO fmmailgate02.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753767Ab0AVX0H (ORCPT ); Fri, 22 Jan 2010 18:26:07 -0500 Received: from smtp05.web.de (fmsmtp05.dlan.cinetic.de [172.20.4.166]) by fmmailgate02.web.de (Postfix) with ESMTP id A49D514C5E924; Sat, 23 Jan 2010 00:26:06 +0100 (CET) Received: from [92.75.141.69] (helo=[192.168.1.10]) by smtp05.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1NYStC-0005uj-00; Sat, 23 Jan 2010 00:26:06 +0100 Message-Id: <136f269e37529d1e40fc54ef3da02facd7bda21a.1264201407.git.jan.kiszka@web.de> In-Reply-To: References: From: Jan Kiszka To: David Miller , Karsten Keil Cc: linux-kernel@vger.kernel.org, i4ldeveloper@listserv.isdn4linux.de, isdn4linux@listserv.isdn4linux.de, netdev@vger.kernel.org Date: Fri, 8 Jan 2010 11:38:58 +0100 Subject: [PATCH 20/31] CAPI: Drop atomic ttyopencount X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX19Fttd5Fb3BV6k93tb6KXC7wwB4zoBSFhXGdKNJ ccmSGvk1dtFCJd+x93HM3zOYX9lY6EtYbYNFB9hXtnNLUNh4ba Jk81GA5xM= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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,