Skip to content

Commit e61ef49

Browse files
finikorgGustavo F. Padovan
authored andcommitted
Bluetooth: Split ctrl init to BREDR and AMP parts
Current controller initialization is moved tp bredr_init and new function added amp_init to handle later AMP init sequence. Current AMP init sequence include Reset and Read Local Version. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
1 parent 27bf888 commit e61ef49

2 files changed

Lines changed: 49 additions & 18 deletions

File tree

‎net/bluetooth/hci_core.c‎

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -193,33 +193,18 @@ static void hci_reset_req(struct hci_dev *hdev, unsigned long opt)
193193
hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL);
194194
}
195195

196-
static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
196+
static void bredr_init(struct hci_dev *hdev)
197197
{
198198
struct hci_cp_delete_stored_link_key cp;
199-
struct sk_buff *skb;
200199
__le16 param;
201200
__u8 flt_type;
202201

203-
BT_DBG("%s %ld", hdev->name, opt);
204-
205-
/* Driver initialization */
206-
207-
/* Special commands */
208-
while ((skb = skb_dequeue(&hdev->driver_init))) {
209-
bt_cb(skb)->pkt_type = HCI_COMMAND_PKT;
210-
skb->dev = (void *) hdev;
211-
212-
skb_queue_tail(&hdev->cmd_q, skb);
213-
queue_work(hdev->workqueue, &hdev->cmd_work);
214-
}
215-
skb_queue_purge(&hdev->driver_init);
216-
217202
/* Mandatory initialization */
218203

219204
/* Reset */
220205
if (!test_bit(HCI_QUIRK_NO_RESET, &hdev->quirks)) {
221-
set_bit(HCI_RESET, &hdev->flags);
222-
hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL);
206+
set_bit(HCI_RESET, &hdev->flags);
207+
hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL);
223208
}
224209

225210
/* Read Local Supported Features */
@@ -258,6 +243,49 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
258243
hci_send_cmd(hdev, HCI_OP_DELETE_STORED_LINK_KEY, sizeof(cp), &cp);
259244
}
260245

246+
static void amp_init(struct hci_dev *hdev)
247+
{
248+
/* Reset */
249+
hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL);
250+
251+
/* Read Local Version */
252+
hci_send_cmd(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL);
253+
}
254+
255+
static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
256+
{
257+
struct sk_buff *skb;
258+
259+
BT_DBG("%s %ld", hdev->name, opt);
260+
261+
/* Driver initialization */
262+
263+
/* Special commands */
264+
while ((skb = skb_dequeue(&hdev->driver_init))) {
265+
bt_cb(skb)->pkt_type = HCI_COMMAND_PKT;
266+
skb->dev = (void *) hdev;
267+
268+
skb_queue_tail(&hdev->cmd_q, skb);
269+
queue_work(hdev->workqueue, &hdev->cmd_work);
270+
}
271+
skb_queue_purge(&hdev->driver_init);
272+
273+
switch (hdev->dev_type) {
274+
case HCI_BREDR:
275+
bredr_init(hdev);
276+
break;
277+
278+
case HCI_AMP:
279+
amp_init(hdev);
280+
break;
281+
282+
default:
283+
BT_ERR("Unknown device type %d", hdev->dev_type);
284+
break;
285+
}
286+
287+
}
288+
261289
static void hci_le_init_req(struct hci_dev *hdev, unsigned long opt)
262290
{
263291
BT_DBG("%s", hdev->name);

‎net/bluetooth/hci_event.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,9 @@ static void hci_set_le_support(struct hci_dev *hdev)
556556

557557
static void hci_setup(struct hci_dev *hdev)
558558
{
559+
if (hdev->dev_type != HCI_BREDR)
560+
return;
561+
559562
hci_setup_event_mask(hdev);
560563

561564
if (hdev->hci_ver > BLUETOOTH_VER_1_1)

0 commit comments

Comments
 (0)