Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 328189
b: refs/heads/master
c: 144ad33
h: refs/heads/master
i:
  328187: 0b06f6e
v: v3
  • Loading branch information
Syam Sidhardhan authored and Gustavo Padovan committed Aug 21, 2012
1 parent 70e3446 commit 6aa3d78
Show file tree
Hide file tree
Showing 3 changed files with 10 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: ab19516a50b375c11b9fa442954a43454a730950
refs/heads/master: 144ad33020a0af66fbb188ef3f13ca91c5326a69
3 changes: 1 addition & 2 deletions trunk/include/net/bluetooth/l2cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,10 @@ struct l2cap_chan {
struct sock *sk;

struct l2cap_conn *conn;
struct kref kref;

__u8 state;

atomic_t refcnt;

__le16 psm;
__u16 dcid;
__u16 scid;
Expand Down
15 changes: 8 additions & 7 deletions trunk/net/bluetooth/l2cap_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ struct l2cap_chan *l2cap_chan_create(void)

chan->state = BT_OPEN;

atomic_set(&chan->refcnt, 1);
kref_init(&chan->kref);

/* This flag is cleared in l2cap_chan_ready() */
set_bit(CONF_NOT_COMPLETE, &chan->conf_state);
Expand All @@ -416,8 +416,10 @@ struct l2cap_chan *l2cap_chan_create(void)
return chan;
}

static void l2cap_chan_destroy(struct l2cap_chan *chan)
static void l2cap_chan_destroy(struct kref *kref)
{
struct l2cap_chan *chan = container_of(kref, struct l2cap_chan, kref);

BT_DBG("chan %p", chan);

write_lock(&chan_list_lock);
Expand All @@ -429,17 +431,16 @@ static void l2cap_chan_destroy(struct l2cap_chan *chan)

void l2cap_chan_hold(struct l2cap_chan *c)
{
BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->refcnt));
BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->kref.refcount));

atomic_inc(&c->refcnt);
kref_get(&c->kref);
}

void l2cap_chan_put(struct l2cap_chan *c)
{
BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->refcnt));
BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->kref.refcount));

if (atomic_dec_and_test(&c->refcnt))
l2cap_chan_destroy(c);
kref_put(&c->kref, l2cap_chan_destroy);
}

void l2cap_chan_set_defaults(struct l2cap_chan *chan)
Expand Down

0 comments on commit 6aa3d78

Please sign in to comment.