Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: btintel_pcie: Introduce HCI Driver protocol

This patch adds the infrastructure that allow the user space program to
talk to intel pcie driver directly for fetching basic driver details.

The changes introduced are referred form
commit 04425292a62c15 ("Bluetooth: Introduce HCI Driver protocol")

Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Chethan T N and committed by
Luiz Augusto von Dentz
bc6f557b a8b38d19

+59
+59
drivers/bluetooth/btintel_pcie.c
··· 19 19 20 20 #include <net/bluetooth/bluetooth.h> 21 21 #include <net/bluetooth/hci_core.h> 22 + #include <net/bluetooth/hci_drv.h> 22 23 23 24 #include "btintel.h" 24 25 #include "btintel_pcie.h" ··· 2361 2360 return device_may_wakeup(&data->pdev->dev); 2362 2361 } 2363 2362 2363 + static const struct { 2364 + u16 opcode; 2365 + const char *desc; 2366 + } btintel_pcie_hci_drv_supported_commands[] = { 2367 + /* Common commands */ 2368 + { HCI_DRV_OP_READ_INFO, "Read Info" }, 2369 + }; 2370 + 2371 + static int btintel_pcie_hci_drv_read_info(struct hci_dev *hdev, void *data, 2372 + u16 data_len) 2373 + { 2374 + struct hci_drv_rp_read_info *rp; 2375 + size_t rp_size; 2376 + int err, i; 2377 + u16 opcode, num_supported_commands = 2378 + ARRAY_SIZE(btintel_pcie_hci_drv_supported_commands); 2379 + 2380 + rp_size = sizeof(*rp) + num_supported_commands * 2; 2381 + 2382 + rp = kmalloc(rp_size, GFP_KERNEL); 2383 + if (!rp) 2384 + return -ENOMEM; 2385 + 2386 + strscpy_pad(rp->driver_name, KBUILD_MODNAME); 2387 + 2388 + rp->num_supported_commands = cpu_to_le16(num_supported_commands); 2389 + for (i = 0; i < num_supported_commands; i++) { 2390 + opcode = btintel_pcie_hci_drv_supported_commands[i].opcode; 2391 + bt_dev_dbg(hdev, 2392 + "Supported HCI Drv command (0x%02x|0x%04x): %s", 2393 + hci_opcode_ogf(opcode), 2394 + hci_opcode_ocf(opcode), 2395 + btintel_pcie_hci_drv_supported_commands[i].desc); 2396 + rp->supported_commands[i] = cpu_to_le16(opcode); 2397 + } 2398 + 2399 + err = hci_drv_cmd_complete(hdev, HCI_DRV_OP_READ_INFO, 2400 + HCI_DRV_STATUS_SUCCESS, 2401 + rp, rp_size); 2402 + 2403 + kfree(rp); 2404 + return err; 2405 + } 2406 + 2407 + static const struct hci_drv_handler btintel_pcie_hci_drv_common_handlers[] = { 2408 + { btintel_pcie_hci_drv_read_info, HCI_DRV_READ_INFO_SIZE }, 2409 + }; 2410 + 2411 + static const struct hci_drv_handler btintel_pcie_hci_drv_specific_handlers[] = {}; 2412 + 2413 + static struct hci_drv btintel_pcie_hci_drv = { 2414 + .common_handler_count = ARRAY_SIZE(btintel_pcie_hci_drv_common_handlers), 2415 + .common_handlers = btintel_pcie_hci_drv_common_handlers, 2416 + .specific_handler_count = ARRAY_SIZE(btintel_pcie_hci_drv_specific_handlers), 2417 + .specific_handlers = btintel_pcie_hci_drv_specific_handlers, 2418 + }; 2419 + 2364 2420 static int btintel_pcie_setup_hdev(struct btintel_pcie_data *data) 2365 2421 { 2366 2422 int err; ··· 2444 2386 hdev->set_bdaddr = btintel_set_bdaddr; 2445 2387 hdev->reset = btintel_pcie_reset; 2446 2388 hdev->wakeup = btintel_pcie_wakeup; 2389 + hdev->hci_drv = &btintel_pcie_hci_drv; 2447 2390 2448 2391 err = hci_register_dev(hdev); 2449 2392 if (err < 0) {