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,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Marcel Holtmann <marcel@holtmann.org>
Subject: [PATCH v2 14/41] CAPI: Clean up capi_open/release
Date: Mon,  8 Feb 2010 21:12:18 +0100	[thread overview]
Message-ID: <4d410220c1c4e9da2c7fcfe113a3dadbf586ffbe.1265659934.git.jan.kiszka@web.de> (raw)
In-Reply-To: <cover.1265659933.git.jan.kiszka@web.de>
In-Reply-To: <cover.1265659933.git.jan.kiszka@web.de>

Fold capidev_alloc and capidev_free into capi_open and capi_release -
there are no other users. Someone pushed a lock_kernel into capi_open.
Drop it, we don't need it. Also remove the useless test from open that
checks for private_data == NULL.

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

diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 623412e..9d7c369 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -401,46 +401,6 @@ static struct capincci *capincci_find(struct capidev *cdev, u32 ncci)
 	return p;
 }
 
-/* -------- struct capidev ------------------------------------------ */
-
-static struct capidev *capidev_alloc(void)
-{
-	struct capidev *cdev;
-
-	cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
-	if (!cdev)
-		return NULL;
-
-	mutex_init(&cdev->ncci_list_mtx);
-	skb_queue_head_init(&cdev->recvqueue);
-	init_waitqueue_head(&cdev->recvwait);
-
-	mutex_lock(&capidev_list_lock);
-	list_add_tail(&cdev->list, &capidev_list);
-	mutex_unlock(&capidev_list_lock);
-
-        return cdev;
-}
-
-static void capidev_free(struct capidev *cdev)
-{
-	mutex_lock(&capidev_list_lock);
-	list_del(&cdev->list);
-	mutex_unlock(&capidev_list_lock);
-
-	if (cdev->ap.applid) {
-		capi20_release(&cdev->ap);
-		cdev->ap.applid = 0;
-	}
-	skb_queue_purge(&cdev->recvqueue);
-
-	mutex_lock(&cdev->ncci_list_mtx);
-	capincci_free(cdev, 0xffffffff);
-	mutex_unlock(&cdev->ncci_list_mtx);
-
-	kfree(cdev);
-}
-
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
 /* -------- handle data queue --------------------------------------- */
 
@@ -991,30 +951,45 @@ capi_ioctl(struct inode *inode, struct file *file,
 	return -EINVAL;
 }
 
-static int
-capi_open(struct inode *inode, struct file *file)
+static int capi_open(struct inode *inode, struct file *file)
 {
-	int ret;
-	
-	lock_kernel();
-	if (file->private_data)
-		ret = -EEXIST;
-	else if ((file->private_data = capidev_alloc()) == NULL)
-		ret = -ENOMEM;
-	else
-		ret = nonseekable_open(inode, file);
-	unlock_kernel();
-	return ret;
+	struct capidev *cdev;
+
+	cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
+	if (!cdev)
+		return -ENOMEM;
+
+	mutex_init(&cdev->ncci_list_mtx);
+	skb_queue_head_init(&cdev->recvqueue);
+	init_waitqueue_head(&cdev->recvwait);
+	file->private_data = cdev;
+
+	mutex_lock(&capidev_list_lock);
+	list_add_tail(&cdev->list, &capidev_list);
+	mutex_unlock(&capidev_list_lock);
+
+	return nonseekable_open(inode, file);
 }
 
-static int
-capi_release(struct inode *inode, struct file *file)
+static int capi_release(struct inode *inode, struct file *file)
 {
-	struct capidev *cdev = (struct capidev *)file->private_data;
+	struct capidev *cdev = file->private_data;
 
-	capidev_free(cdev);
-	file->private_data = NULL;
-	
+	mutex_lock(&capidev_list_lock);
+	list_del(&cdev->list);
+	mutex_unlock(&capidev_list_lock);
+
+	if (cdev->ap.applid) {
+		capi20_release(&cdev->ap);
+		cdev->ap.applid = 0;
+	}
+	skb_queue_purge(&cdev->recvqueue);
+
+	mutex_lock(&cdev->ncci_list_mtx);
+	capincci_free(cdev, 0xffffffff);
+	mutex_unlock(&cdev->ncci_list_mtx);
+
+	kfree(cdev);
 	return 0;
 }
 
