aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/bluetooth/l2cap.h
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2012-01-02 16:43:54 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-01-02 16:43:54 -0500
commitdc0d633e35643662f27a0b1c531da3cd6b204b9c (patch)
treecae724ecca3fb997bf3ad6b70bff4e3c739cd648 /include/net/bluetooth/l2cap.h
parentaef6c928a92481f75fbd548eb8c1e840912444b8 (diff)
parent4ae1652ef1bf38e07caa5d1d86ffd3b31103b55a (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth-next
Diffstat (limited to 'include/net/bluetooth/l2cap.h')
-rw-r--r--include/net/bluetooth/l2cap.h40
1 files changed, 34 insertions, 6 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index c0d168adf9be..9572cbd12a7a 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -522,7 +522,7 @@ struct l2cap_conn {
522 __u8 info_state; 522 __u8 info_state;
523 __u8 info_ident; 523 __u8 info_ident;
524 524
525 struct delayed_work info_work; 525 struct delayed_work info_timer;
526 526
527 spinlock_t lock; 527 spinlock_t lock;
528 528
@@ -532,7 +532,7 @@ struct l2cap_conn {
532 532
533 __u8 disc_reason; 533 __u8 disc_reason;
534 534
535 struct timer_list security_timer; 535 struct delayed_work security_timer;
536 struct smp_chan *smp_chan; 536 struct smp_chan *smp_chan;
537 537
538 struct list_head chan_l; 538 struct list_head chan_l;
@@ -595,17 +595,45 @@ enum {
595 FLAG_EFS_ENABLE, 595 FLAG_EFS_ENABLE,
596}; 596};
597 597
598static inline void l2cap_chan_hold(struct l2cap_chan *c)
599{
600 atomic_inc(&c->refcnt);
601}
602
603static inline void l2cap_chan_put(struct l2cap_chan *c)
604{
605 if (atomic_dec_and_test(&c->refcnt))
606 kfree(c);
607}
608
609static inline void l2cap_set_timer(struct l2cap_chan *chan,
610 struct delayed_work *work, long timeout)
611{
612 BT_DBG("chan %p state %d timeout %ld", chan, chan->state, timeout);
613
614 if (!__cancel_delayed_work(work))
615 l2cap_chan_hold(chan);
616 schedule_delayed_work(work, timeout);
617}
618
619static inline void l2cap_clear_timer(struct l2cap_chan *chan,
620 struct delayed_work *work)
621{
622 if (__cancel_delayed_work(work))
623 l2cap_chan_put(chan);
624}
625
598#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) 626#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t))
599#define __clear_chan_timer(c) l2cap_clear_timer(&c->chan_timer) 627#define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer)
600#define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ 628#define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \
601 L2CAP_DEFAULT_RETRANS_TO); 629 L2CAP_DEFAULT_RETRANS_TO);
602#define __clear_retrans_timer(c) l2cap_clear_timer(&c->retrans_timer) 630#define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer)
603#define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \ 631#define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \
604 L2CAP_DEFAULT_MONITOR_TO); 632 L2CAP_DEFAULT_MONITOR_TO);
605#define __clear_monitor_timer(c) l2cap_clear_timer(&c->monitor_timer) 633#define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer)
606#define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ 634#define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \
607 L2CAP_DEFAULT_ACK_TO); 635 L2CAP_DEFAULT_ACK_TO);
608#define __clear_ack_timer(c) l2cap_clear_timer(&c->ack_timer) 636#define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer)
609 637
610static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2) 638static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2)
611{ 639{