git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
drivers
/
isdn
/
capi
/
capi.c
diff --git
a/drivers/isdn/capi/capi.c
b/drivers/isdn/capi/capi.c
index
12dee8e
..
d22c022
100644
(file)
--- a/
drivers/isdn/capi/capi.c
+++ b/
drivers/isdn/capi/capi.c
@@
-9,7
+9,6
@@
*
*/
*
*/
-#include <linux/config.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/kernel.h>
@@
-39,7
+38,6
@@
#include <linux/init.h>
#include <linux/device.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/moduleparam.h>
-#include <linux/devfs_fs_kernel.h>
#include <linux/isdn/capiutil.h>
#include <linux/isdn/capicmd.h>
#if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE)
#include <linux/isdn/capiutil.h>
#include <linux/isdn/capicmd.h>
#if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE)
@@
-58,7
+56,7
@@
MODULE_LICENSE("GPL");
/* -------- driver information -------------------------------------- */
/* -------- driver information -------------------------------------- */
-static struct class
_simple
*capi_class;
+static struct class *capi_class;
static int capi_major = 68; /* allocated */
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
static int capi_major = 68; /* allocated */
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
@@
-87,6
+85,11
@@
struct capincci;
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
struct capiminor;
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
struct capiminor;
+struct datahandle_queue {
+ struct list_head list;
+ u16 datahandle;
+};
+
struct capiminor {
struct list_head list;
struct capincci *nccip;
struct capiminor {
struct list_head list;
struct capincci *nccip;
@@
-109,12
+112,9
@@
struct capiminor {
int outbytes;
/* transmit path */
int outbytes;
/* transmit path */
- struct datahandle_queue {
- struct datahandle_queue *next;
- u16 datahandle;
- } *ackqueue;
+ struct list_head ackqueue;
int nack;
int nack;
-
+ spinlock_t ackqlock;
};
#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
};
#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
@@
-156,48
+156,54
@@
static LIST_HEAD(capiminor_list);
static int capincci_add_ack(struct capiminor *mp, u16 datahandle)
{
static int capincci_add_ack(struct capiminor *mp, u16 datahandle)
{
- struct datahandle_queue *n, **pp;
+ struct datahandle_queue *n;
+ unsigned long flags;
n = kmalloc(sizeof(*n), GFP_ATOMIC);
n = kmalloc(sizeof(*n), GFP_ATOMIC);
- if (
!n
) {
- printk(KERN_ERR "capi: alloc datahandle failed\n");
- return -1;
+ if (
unlikely(!n)
) {
+
printk(KERN_ERR "capi: alloc datahandle failed\n");
+
return -1;
}
}
- n->next = NULL;
n->datahandle = datahandle;
n->datahandle = datahandle;
- for (pp = &mp->ackqueue; *pp; pp = &(*pp)->next) ;
- *pp = n;
+ INIT_LIST_HEAD(&n->list);
+ spin_lock_irqsave(&mp->ackqlock, flags);
+ list_add_tail(&n->list, &mp->ackqueue);
mp->nack++;
mp->nack++;
+ spin_unlock_irqrestore(&mp->ackqlock, flags);
return 0;
}
static int capiminor_del_ack(struct capiminor *mp, u16 datahandle)
{
return 0;
}
static int capiminor_del_ack(struct capiminor *mp, u16 datahandle)
{
- struct datahandle_queue **pp, *p;
+ struct datahandle_queue *p, *tmp;
+ unsigned long flags;
- for (pp = &mp->ackqueue; *pp; pp = &(*pp)->next) {
-
if ((*pp)->datahandle == datahandle
) {
- p = *pp;
-
*pp = (*pp)->next
;
+ spin_lock_irqsave(&mp->ackqlock, flags);
+
list_for_each_entry_safe(p, tmp, &mp->ackqueue, list
) {
+ if (p->datahandle == datahandle) {
+
list_del(&p->list)
;
kfree(p);
mp->nack--;
kfree(p);
mp->nack--;
+ spin_unlock_irqrestore(&mp->ackqlock, flags);
return 0;
}
}
return 0;
}
}
+ spin_unlock_irqrestore(&mp->ackqlock, flags);
return -1;
}
static void capiminor_del_all_ack(struct capiminor *mp)
{
return -1;
}
static void capiminor_del_all_ack(struct capiminor *mp)
{
- struct datahandle_queue **pp, *p;
+ struct datahandle_queue *p, *tmp;
+ unsigned long flags;
- pp = &mp->ackqueue;
- while (*pp) {
- p = *pp;
- *pp = (*pp)->next;
+ spin_lock_irqsave(&mp->ackqlock, flags);
+ list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) {
+ list_del(&p->list);
kfree(p);
mp->nack--;
}
kfree(p);
mp->nack--;
}
+ spin_unlock_irqrestore(&mp->ackqlock, flags);
}
}
@@
-209,17
+215,18
@@
static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)
unsigned int minor = 0;
unsigned long flags;
unsigned int minor = 0;
unsigned long flags;
- mp = k
m
alloc(sizeof(*mp), GFP_ATOMIC);
+ mp = k
z
alloc(sizeof(*mp), GFP_ATOMIC);
if (!mp) {
printk(KERN_ERR "capi: can't alloc capiminor\n");
return NULL;
}
if (!mp) {
printk(KERN_ERR "capi: can't alloc capiminor\n");
return NULL;
}
- memset(mp, 0, sizeof(struct capiminor));
mp->ap = ap;
mp->ncci = ncci;
mp->msgid = 0;
atomic_set(&mp->ttyopencount,0);
mp->ap = ap;
mp->ncci = ncci;
mp->msgid = 0;
atomic_set(&mp->ttyopencount,0);
+ INIT_LIST_HEAD(&mp->ackqueue);
+ spin_lock_init(&mp->ackqlock);
skb_queue_head_init(&mp->inqueue);
skb_queue_head_init(&mp->outqueue);
skb_queue_head_init(&mp->inqueue);
skb_queue_head_init(&mp->outqueue);
@@
-296,10
+303,9
@@
static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci)
struct capiminor *mp = NULL;
#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
struct capiminor *mp = NULL;
#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
- np = k
m
alloc(sizeof(*np), GFP_ATOMIC);
+ np = k
z
alloc(sizeof(*np), GFP_ATOMIC);
if (!np)
return NULL;
if (!np)
return NULL;
- memset(np, 0, sizeof(struct capincci));
np->ncci = ncci;
np->cdev = cdev;
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
np->ncci = ncci;
np->cdev = cdev;
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
@@
-376,10
+382,9
@@
static struct capidev *capidev_alloc(void)
struct capidev *cdev;
unsigned long flags;
struct capidev *cdev;
unsigned long flags;
- cdev = k
m
alloc(sizeof(*cdev), GFP_KERNEL);
+ cdev = k
z
alloc(sizeof(*cdev), GFP_KERNEL);
if (!cdev)
return NULL;
if (!cdev)
return NULL;
- memset(cdev, 0, sizeof(struct capidev));
init_MUTEX(&cdev->ncci_list_sem);
skb_queue_head_init(&cdev->recvqueue);
init_MUTEX(&cdev->ncci_list_sem);
skb_queue_head_init(&cdev->recvqueue);
@@
-463,8
+468,7
@@
static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb)
#endif
goto bad;
}
#endif
goto bad;
}
- if (ld->receive_room &&
- ld->receive_room(mp->tty) < datalen) {
+ if (mp->tty->receive_room < datalen) {
#if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS)
printk(KERN_DEBUG "capi: no room in tty\n");
#endif
#if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS)
printk(KERN_DEBUG "capi: no room in tty\n");
#endif
@@
-1003,7
+1007,7
@@
static int capinc_tty_open(struct tty_struct * tty, struct file * file)
{
struct capiminor *mp;
{
struct capiminor *mp;
- if ((mp = capiminor_find(iminor(file->f_dentry->d_inode))) == 0)
+ if ((mp = capiminor_find(iminor(file->f_
path.
dentry->d_inode))) == 0)
return -ENXIO;
if (mp->nccip == 0)
return -ENXIO;
return -ENXIO;
if (mp->nccip == 0)
return -ENXIO;
@@
-1196,7
+1200,7
@@
static int capinc_tty_ioctl(struct tty_struct *tty, struct file * file,
return error;
}
return error;
}
-static void capinc_tty_set_termios(struct tty_struct *tty, struct termios * old)
+static void capinc_tty_set_termios(struct tty_struct *tty, struct
k
termios * old)
{
#ifdef _DEBUG_TTYFUNCS
printk(KERN_DEBUG "capinc_tty_set_termios\n");
{
#ifdef _DEBUG_TTYFUNCS
printk(KERN_DEBUG "capinc_tty_set_termios\n");
@@
-1291,7
+1295,7
@@
static int capinc_tty_read_proc(char *page, char **start, off_t off,
static struct tty_driver *capinc_tty_driver;
static struct tty_driver *capinc_tty_driver;
-static struct tty_operations capinc_ops = {
+static
const
struct tty_operations capinc_ops = {
.open = capinc_tty_open,
.close = capinc_tty_close,
.write = capinc_tty_write,
.open = capinc_tty_open,
.close = capinc_tty_close,
.write = capinc_tty_write,
@@
-1328,7
+1332,6
@@
static int capinc_tty_init(void)
drv->owner = THIS_MODULE;
drv->driver_name = "capi_nc";
drv->owner = THIS_MODULE;
drv->driver_name = "capi_nc";
- drv->devfs_name = "capi/";
drv->name = "capi";
drv->major = capi_ttymajor;
drv->minor_start = 0;
drv->name = "capi";
drv->major = capi_ttymajor;
drv->minor_start = 0;
@@
-1486,6
+1489,7
@@
static int __init capi_init(void)
{
char *p;
char *compileinfo;
{
char *p;
char *compileinfo;
+ int major_ret;
if ((p = strchr(revision, ':')) != 0 && p[1]) {
strlcpy(rev, p + 2, sizeof(rev));
if ((p = strchr(revision, ':')) != 0 && p[1]) {
strlcpy(rev, p + 2, sizeof(rev));
@@
-1494,25
+1498,23
@@
static int __init capi_init(void)
} else
strcpy(rev, "1.0");
} else
strcpy(rev, "1.0");
- if (register_chrdev(capi_major, "capi20", &capi_fops)) {
+ major_ret = register_chrdev(capi_major, "capi20", &capi_fops);
+ if (major_ret < 0) {
printk(KERN_ERR "capi20: unable to get major %d\n", capi_major);
printk(KERN_ERR "capi20: unable to get major %d\n", capi_major);
- return
-EIO
;
+ return
major_ret
;
}
}
-
- capi_class = class_simple_create(THIS_MODULE, "capi");
+ capi_class = class_create(THIS_MODULE, "capi");
if (IS_ERR(capi_class)) {
unregister_chrdev(capi_major, "capi20");
return PTR_ERR(capi_class);
}
if (IS_ERR(capi_class)) {
unregister_chrdev(capi_major, "capi20");
return PTR_ERR(capi_class);
}
- class_simple_device_add(capi_class, MKDEV(capi_major, 0), NULL, "capi");
- devfs_mk_cdev(MKDEV(capi_major, 0), S_IFCHR | S_IRUSR | S_IWUSR,
- "isdn/capi20");
+ class_device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi");
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
if (capinc_tty_init() < 0) {
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
if (capinc_tty_init() < 0) {
- class_
simple_device_remove(
MKDEV(capi_major, 0));
- class_
simple_
destroy(capi_class);
+ class_
device_destroy(capi_class,
MKDEV(capi_major, 0));
+ class_destroy(capi_class);
unregister_chrdev(capi_major, "capi20");
return -ENOMEM;
}
unregister_chrdev(capi_major, "capi20");
return -ENOMEM;
}
@@
-1539,10
+1541,9
@@
static void __exit capi_exit(void)
{
proc_exit();
{
proc_exit();
- class_
simple_device_remove(
MKDEV(capi_major, 0));
- class_
simple_
destroy(capi_class);
+ class_
device_destroy(capi_class,
MKDEV(capi_major, 0));
+ class_destroy(capi_class);
unregister_chrdev(capi_major, "capi20");
unregister_chrdev(capi_major, "capi20");
- devfs_remove("isdn/capi20");
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
capinc_tty_exit();
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
capinc_tty_exit();