diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2012-05-29 06:59:01 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-06-04 23:34:11 -0400 |
commit | 466f8004f364e9cb46d9124109972489eccfb404 (patch) | |
tree | 100233272787a891de4022eca15ba5c414719b2c /net | |
parent | 0181a70f549bd1683d18a5a1d79ac25bcdb76570 (diff) |
Bluetooth: A2MP: Create A2MP channel
Create and initialize fixed A2MP channel
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/Makefile | 3 | ||||
-rw-r--r-- | net/bluetooth/a2mp.c | 69 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 6 |
3 files changed, 74 insertions, 4 deletions
diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile index 2dc5a5700f53..fa6d94a4602a 100644 --- a/net/bluetooth/Makefile +++ b/net/bluetooth/Makefile | |||
@@ -9,4 +9,5 @@ obj-$(CONFIG_BT_CMTP) += cmtp/ | |||
9 | obj-$(CONFIG_BT_HIDP) += hidp/ | 9 | obj-$(CONFIG_BT_HIDP) += hidp/ |
10 | 10 | ||
11 | bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \ | 11 | bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \ |
12 | hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o | 12 | hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o \ |
13 | a2mp.o | ||
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c new file mode 100644 index 000000000000..de455a264451 --- /dev/null +++ b/net/bluetooth/a2mp.c | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | Copyright (c) 2010,2011 Code Aurora Forum. All rights reserved. | ||
3 | Copyright (c) 2011,2012 Intel Corp. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License version 2 and | ||
7 | only version 2 as published by the Free Software Foundation. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | */ | ||
14 | |||
15 | #include <net/bluetooth/bluetooth.h> | ||
16 | #include <net/bluetooth/hci_core.h> | ||
17 | #include <net/bluetooth/l2cap.h> | ||
18 | |||
19 | static struct l2cap_ops a2mp_chan_ops = { | ||
20 | .name = "L2CAP A2MP channel", | ||
21 | }; | ||
22 | |||
23 | static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn) | ||
24 | { | ||
25 | struct l2cap_chan *chan; | ||
26 | int err; | ||
27 | |||
28 | chan = l2cap_chan_create(); | ||
29 | if (!chan) | ||
30 | return NULL; | ||
31 | |||
32 | BT_DBG("chan %p", chan); | ||
33 | |||
34 | hci_conn_hold(conn->hcon); | ||
35 | |||
36 | chan->omtu = L2CAP_A2MP_DEFAULT_MTU; | ||
37 | chan->imtu = L2CAP_A2MP_DEFAULT_MTU; | ||
38 | chan->flush_to = L2CAP_DEFAULT_FLUSH_TO; | ||
39 | |||
40 | chan->ops = &a2mp_chan_ops; | ||
41 | |||
42 | l2cap_chan_set_defaults(chan); | ||
43 | chan->remote_max_tx = chan->max_tx; | ||
44 | chan->remote_tx_win = chan->tx_win; | ||
45 | |||
46 | chan->retrans_timeout = L2CAP_DEFAULT_RETRANS_TO; | ||
47 | chan->monitor_timeout = L2CAP_DEFAULT_MONITOR_TO; | ||
48 | |||
49 | skb_queue_head_init(&chan->tx_q); | ||
50 | |||
51 | chan->mode = L2CAP_MODE_ERTM; | ||
52 | |||
53 | err = l2cap_ertm_init(chan); | ||
54 | if (err < 0) { | ||
55 | l2cap_chan_del(chan, 0); | ||
56 | return NULL; | ||
57 | } | ||
58 | |||
59 | chan->conf_state = 0; | ||
60 | |||
61 | l2cap_chan_add(conn, chan); | ||
62 | |||
63 | chan->remote_mps = chan->omtu; | ||
64 | chan->mps = chan->omtu; | ||
65 | |||
66 | chan->state = BT_CONNECTED; | ||
67 | |||
68 | return chan; | ||
69 | } | ||
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 778c0c8cdc59..2c616cf24c71 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -484,14 +484,14 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) | |||
484 | list_add(&chan->list, &conn->chan_l); | 484 | list_add(&chan->list, &conn->chan_l); |
485 | } | 485 | } |
486 | 486 | ||
487 | static void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) | 487 | void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) |
488 | { | 488 | { |
489 | mutex_lock(&conn->chan_lock); | 489 | mutex_lock(&conn->chan_lock); |
490 | __l2cap_chan_add(conn, chan); | 490 | __l2cap_chan_add(conn, chan); |
491 | mutex_unlock(&conn->chan_lock); | 491 | mutex_unlock(&conn->chan_lock); |
492 | } | 492 | } |
493 | 493 | ||
494 | static void l2cap_chan_del(struct l2cap_chan *chan, int err) | 494 | void l2cap_chan_del(struct l2cap_chan *chan, int err) |
495 | { | 495 | { |
496 | struct l2cap_conn *conn = chan->conn; | 496 | struct l2cap_conn *conn = chan->conn; |
497 | 497 | ||
@@ -2691,7 +2691,7 @@ static void l2cap_ack_timeout(struct work_struct *work) | |||
2691 | l2cap_chan_put(chan); | 2691 | l2cap_chan_put(chan); |
2692 | } | 2692 | } |
2693 | 2693 | ||
2694 | static inline int l2cap_ertm_init(struct l2cap_chan *chan) | 2694 | int l2cap_ertm_init(struct l2cap_chan *chan) |
2695 | { | 2695 | { |
2696 | int err; | 2696 | int err; |
2697 | 2697 | ||