-- 
1.6.0.2


  parent reply	other threads:[~2010-02-08 20:20 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-08 20:12 [PATCH v2 00/41] CAPI: Major rework, tons of bug fixes Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 01/41] CAPI: Fix leaks in capifs_new_ncci Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 02/41] CAPI: Sanitize capifs API Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 03/41] CAPI: Eliminate capifs_root variable Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 04/41] CAPI: Pin capifs instead of mounting it Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 05/41] CAPI: Reduce chattiness during module loading/removal Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 06/41] CAPI: Call a controller 'controller', not 'card' Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 07/41] CAPI: Convert capi drivers rwlock into mutex Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 08/41] CAPI: Rework capi_ctr_ready/down Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 09/41] CAPI: Rework controller state notifier Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 10/41] CAPI: Rework locking of controller data structures Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 11/41] CAPI: Rework application locking Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 12/41] CAPI: Reduce #ifdef mess around CONFIG_ISDN_CAPI_MIDDLEWARE Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 13/41] CAPI: Convert capidev_list_lock into a mutex Jan Kiszka
2010-02-08 20:12 ` Jan Kiszka [this message]
2010-02-08 20:12 ` [PATCH v2 15/41] CAPI: Rework locking of capidev members Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 16/41] CAPI: Use non-atomic allocation during NCCI setup Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 17/41] CAPI: Fix racy capi_read Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 18/41] CAPI: Switch NCCI list to standard doubly linked list Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 19/41] CAPI: Switch capiminor list to array Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 20/41] CAPI: Clean up capinc_tty_init/exit Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 21/41] CAPI: Dynamically register minor devices Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 22/41] CAPI: Use dynamic major for NCCI TTYs by default Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 23/41] CAPI: Use kref on capiminor Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 24/41] CAPI: Establish install/cleanup handlers for capiminor TTYs Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 25/41] CAPI: Use tty_port to keep track of capiminor's tty Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 26/41] CAPI: Drop remaining NULL checks on tty->driver_data Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 27/41] CAPI: Issue synchronous hangup on capincci_free_minor Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 28/41] CAPI: Drop obsolete nccip from capiminor struct Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 29/41] CAPI: Clean up capiminors_lock Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 30/41] CAPI: Drop atomic ttyopencount Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 31/41] CAPI: Drop handle_minor_recv from capinc_tty_write Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 32/41] CAPI: Rework capiminor RX handler Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 33/41] CAPI: Rename datahandle_queue -> ackqueue_entry Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 34/41] CAPI: Use atomics for capiminor's datahandle and msgid Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 35/41] CAPI: Drop capiminor's unused inbytes counter Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 36/41] CAPI: Fix locking around capiminor's output queue and drop workaround_lock Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 37/41] CAPI: Clean up capiminor_*_ack Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 38/41] CAPI: Drop return value of handle_minor_send Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 39/41] CAPI: Drop special controller lookup from capi20_put_message Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 40/41] CAPI: Schedule capifs for removal Jan Kiszka
2010-02-08 20:12 ` [PATCH v2 41/41] CAPI: Remove experimental tag from middleware feature Jan Kiszka
2010-02-08 21:38 ` [PATCH v2 00/41] CAPI: Major rework, tons of bug fixes Alan Cox
2010-02-09 12:54 ` Karsten Keil
2010-02-16  4:09   ` David Miller
2010-02-10 15:07 ` Tilman Schmidt
2010-02-17  0:02 ` 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=4d410220c1c4e9da2c7fcfe113a3dadbf586ffbe.1265659934.git.jan.kiszka@web.de \
    --to=jan.kiszka@web.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --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=marcel@holtmann.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®