Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 184221
b: refs/heads/master
c: eca39dd
h: refs/heads/master
i:
  184219: 7233d1f
v: v3
  • Loading branch information
Jan Kiszka authored and David S. Miller committed Feb 17, 2010
1 parent c5f0f45 commit cdc73fb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 60 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b8f433dc5cd9b910c12ef5cca351bf720d3e68c1
refs/heads/master: eca39dd830dbc58061aa6cd68853c39055236be3
93 changes: 34 additions & 59 deletions trunk/drivers/isdn/capi/capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------------------- */

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit cdc73fb

Please sign in to comment.