From patchwork Mon Feb 8 20:12:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 44840 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 267C9B7CF5 for ; Tue, 9 Feb 2010 07:20:11 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755567Ab0BHUSs (ORCPT ); Mon, 8 Feb 2010 15:18:48 -0500 Received: from fmmailgate03.web.de ([217.72.192.234]:53702 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754856Ab0BHUNG (ORCPT ); Mon, 8 Feb 2010 15:13:06 -0500 Received: from smtp05.web.de (fmsmtp05.dlan.cinetic.de [172.20.4.166]) by fmmailgate03.web.de (Postfix) with ESMTP id C18E413D4FFE2; Mon, 8 Feb 2010 21:13:05 +0100 (CET) Received: from [88.65.45.120] (helo=localhost.localdomain) by smtp05.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1NeZyj-0006fo-02; Mon, 08 Feb 2010 21:13:05 +0100 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, Alan Cox , Marcel Holtmann Subject: [PATCH v2 18/41] CAPI: Switch NCCI list to standard doubly linked list Date: Mon, 8 Feb 2010 21:12:22 +0100 Message-Id: X-Mailer: git-send-email 1.6.0.2 In-Reply-To: References: In-Reply-To: References: X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX1//vULHy9WkiGyquorBafFCruC+WpKYCr30EcG1 bYywKvB1Tamy6WmMyrED6bkIlAXS/C5FoIKvE57CmIa50WS6l0 sYVyMNbgU= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Replace open-coded NCCI list management with standard mechanisms. Signed-off-by: Jan Kiszka --- drivers/isdn/capi/capi.c | 52 +++++++++++++++++---------------------------- 1 files changed, 20 insertions(+), 32 deletions(-) diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index 8abec96..6704b2b 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -122,7 +122,7 @@ struct capiminor { static DEFINE_SPINLOCK(workaround_lock); struct capincci { - struct capincci *next; + struct list_head list; u32 ncci; struct capidev *cdev; #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE @@ -139,7 +139,7 @@ struct capidev { struct sk_buff_head recvqueue; wait_queue_head_t recvwait; - struct capincci *nccis; + struct list_head nccis; struct mutex lock; }; @@ -356,7 +356,7 @@ static inline unsigned int capincci_minor_opencount(struct capincci *np) static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci) { - struct capincci *np, **pp; + struct capincci *np; np = kzalloc(sizeof(*np), GFP_KERNEL); if (!np) @@ -366,39 +366,31 @@ static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci) capincci_alloc_minor(cdev, np); - for (pp=&cdev->nccis; *pp; pp = &(*pp)->next) - ; - *pp = np; - return np; + list_add_tail(&np->list, &cdev->nccis); + + return np; } static void capincci_free(struct capidev *cdev, u32 ncci) { - struct capincci *np, **pp; + struct capincci *np, *tmp; - pp=&cdev->nccis; - while (*pp) { - np = *pp; + list_for_each_entry_safe(np, tmp, &cdev->nccis, list) if (ncci == 0xffffffff || np->ncci == ncci) { - *pp = (*pp)->next; capincci_free_minor(np); + list_del(&np->list); kfree(np); - if (*pp == NULL) return; - } else { - pp = &(*pp)->next; } - } } static struct capincci *capincci_find(struct capidev *cdev, u32 ncci) { - struct capincci *p; + struct capincci *np; - for (p=cdev->nccis; p ; p = p->next) { - if (p->ncci == ncci) - break; - } - return p; + list_for_each_entry(np, &cdev->nccis, list) + if (np->ncci == ncci) + return np; + return NULL; } #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE @@ -955,6 +947,7 @@ static int capi_open(struct inode *inode, struct file *file) mutex_init(&cdev->lock); skb_queue_head_init(&cdev->recvqueue); init_waitqueue_head(&cdev->recvwait); + INIT_LIST_HEAD(&cdev->nccis); file->private_data = cdev; mutex_lock(&capidev_list_lock); @@ -1427,19 +1420,14 @@ static const struct file_operations capi20_proc_fops = { */ static int capi20ncci_proc_show(struct seq_file *m, void *v) { - struct capidev *cdev; - struct capincci *np; - struct list_head *l; + struct capidev *cdev; + struct capincci *np; mutex_lock(&capidev_list_lock); - list_for_each(l, &capidev_list) { - cdev = list_entry(l, struct capidev, list); + list_for_each_entry(cdev, &capidev_list, list) { mutex_lock(&cdev->lock); - for (np=cdev->nccis; np; np = np->next) { - seq_printf(m, "%d 0x%x\n", - cdev->ap.applid, - np->ncci); - } + list_for_each_entry(np, &cdev->nccis, list) + seq_printf(m, "%d 0x%x\n", cdev->ap.applid, np->ncci); mutex_unlock(&cdev->lock); } mutex_unlock(&capidev_list_lock);