diff options
Diffstat (limited to 'net/bluetooth/l2cap_core.c')
-rw-r--r-- | net/bluetooth/l2cap_core.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index e0abaf3cb6a5..7a59e929febc 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -406,7 +406,7 @@ struct l2cap_chan *l2cap_chan_create(void) | |||
406 | 406 | ||
407 | chan->state = BT_OPEN; | 407 | chan->state = BT_OPEN; |
408 | 408 | ||
409 | atomic_set(&chan->refcnt, 1); | 409 | kref_init(&chan->kref); |
410 | 410 | ||
411 | /* This flag is cleared in l2cap_chan_ready() */ | 411 | /* This flag is cleared in l2cap_chan_ready() */ |
412 | set_bit(CONF_NOT_COMPLETE, &chan->conf_state); | 412 | set_bit(CONF_NOT_COMPLETE, &chan->conf_state); |
@@ -416,8 +416,10 @@ struct l2cap_chan *l2cap_chan_create(void) | |||
416 | return chan; | 416 | return chan; |
417 | } | 417 | } |
418 | 418 | ||
419 | static void l2cap_chan_destroy(struct l2cap_chan *chan) | 419 | static void l2cap_chan_destroy(struct kref *kref) |
420 | { | 420 | { |
421 | struct l2cap_chan *chan = container_of(kref, struct l2cap_chan, kref); | ||
422 | |||
421 | BT_DBG("chan %p", chan); | 423 | BT_DBG("chan %p", chan); |
422 | 424 | ||
423 | write_lock(&chan_list_lock); | 425 | write_lock(&chan_list_lock); |
@@ -429,17 +431,16 @@ static void l2cap_chan_destroy(struct l2cap_chan *chan) | |||
429 | 431 | ||
430 | void l2cap_chan_hold(struct l2cap_chan *c) | 432 | void l2cap_chan_hold(struct l2cap_chan *c) |
431 | { | 433 | { |
432 | BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->refcnt)); | 434 | BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->kref.refcount)); |
433 | 435 | ||
434 | atomic_inc(&c->refcnt); | 436 | kref_get(&c->kref); |
435 | } | 437 | } |
436 | 438 | ||
437 | void l2cap_chan_put(struct l2cap_chan *c) | 439 | void l2cap_chan_put(struct l2cap_chan *c) |
438 | { | 440 | { |
439 | BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->refcnt)); | 441 | BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->kref.refcount)); |
440 | 442 | ||
441 | if (atomic_dec_and_test(&c->refcnt)) | 443 | kref_put(&c->kref, l2cap_chan_destroy); |
442 | l2cap_chan_destroy(c); | ||
443 | } | 444 | } |
444 | 445 | ||
445 | void l2cap_chan_set_defaults(struct l2cap_chan *chan) | 446 | void l2cap_chan_set_defaults(struct l2cap_chan *chan) |
@@ -1448,7 +1449,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | |||
1448 | int err; | 1449 | int err; |
1449 | 1450 | ||
1450 | BT_DBG("%s -> %s (type %u) psm 0x%2.2x", batostr(src), batostr(dst), | 1451 | BT_DBG("%s -> %s (type %u) psm 0x%2.2x", batostr(src), batostr(dst), |
1451 | dst_type, __le16_to_cpu(chan->psm)); | 1452 | dst_type, __le16_to_cpu(psm)); |
1452 | 1453 | ||
1453 | hdev = hci_get_route(dst, src); | 1454 | hdev = hci_get_route(dst, src); |
1454 | if (!hdev) | 1455 | if (!hdev) |