From: Armin Schindler <armin@melware.de>
To: torvalds@osdl.org, akpm@osdl.org
Cc: i4ldeveloper@listserv.isdn4linux.de, linux-kernel@vger.kernel.org
Subject: [PATCH] 2.6 ISDN CAPI: fix capiminor_alloc()
Date: Mon, 29 Mar 2004 14:38:41 +0200 [thread overview]
Message-ID: <200403291238.i2TCcfDp021931@phoenix.one.melware.de> (raw)
Hi Andrew, Hi Linus,
this patch fixes assigning a correct minor for the capi tty.
Please apply.
Thanks,
Armin
Name: ISDN CAPI: fix capiminor_alloc() to assign lowest free minor
Author: Frank A. Uepping
D: This fixes capiminor_alloc() to assign the lowest free minor for a
new capi_tty. Thanks to Frank A. Uepping and Tim Woods.
--- linux-2.5/drivers/isdn/capi/capi.c_orig Mon Mar 29 14:25:49 2004
+++ linux-2.5/drivers/isdn/capi/capi.c Mon Mar 29 14:25:54 2004
@@ -1,4 +1,4 @@
-/* $Id: capi.c,v 1.1.2.3 2004/01/16 21:09:26 keil Exp $
+/* $Id: capi.c,v 1.1.2.4 2004/03/29 10:38:02 armin Exp $
*
* CAPI 2.0 Interface for Linux
*
@@ -44,7 +44,7 @@
#include "capifs.h"
#endif
-static char *revision = "$Revision: 1.1.2.3 $";
+static char *revision = "$Revision: 1.1.2.4 $";
MODULE_DESCRIPTION("CAPI4Linux: Userspace /dev/capi20 interface");
MODULE_AUTHOR("Carsten Paeth");
@@ -200,7 +200,6 @@
static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)
{
struct capiminor *mp, *p;
- struct list_head *l;
unsigned int minor = 0;
unsigned long flags;
@@ -219,26 +218,31 @@
skb_queue_head_init(&mp->inqueue);
skb_queue_head_init(&mp->outqueue);
+ /* Allocate the least unused minor number.
+ */
write_lock_irqsave(&capiminor_list_lock, flags);
- if (list_empty(&capiminor_list)) {
+ if (list_empty(&capiminor_list))
list_add(&mp->list, &capiminor_list);
- write_unlock_irqrestore(&capiminor_list_lock, flags);
- } else {
- list_for_each(l, &capiminor_list) {
- p = list_entry(l, struct capiminor, list);
- if (p->minor > minor) {
- mp->minor = minor;
- list_add_tail(&mp->list, &p->list);
+ else {
+ list_for_each_entry(p, &capiminor_list, list) {
+ if (p->minor > minor)
break;
- }
minor++;
}
+
+ if (minor < capi_ttyminors) {
+ mp->minor = minor;
+ list_add(&mp->list, p->list.prev);
+ }
+ }
write_unlock_irqrestore(&capiminor_list_lock, flags);
- if (l == &capiminor_list) {
+
+ if (!(minor < capi_ttyminors)) {
+ printk(KERN_NOTICE "capi: out of minors\n");
kfree(mp);
- return NULL;
- }
+ return 0;
}
+
return mp;
}
reply other threads:[~2004-03-29 12:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200403291238.i2TCcfDp021931@phoenix.one.melware.de \
--to=armin@melware.de \
--cc=akpm@osdl.org \
--cc=i4ldeveloper@listserv.isdn4linux.de \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.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®