Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 184230
b: refs/heads/master
c: 0159d54
h: refs/heads/master
v: v3
  • Loading branch information
Jan Kiszka authored and David S. Miller committed Feb 17, 2010
1 parent b332f7e commit 1e955dc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 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: e95ac143868752ad30d93068a6fc0b39cf3a1bf4
refs/heads/master: 0159d5491fef4acadd116a989b671e1cd350382f
37 changes: 28 additions & 9 deletions trunk/drivers/isdn/capi/capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ struct datahandle_queue {
};

struct capiminor {
struct kref kref;

struct capincci *nccip;
unsigned int minor;
struct dentry *capifs_dentry;
Expand Down Expand Up @@ -223,6 +225,8 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)
return NULL;
}

kref_init(&mp->kref);

mp->ap = ap;
mp->ncci = ncci;
mp->msgid = 0;
Expand Down Expand Up @@ -265,18 +269,11 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)
return NULL;
}

static void capiminor_free(struct capiminor *mp)
static void capiminor_destroy(struct kref *kref)
{
unsigned long flags;

tty_unregister_device(capinc_tty_driver, mp->minor);

write_lock_irqsave(&capiminors_lock, flags);
capiminors[mp->minor] = NULL;
write_unlock_irqrestore(&capiminors_lock, flags);
struct capiminor *mp = container_of(kref, struct capiminor, kref);

kfree_skb(mp->ttyskb);
mp->ttyskb = NULL;
skb_queue_purge(&mp->inqueue);
skb_queue_purge(&mp->outqueue);
capiminor_del_all_ack(mp);
Expand All @@ -289,11 +286,31 @@ static struct capiminor *capiminor_get(unsigned int minor)

read_lock(&capiminors_lock);
mp = capiminors[minor];
if (mp)
kref_get(&mp->kref);
read_unlock(&capiminors_lock);

return mp;
}

static inline void capiminor_put(struct capiminor *mp)
{
kref_put(&mp->kref, capiminor_destroy);
}

static void capiminor_free(struct capiminor *mp)
{
unsigned long flags;

tty_unregister_device(capinc_tty_driver, mp->minor);

write_lock_irqsave(&capiminors_lock, flags);
capiminors[mp->minor] = NULL;
write_unlock_irqrestore(&capiminors_lock, flags);

capiminor_put(mp);
}

/* -------- struct capincci ----------------------------------------- */

static void capincci_alloc_minor(struct capidev *cdev, struct capincci *np)
Expand Down Expand Up @@ -1029,6 +1046,8 @@ static void capinc_tty_close(struct tty_struct * tty, struct file * file)
#endif
if (mp->nccip == NULL)
capiminor_free(mp);

capiminor_put(mp);
}

#ifdef _DEBUG_REFCOUNT
Expand Down

0 comments on commit 1e955dc

Please sign in to comment.