hdev->flush = bfusb_flush;
        hdev->send  = bfusb_send_frame;
 
-       set_bit(HCI_QUIRK_BROKEN_LOCAL_COMMANDS, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_BROKEN_LOCAL_COMMANDS);
 
        if (hci_register_dev(hdev) < 0) {
                BT_ERR("Can't register HCI device");
 
        hdev->send     = bpa10x_send_frame;
        hdev->set_diag = bpa10x_set_diag;
 
-       set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_RESET_ON_CLOSE);
 
        err = hci_register_dev(hdev);
        if (err < 0) {
 
                if (btbcm_set_bdaddr_from_efi(hdev) != 0) {
                        bt_dev_info(hdev, "BCM: Using default device address (%pMR)",
                                    &bda->bdaddr);
-                       set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
+                       hci_set_quirk(hdev, HCI_QUIRK_INVALID_BDADDR);
                }
        }
 
 
        /* Read DMI and disable broken Read LE Min/Max Tx Power */
        if (dmi_first_match(disable_broken_read_transmit_power))
-               set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER);
 
        return 0;
 }
 
        btbcm_check_bdaddr(hdev);
 
-       set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_STRICT_DUPLICATE_FILTER);
 
        return 0;
 }
                kfree_skb(skb);
        }
 
-       set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_STRICT_DUPLICATE_FILTER);
 
        return 0;
 }
 
        if (!bacmp(&bda->bdaddr, BDADDR_INTEL)) {
                bt_dev_err(hdev, "Found Intel default device address (%pMR)",
                           &bda->bdaddr);
-               set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_INVALID_BDADDR);
        }
 
        kfree_skb(skb);
         */
        if (!bacmp(¶ms->otp_bdaddr, BDADDR_ANY)) {
                bt_dev_info(hdev, "No device address configured");
-               set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_INVALID_BDADDR);
        }
 
 download:
                 */
                if (!bacmp(&ver->otp_bd_addr, BDADDR_ANY)) {
                        bt_dev_info(hdev, "No device address configured");
-                       set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
+                       hci_set_quirk(hdev, HCI_QUIRK_INVALID_BDADDR);
                }
        }
 
        }
 
        /* Apply the common HCI quirks for Intel device */
-       set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
-       set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
-       set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_STRICT_DUPLICATE_FILTER);
+       hci_set_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY);
+       hci_set_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_DIAG);
 
        /* Set up the quality report callback for Intel devices */
        hdev->set_quality_report = btintel_set_quality_report;
                         */
                        if (!btintel_test_flag(hdev,
                                               INTEL_ROM_LEGACY_NO_WBS_SUPPORT))
-                               set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
-                                       &hdev->quirks);
+                               hci_set_quirk(hdev,
+                                             HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED);
 
                        err = btintel_legacy_rom_setup(hdev, &ver);
                        break;
                         *
                         * All Legacy bootloader devices support WBS
                         */
-                       set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
-                               &hdev->quirks);
+                       hci_set_quirk(hdev,
+                                     HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED);
 
                        /* These variants don't seem to support LE Coded PHY */
-                       set_bit(HCI_QUIRK_BROKEN_LE_CODED, &hdev->quirks);
+                       hci_set_quirk(hdev, HCI_QUIRK_BROKEN_LE_CODED);
 
                        /* Setup MSFT Extension support */
                        btintel_set_msft_opcode(hdev, ver.hw_variant);
                 *
                 * All Legacy bootloader devices support WBS
                 */
-               set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED);
 
                /* These variants don't seem to support LE Coded PHY */
-               set_bit(HCI_QUIRK_BROKEN_LE_CODED, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_LE_CODED);
 
                /* Setup MSFT Extension support */
                btintel_set_msft_opcode(hdev, ver.hw_variant);
                 *
                 * All TLV based devices support WBS
                 */
-               set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED);
 
                /* Setup MSFT Extension support */
                btintel_set_msft_opcode(hdev,
 
        }
 
        /* Apply the common HCI quirks for Intel device */
-       set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
-       set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
-       set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_STRICT_DUPLICATE_FILTER);
+       hci_set_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY);
+       hci_set_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_DIAG);
 
        /* Set up the quality report callback for Intel devices */
        hdev->set_quality_report = btintel_set_quality_report;
                 *
                 * All TLV based devices support WBS
                 */
-               set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED);
 
                /* Setup MSFT Extension support */
                btintel_set_msft_opcode(hdev,
 
                }
 
                /* Enable WBS with mSBC codec */
-               set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED);
 
                /* Enable GPIO reset mechanism */
                if (bdev->reset) {
        SET_HCIDEV_DEV(hdev, &func->dev);
 
        hdev->manufacturer = 70;
-       set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_SETUP);
 
        sdio_set_drvdata(func, bdev);
 
 
        SET_HCIDEV_DEV(hdev, &serdev->dev);
 
        hdev->manufacturer = 70;
-       set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_SETUP);
 
        if (btmtkuart_is_standalone(bdev)) {
                err = clk_prepare_enable(bdev->osc);
 
                                      "local-bd-address",
                                      (u8 *)&ba, sizeof(ba));
        if (bacmp(&ba, BDADDR_ANY))
-               set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY);
 
        if (hci_register_dev(hdev) < 0) {
                dev_err(&serdev->dev, "Can't register HCI device\n");
 
 
        bda = (struct hci_rp_read_bd_addr *)skb->data;
        if (!bacmp(&bda->bdaddr, &config->bdaddr))
-               set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY);
 
        kfree_skb(skb);
 
 
        /* Devices do not have persistent storage for BD address. Retrieve
         * it from the firmware node property.
         */
-       set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY);
 
        return 0;
 }
 
        /* Enable controller to do both LE scan and BR/EDR inquiry
         * simultaneously.
         */
-       set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY);
 
        /* Enable central-peripheral role (able to create new connections with
         * an existing connection in slave role).
        case CHIP_ID_8851B:
        case CHIP_ID_8922A:
        case CHIP_ID_8852BT:
-               set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED);
 
                /* RTL8852C needs to transmit mSBC data continuously without
                 * the zero length of USB packets for the ALT 6 supported chips
                if (btrtl_dev->project_id == CHIP_ID_8852A ||
                    btrtl_dev->project_id == CHIP_ID_8852B ||
                    btrtl_dev->project_id == CHIP_ID_8852C)
-                       set_bit(HCI_QUIRK_USE_MSFT_EXT_ADDRESS_FILTER, &hdev->quirks);
+                       hci_set_quirk(hdev,
+                                     HCI_QUIRK_USE_MSFT_EXT_ADDRESS_FILTER);
 
                hci_set_aosp_capable(hdev);
                break;
                 * but it doesn't support any features from page 2 -
                 * it either responds with garbage or with error status
                 */
-               set_bit(HCI_QUIRK_BROKEN_LOCAL_EXT_FEATURES_PAGE_2,
-                       &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_LOCAL_EXT_FEATURES_PAGE_2);
                break;
        default:
                break;
 
        hdev->send     = btsdio_send_frame;
 
        if (func->vendor == 0x0104 && func->device == 0x00c5)
-               set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_RESET_ON_CLOSE);
 
        err = hci_register_dev(hdev);
        if (err < 0) {
 
                 * Probably will need to be expanded in the future;
                 * without these the controller will lock up.
                 */
-               set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks);
-               set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks);
-               set_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks);
-               set_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks);
-               set_bit(HCI_QUIRK_BROKEN_READ_VOICE_SETTING, &hdev->quirks);
-               set_bit(HCI_QUIRK_BROKEN_READ_PAGE_SCAN_TYPE, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_STORED_LINK_KEY);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_ERR_DATA_REPORTING);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL);
+               hci_set_quirk(hdev, HCI_QUIRK_NO_SUSPEND_NOTIFIER);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_READ_VOICE_SETTING);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_READ_PAGE_SCAN_TYPE);
 
                /* Clear the reset quirk since this is not an actual
                 * early Bluetooth 1.1 device from CSR.
                 */
-               clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
-               clear_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
+               hci_clear_quirk(hdev, HCI_QUIRK_RESET_ON_CLOSE);
+               hci_clear_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY);
 
                /*
                 * Special workaround for these BT 4.0 chip clones, and potentially more:
        /* Mark HCI_OP_ENHANCED_SETUP_SYNC_CONN as broken as it doesn't seem to
         * work with the likes of HSP/HFP mSBC.
         */
-       set_bit(HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN);
 
        return 0;
 }
        }
 #endif
        if (id->driver_info & BTUSB_CW6622)
-               set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_STORED_LINK_KEY);
 
        if (id->driver_info & BTUSB_BCM2045)
-               set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_STORED_LINK_KEY);
 
        if (id->driver_info & BTUSB_BCM92035)
                hdev->setup = btusb_setup_bcm92035;
                hdev->reset = btmtk_reset_sync;
                hdev->set_bdaddr = btmtk_set_bdaddr;
                hdev->send = btusb_send_frame_mtk;
-               set_bit(HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN, &hdev->quirks);
-               set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN);
+               hci_set_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_SETUP);
                data->recv_acl = btmtk_usb_recv_acl;
                data->suspend = btmtk_usb_suspend;
                data->resume = btmtk_usb_resume;
        }
 
        if (id->driver_info & BTUSB_SWAVE) {
-               set_bit(HCI_QUIRK_FIXUP_INQUIRY_MODE, &hdev->quirks);
-               set_bit(HCI_QUIRK_BROKEN_LOCAL_COMMANDS, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_FIXUP_INQUIRY_MODE);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_LOCAL_COMMANDS);
        }
 
        if (id->driver_info & BTUSB_INTEL_BOOT) {
                hdev->manufacturer = 2;
-               set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_RAW_DEVICE);
        }
 
        if (id->driver_info & BTUSB_ATH3012) {
                data->setup_on_usb = btusb_setup_qca;
                hdev->set_bdaddr = btusb_set_bdaddr_ath3012;
-               set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
-               set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY);
+               hci_set_quirk(hdev, HCI_QUIRK_STRICT_DUPLICATE_FILTER);
        }
 
        if (id->driver_info & BTUSB_QCA_ROME) {
                hdev->shutdown = btusb_shutdown_qca;
                hdev->set_bdaddr = btusb_set_bdaddr_ath3012;
                hdev->reset = btusb_qca_reset;
-               set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY);
                btusb_check_needs_reset_resume(intf);
        }
 
                hdev->shutdown = btusb_shutdown_qca;
                hdev->set_bdaddr = btusb_set_bdaddr_wcn6855;
                hdev->reset = btusb_qca_reset;
-               set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY);
                hci_set_msft_opcode(hdev, 0xFD70);
        }
 
 
        if (id->driver_info & BTUSB_ACTIONS_SEMI) {
                /* Support is advertised, but not implemented */
-               set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks);
-               set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
-               set_bit(HCI_QUIRK_BROKEN_SET_RPA_TIMEOUT, &hdev->quirks);
-               set_bit(HCI_QUIRK_BROKEN_EXT_SCAN, &hdev->quirks);
-               set_bit(HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE, &hdev->quirks);
-               set_bit(HCI_QUIRK_BROKEN_EXT_CREATE_CONN, &hdev->quirks);
-               set_bit(HCI_QUIRK_BROKEN_WRITE_AUTH_PAYLOAD_TIMEOUT, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_ERR_DATA_REPORTING);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_SET_RPA_TIMEOUT);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_EXT_SCAN);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_EXT_CREATE_CONN);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_WRITE_AUTH_PAYLOAD_TIMEOUT);
        }
 
        if (!reset)
-               set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_RESET_ON_CLOSE);
 
        if (force_scofix || id->driver_info & BTUSB_WRONG_SCO_MTU) {
                if (!disable_scofix)
-                       set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks);
+                       hci_set_quirk(hdev, HCI_QUIRK_FIXUP_BUFFER_SIZE);
        }
 
        if (id->driver_info & BTUSB_BROKEN_ISOC)
                data->isoc = NULL;
 
        if (id->driver_info & BTUSB_WIDEBAND_SPEECH)
-               set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED);
 
        if (id->driver_info & BTUSB_INVALID_LE_STATES)
-               set_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_LE_STATES);
 
        if (id->driver_info & BTUSB_DIGIANSWER) {
                data->cmdreq_type = USB_TYPE_VENDOR;
-               set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_RESET_ON_CLOSE);
        }
 
        if (id->driver_info & BTUSB_CSR) {
 
                /* Old firmware would otherwise execute USB reset */
                if (bcdDevice < 0x117)
-                       set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
+                       hci_set_quirk(hdev, HCI_QUIRK_RESET_ON_CLOSE);
 
                /* This must be set first in case we disable it for fakes */
-               set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY);
 
                /* Fake CSR devices with broken commands */
                if (le16_to_cpu(udev->descriptor.idVendor)  == 0x0a12 &&
 
                /* New sniffer firmware has crippled HCI interface */
                if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997)
-                       set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
+                       hci_set_quirk(hdev, HCI_QUIRK_RAW_DEVICE);
        }
 
        if (id->driver_info & BTUSB_INTEL_BOOT) {
 
 
        if (!bacmp(&paddr->bdaddr, AML_BDADDR_DEFAULT)) {
                bt_dev_info(hdev, "amlbt using default bdaddr (%pM)", &paddr->bdaddr);
-               set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_INVALID_BDADDR);
        }
 
 exit:
 
         * Allow the bootloader to set a valid address through the
         * device tree.
         */
-       if (test_bit(HCI_QUIRK_INVALID_BDADDR, &hu->hdev->quirks))
-               set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hu->hdev->quirks);
+       if (hci_test_quirk(hu->hdev, HCI_QUIRK_INVALID_BDADDR))
+               hci_set_quirk(hu->hdev, HCI_QUIRK_USE_BDADDR_PROPERTY);
 
        if (!bcm_request_irq(bcm))
                err = bcm_setup_sleep(hu);
 
 
        bda = (struct hci_rp_read_bd_addr *)skb->data;
        if (!bcm4377_is_valid_bdaddr(bcm4377, &bda->bdaddr))
-               set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &bcm4377->hdev->quirks);
+               hci_set_quirk(bcm4377->hdev, HCI_QUIRK_USE_BDADDR_PROPERTY);
 
        kfree_skb(skb);
        return 0;
        hdev->setup = bcm4377_hci_setup;
 
        if (bcm4377->hw->broken_mws_transport_config)
-               set_bit(HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG);
        if (bcm4377->hw->broken_ext_scan)
-               set_bit(HCI_QUIRK_BROKEN_EXT_SCAN, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_EXT_SCAN);
        if (bcm4377->hw->broken_le_coded)
-               set_bit(HCI_QUIRK_BROKEN_LE_CODED, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_BROKEN_LE_CODED);
        if (bcm4377->hw->broken_le_ext_adv_report_phy)
-               set_bit(HCI_QUIRK_FIXUP_LE_EXT_ADV_REPORT_PHY, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_FIXUP_LE_EXT_ADV_REPORT_PHY);
 
        pci_set_drvdata(pdev, bcm4377);
        hci_set_drvdata(hdev, bcm4377);
 
         */
        if (!bacmp(¶ms.otp_bdaddr, BDADDR_ANY)) {
                bt_dev_info(hdev, "No device address configured");
-               set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_INVALID_BDADDR);
        }
 
        /* With this Intel bootloader only the hardware variant and device
 
        SET_HCIDEV_DEV(hdev, hu->tty->dev);
 
        if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags))
-               set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_RAW_DEVICE);
 
        if (test_bit(HCI_UART_EXT_CONFIG, &hu->hdev_flags))
-               set_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_EXTERNAL_CONFIG);
 
        if (!test_bit(HCI_UART_RESET_ON_INIT, &hu->hdev_flags))
-               set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_RESET_ON_CLOSE);
 
        /* Only call open() for the protocol after hdev is fully initialized as
         * open() (or a timer/workqueue it starts) may attempt to reference it.
 
                /* This means that there was an error getting the BD address
                 * during probe, so mark the device as having a bad address.
                 */
-               set_bit(HCI_QUIRK_INVALID_BDADDR, &hu->hdev->quirks);
+               hci_set_quirk(hu->hdev, HCI_QUIRK_INVALID_BDADDR);
        } else if (bacmp(&lldev->bdaddr, BDADDR_ANY)) {
                err = ll_set_bdaddr(hu->hdev, &lldev->bdaddr);
                if (err)
-                       set_bit(HCI_QUIRK_INVALID_BDADDR, &hu->hdev->quirks);
+                       hci_set_quirk(hu->hdev, HCI_QUIRK_INVALID_BDADDR);
        }
 
        /* Operational speed if any */
 
 
        if (btdev->man_id == NOKIA_ID_BCM2048) {
                hu->hdev->set_bdaddr = btbcm_set_bdaddr;
-               set_bit(HCI_QUIRK_INVALID_BDADDR, &hu->hdev->quirks);
+               hci_set_quirk(hu->hdev, HCI_QUIRK_INVALID_BDADDR);
                dev_dbg(dev, "bcm2048 has invalid bluetooth address!");
        }
 
 
        /* Enable controller to do both LE scan and BR/EDR inquiry
         * simultaneously.
         */
-       set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY);
 
        switch (soc_type) {
        case QCA_QCA2066:
        case QCA_WCN7850:
                qcadev = serdev_device_get_drvdata(hu->serdev);
                if (qcadev->bdaddr_property_broken)
-                       set_bit(HCI_QUIRK_BDADDR_PROPERTY_BROKEN, &hdev->quirks);
+                       hci_set_quirk(hdev, HCI_QUIRK_BDADDR_PROPERTY_BROKEN);
 
                hci_set_aosp_capable(hdev);
 
        hdev = qcadev->serdev_hu.hdev;
 
        if (power_ctrl_enabled) {
-               set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_SETUP);
                hdev->shutdown = qca_power_off;
        }
 
                 * be queried via hci. Same with the valid le states quirk.
                 */
                if (data->capabilities & QCA_CAP_WIDEBAND_SPEECH)
-                       set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
-                               &hdev->quirks);
+                       hci_set_quirk(hdev,
+                                     HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED);
 
                if (!(data->capabilities & QCA_CAP_VALID_LE_STATES))
-                       set_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks);
+                       hci_set_quirk(hdev, HCI_QUIRK_BROKEN_LE_STATES);
        }
 
        return 0;
                 * invoked and the SOC is already in the initial state, so
                 * don't also need to send the VSC.
                 */
-               if (test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks) ||
+               if (hci_test_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_SETUP) ||
                    hci_dev_test_flag(hdev, HCI_SETUP))
                        return;
 
 
         * BT SOC is completely powered OFF during BT OFF, holding port
         * open may drain the battery.
         */
-       if (test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
+       if (hci_test_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_SETUP)) {
                clear_bit(HCI_UART_PROTO_READY, &hu->flags);
                serdev_device_close(hu->serdev);
        }
        SET_HCIDEV_DEV(hdev, &hu->serdev->dev);
 
        if (test_bit(HCI_UART_NO_SUSPEND_NOTIFIER, &hu->flags))
-               set_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_NO_SUSPEND_NOTIFIER);
 
        if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags))
-               set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_RAW_DEVICE);
 
        if (test_bit(HCI_UART_EXT_CONFIG, &hu->hdev_flags))
-               set_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_EXTERNAL_CONFIG);
 
        if (test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags))
                return 0;
 
        hdev->get_codec_config_data = vhci_get_codec_config_data;
        hdev->wakeup = vhci_wakeup;
        hdev->setup = vhci_setup;
-       set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
-       set_bit(HCI_QUIRK_SYNC_FLOWCTL_SUPPORTED, &hdev->quirks);
+       hci_set_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_SETUP);
+       hci_set_quirk(hdev, HCI_QUIRK_SYNC_FLOWCTL_SUPPORTED);
 
        /* bit 6 is for external configuration */
        if (opcode & 0x40)
-               set_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_EXTERNAL_CONFIG);
 
        /* bit 7 is for raw device */
        if (opcode & 0x80)
-               set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
+               hci_set_quirk(hdev, HCI_QUIRK_RAW_DEVICE);
 
        if (hci_register_dev(hdev) < 0) {
                BT_ERR("Can't register HCI device");
 
                        hdev->setup = virtbt_setup_intel;
                        hdev->shutdown = virtbt_shutdown_generic;
                        hdev->set_bdaddr = virtbt_set_bdaddr_intel;
-                       set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
-                       set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
-                       set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
+                       hci_set_quirk(hdev, HCI_QUIRK_STRICT_DUPLICATE_FILTER);
+                       hci_set_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY);
+                       hci_set_quirk(hdev, HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED);
                        break;
 
                case VIRTIO_BT_CONFIG_VENDOR_REALTEK:
                        hdev->manufacturer = 93;
                        hdev->setup = virtbt_setup_realtek;
                        hdev->shutdown = virtbt_shutdown_generic;
-                       set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
-                       set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
+                       hci_set_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY);
+                       hci_set_quirk(hdev, HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED);
                        break;
                }
        }
 
         * This quirk must be set before hci_register_dev is called.
         */
        HCI_QUIRK_BROKEN_READ_PAGE_SCAN_TYPE,
+
+       __HCI_NUM_QUIRKS,
 };
 
 /* HCI device flags */
 
 
        unsigned int    auto_accept_delay;
 
-       unsigned long   quirks;
+       DECLARE_BITMAP(quirk_flags, __HCI_NUM_QUIRKS);
 
        atomic_t        cmd_cnt;
        unsigned int    acl_cnt;
        u8 (*classify_pkt_type)(struct hci_dev *hdev, struct sk_buff *skb);
 };
 
+#define hci_set_quirk(hdev, nr) set_bit((nr), (hdev)->quirk_flags)
+#define hci_clear_quirk(hdev, nr) clear_bit((nr), (hdev)->quirk_flags)
+#define hci_test_quirk(hdev, nr) test_bit((nr), (hdev)->quirk_flags)
+
 #define HCI_PHY_HANDLE(handle) (handle & 0xff)
 
 enum conn_reasons {
        } while (0)
 
 #define hci_dev_le_state_simultaneous(hdev) \
-       (!test_bit(HCI_QUIRK_BROKEN_LE_STATES, &(hdev)->quirks) && \
+       (!hci_test_quirk((hdev), HCI_QUIRK_BROKEN_LE_STATES) && \
         ((hdev)->le_states[4] & 0x08) &&       /* Central */ \
         ((hdev)->le_states[4] & 0x40) &&       /* Peripheral */ \
         ((hdev)->le_states[3] & 0x10))         /* Simultaneous */
                      ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_2M))
 
 #define le_coded_capable(dev) (((dev)->le_features[1] & HCI_LE_PHY_CODED) && \
-                              !test_bit(HCI_QUIRK_BROKEN_LE_CODED, \
-                                        &(dev)->quirks))
+                              !hci_test_quirk((dev), \
+                                              HCI_QUIRK_BROKEN_LE_CODED))
 
 #define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \
                         ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED))
 
 #define read_key_size_capable(dev) \
        ((dev)->commands[20] & 0x10 && \
-        !test_bit(HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE, &(dev)->quirks))
+        !hci_test_quirk((dev), HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE))
 
 #define read_voice_setting_capable(dev) \
        ((dev)->commands[9] & 0x04 && \
-        !test_bit(HCI_QUIRK_BROKEN_READ_VOICE_SETTING, &(dev)->quirks))
+        !hci_test_quirk((dev), HCI_QUIRK_BROKEN_READ_VOICE_SETTING))
 
 /* Use enhanced synchronous connection if command is supported and its quirk
  * has not been set.
  */
 #define enhanced_sync_conn_capable(dev) \
        (((dev)->commands[29] & 0x08) && \
-        !test_bit(HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN, &(dev)->quirks))
+        !hci_test_quirk((dev), HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN))
 
 /* Use ext scanning if set ext scan param and ext scan enable is supported */
 #define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \
                           ((dev)->commands[37] & 0x40) && \
-                          !test_bit(HCI_QUIRK_BROKEN_EXT_SCAN, &(dev)->quirks))
+                          !hci_test_quirk((dev), HCI_QUIRK_BROKEN_EXT_SCAN))
 
 /* Use ext create connection if command is supported */
 #define use_ext_conn(dev) (((dev)->commands[37] & 0x80) && \
-       !test_bit(HCI_QUIRK_BROKEN_EXT_CREATE_CONN, &(dev)->quirks))
+       !hci_test_quirk((dev), HCI_QUIRK_BROKEN_EXT_CREATE_CONN))
 /* Extended advertising support */
 #define ext_adv_capable(dev) (((dev)->le_features[1] & HCI_LE_EXT_ADV))
 
  */
 #define use_enhanced_conn_complete(dev) ((ll_privacy_capable(dev) || \
                                         ext_adv_capable(dev)) && \
-                                        !test_bit(HCI_QUIRK_BROKEN_EXT_CREATE_CONN, \
-                                                &(dev)->quirks))
+                                        !hci_test_quirk((dev), \
+                                                        HCI_QUIRK_BROKEN_EXT_CREATE_CONN))
 
 /* Periodic advertising support */
 #define per_adv_capable(dev) (((dev)->le_features[1] & HCI_LE_PERIODIC_ADV))
 #define sync_recv_capable(dev) ((dev)->le_features[3] & HCI_LE_ISO_SYNC_RECEIVER)
 
 #define mws_transport_config_capable(dev) (((dev)->commands[30] & 0x08) && \
-       (!test_bit(HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG, &(dev)->quirks)))
+       (!hci_test_quirk((dev), HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG)))
 
 /* ----- HCI protocols ----- */
 #define HCI_PROTO_DEFER             0x01
 
        /* Devices that are marked for raw-only usage are unconfigured
         * and should not be included in normal operation.
         */
-       if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
+       if (hci_test_quirk(hdev, HCI_QUIRK_RAW_DEVICE))
                hci_dev_set_flag(hdev, HCI_UNCONFIGURED);
 
        /* Mark Remote Wakeup connection flag as supported if driver has wakeup
        int ret = 0;
 
        if (!hdev->suspend_notifier.notifier_call &&
-           !test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks)) {
+           !hci_test_quirk(hdev, HCI_QUIRK_NO_SUSPEND_NOTIFIER)) {
                hdev->suspend_notifier.notifier_call = hci_suspend_notifier;
                ret = register_pm_notifier(&hdev->suspend_notifier);
        }
 
        struct hci_dev *hdev = file->private_data;                            \
        char buf[3];                                                          \
                                                                              \
-       buf[0] = test_bit(__quirk, &hdev->quirks) ? 'Y' : 'N';                \
+       buf[0] = test_bit(__quirk, hdev->quirk_flags) ? 'Y' : 'N';            \
        buf[1] = '\n';                                                        \
        buf[2] = '\0';                                                        \
        return simple_read_from_buffer(user_buf, count, ppos, buf, 2);        \
        if (err)                                                              \
                return err;                                                   \
                                                                              \
-       if (enable == test_bit(__quirk, &hdev->quirks))                       \
+       if (enable == test_bit(__quirk, hdev->quirk_flags))                   \
                return -EALREADY;                                             \
                                                                              \
-       change_bit(__quirk, &hdev->quirks);                                   \
+       change_bit(__quirk, hdev->quirk_flags);                               \
                                                                              \
        return count;                                                         \
 }                                                                            \
         * for the vendor callback. Instead just store the desired value and
         * the setting will be programmed when the controller gets powered on.
         */
-       if (test_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks) &&
+       if (hci_test_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_DIAG) &&
            (!test_bit(HCI_RUNNING, &hdev->flags) ||
             hci_dev_test_flag(hdev, HCI_USER_CHANNEL)))
                goto done;
 
                return rp->status;
 
        if (hdev->max_page < rp->max_page) {
-               if (test_bit(HCI_QUIRK_BROKEN_LOCAL_EXT_FEATURES_PAGE_2,
-                            &hdev->quirks))
+               if (hci_test_quirk(hdev,
+                                  HCI_QUIRK_BROKEN_LOCAL_EXT_FEATURES_PAGE_2))
                        bt_dev_warn(hdev, "broken local ext features page 2");
                else
                        hdev->max_page = rp->max_page;
        hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt);
        hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt);
 
-       if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) {
+       if (hci_test_quirk(hdev, HCI_QUIRK_FIXUP_BUFFER_SIZE)) {
                hdev->sco_mtu  = 64;
                hdev->sco_pkts = 8;
        }
                 * state to indicate completion.
                 */
                if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) ||
-                   !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks))
+                   !hci_test_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY))
                        hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
                goto unlock;
        }
                 * state to indicate completion.
                 */
                if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) ||
-                   !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks))
+                   !hci_test_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY))
                        hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
        }
 
        /* We skip the WRITE_AUTH_PAYLOAD_TIMEOUT for ATS2851 based controllers
         * to avoid unexpected SMP command errors when pairing.
         */
-       if (test_bit(HCI_QUIRK_BROKEN_WRITE_AUTH_PAYLOAD_TIMEOUT,
-                    &hdev->quirks))
+       if (hci_test_quirk(hdev, HCI_QUIRK_BROKEN_WRITE_AUTH_PAYLOAD_TIMEOUT))
                goto notify;
 
        /* Set the default Authenticated Payload Timeout after
         * while we have an existing one in peripheral role.
         */
        if (hdev->conn_hash.le_num_peripheral > 0 &&
-           (test_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks) ||
+           (hci_test_quirk(hdev, HCI_QUIRK_BROKEN_LE_STATES) ||
             !(hdev->le_states[3] & 0x10)))
                return NULL;
 
                evt_type = __le16_to_cpu(info->type) & LE_EXT_ADV_EVT_TYPE_MASK;
                legacy_evt_type = ext_evt_type_to_legacy(hdev, evt_type);
 
-               if (test_bit(HCI_QUIRK_FIXUP_LE_EXT_ADV_REPORT_PHY,
-                            &hdev->quirks)) {
+               if (hci_test_quirk(hdev,
+                                  HCI_QUIRK_FIXUP_LE_EXT_ADV_REPORT_PHY)) {
                        info->primary_phy &= 0x1f;
                        info->secondary_phy &= 0x1f;
                }
 
        if (hdev->discovery.type != DISCOV_TYPE_INTERLEAVED)
                goto _return;
 
-       if (test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) {
+       if (hci_test_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY)) {
                if (!test_bit(HCI_INQUIRY, &hdev->flags) &&
                    hdev->discovery.state != DISCOVERY_RESOLVING)
                        goto discov_stopped;
        if (ret < 0 || !bacmp(&ba, BDADDR_ANY))
                return;
 
-       if (test_bit(HCI_QUIRK_BDADDR_PROPERTY_BROKEN, &hdev->quirks))
+       if (hci_test_quirk(hdev, HCI_QUIRK_BDADDR_PROPERTY_BROKEN))
                baswap(&hdev->public_addr, &ba);
        else
                bacpy(&hdev->public_addr, &ba);
        bt_dev_dbg(hdev, "");
 
        /* Reset */
-       if (!test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) {
+       if (!hci_test_quirk(hdev, HCI_QUIRK_RESET_ON_CLOSE)) {
                err = hci_reset_sync(hdev);
                if (err)
                        return err;
 {
        int err;
 
-       if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
+       if (hci_test_quirk(hdev, HCI_QUIRK_RAW_DEVICE))
                return 0;
 
        err = hci_init0_sync(hdev);
         * supported commands.
         */
        if (hdev->hci_ver > BLUETOOTH_VER_1_1 &&
-           !test_bit(HCI_QUIRK_BROKEN_LOCAL_COMMANDS, &hdev->quirks))
+           !hci_test_quirk(hdev, HCI_QUIRK_BROKEN_LOCAL_COMMANDS))
                return __hci_cmd_sync_status(hdev, HCI_OP_READ_LOCAL_COMMANDS,
                                             0, NULL, HCI_CMD_TIMEOUT);
 
        bt_dev_dbg(hdev, "");
 
        /* Reset */
-       if (!test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) {
+       if (!hci_test_quirk(hdev, HCI_QUIRK_RESET_ON_CLOSE)) {
                err = hci_reset_sync(hdev);
                if (err)
                        return err;
        if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED))
                return 0;
 
-       if (test_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks))
+       if (hci_test_quirk(hdev, HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL))
                return 0;
 
        memset(&cp, 0, sizeof(cp));
         * a hci_set_event_filter_sync() call succeeds, but we do
         * the check both for parity and as a future reminder.
         */
-       if (test_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks))
+       if (hci_test_quirk(hdev, HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL))
                return 0;
 
        return hci_set_event_filter_sync(hdev, HCI_FLT_CLEAR_ALL, 0x00,
 
        /* Check if the controller supports SCO and HCI_OP_WRITE_SYNC_FLOWCTL */
        if (!lmp_sco_capable(hdev) || !(hdev->commands[10] & BIT(4)) ||
-           !test_bit(HCI_QUIRK_SYNC_FLOWCTL_SUPPORTED, &hdev->quirks))
+           !hci_test_quirk(hdev, HCI_QUIRK_SYNC_FLOWCTL_SUPPORTED))
                return 0;
 
        memset(&cp, 0, sizeof(cp));
        u8 mode;
 
        if (!lmp_inq_rssi_capable(hdev) &&
-           !test_bit(HCI_QUIRK_FIXUP_INQUIRY_MODE, &hdev->quirks))
+           !hci_test_quirk(hdev, HCI_QUIRK_FIXUP_INQUIRY_MODE))
                return 0;
 
        /* If Extended Inquiry Result events are supported, then
        }
 
        if (lmp_inq_rssi_capable(hdev) ||
-           test_bit(HCI_QUIRK_FIXUP_INQUIRY_MODE, &hdev->quirks))
+           hci_test_quirk(hdev, HCI_QUIRK_FIXUP_INQUIRY_MODE))
                events[4] |= 0x02; /* Inquiry Result with RSSI */
 
        if (lmp_ext_feat_capable(hdev))
        struct hci_cp_read_stored_link_key cp;
 
        if (!(hdev->commands[6] & 0x20) ||
-           test_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks))
+           hci_test_quirk(hdev, HCI_QUIRK_BROKEN_STORED_LINK_KEY))
                return 0;
 
        memset(&cp, 0, sizeof(cp));
 {
        if (!(hdev->commands[18] & 0x04) ||
            !(hdev->features[0][6] & LMP_ERR_DATA_REPORTING) ||
-           test_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks))
+           hci_test_quirk(hdev, HCI_QUIRK_BROKEN_ERR_DATA_REPORTING))
                return 0;
 
        return __hci_cmd_sync_status(hdev, HCI_OP_READ_DEF_ERR_DATA_REPORTING,
         * this command in the bit mask of supported commands.
         */
        if (!(hdev->commands[13] & 0x01) ||
-           test_bit(HCI_QUIRK_BROKEN_READ_PAGE_SCAN_TYPE, &hdev->quirks))
+           hci_test_quirk(hdev, HCI_QUIRK_BROKEN_READ_PAGE_SCAN_TYPE))
                return 0;
 
        return __hci_cmd_sync_status(hdev, HCI_OP_READ_PAGE_SCAN_TYPE,
 static int hci_le_read_tx_power_sync(struct hci_dev *hdev)
 {
        if (!(hdev->commands[38] & 0x80) ||
-           test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks))
+           hci_test_quirk(hdev, HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER))
                return 0;
 
        return __hci_cmd_sync_status(hdev, HCI_OP_LE_READ_TRANSMIT_POWER,
        __le16 timeout = cpu_to_le16(hdev->rpa_timeout);
 
        if (!(hdev->commands[35] & 0x04) ||
-           test_bit(HCI_QUIRK_BROKEN_SET_RPA_TIMEOUT, &hdev->quirks))
+           hci_test_quirk(hdev, HCI_QUIRK_BROKEN_SET_RPA_TIMEOUT))
                return 0;
 
        return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_RPA_TIMEOUT,
         * just disable this command.
         */
        if (!(hdev->commands[6] & 0x80) ||
-           test_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks))
+           hci_test_quirk(hdev, HCI_QUIRK_BROKEN_STORED_LINK_KEY))
                return 0;
 
        memset(&cp, 0, sizeof(cp));
 
        if (!(hdev->commands[18] & 0x08) ||
            !(hdev->features[0][6] & LMP_ERR_DATA_REPORTING) ||
-           test_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks))
+           hci_test_quirk(hdev, HCI_QUIRK_BROKEN_ERR_DATA_REPORTING))
                return 0;
 
        if (enabled == hdev->err_data_reporting)
        size_t i;
 
        if (!hci_dev_test_flag(hdev, HCI_SETUP) &&
-           !test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks))
+           !hci_test_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_SETUP))
                return 0;
 
        bt_dev_dbg(hdev, "");
                ret = hdev->setup(hdev);
 
        for (i = 0; i < ARRAY_SIZE(hci_broken_table); i++) {
-               if (test_bit(hci_broken_table[i].quirk, &hdev->quirks))
+               if (hci_test_quirk(hdev, hci_broken_table[i].quirk))
                        bt_dev_warn(hdev, "%s", hci_broken_table[i].desc);
        }
 
         * BD_ADDR invalid before creating the HCI device or in
         * its setup callback.
         */
-       invalid_bdaddr = test_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks) ||
-                        test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
+       invalid_bdaddr = hci_test_quirk(hdev, HCI_QUIRK_INVALID_BDADDR) ||
+                        hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY);
        if (!ret) {
-               if (test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks) &&
+               if (hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY) &&
                    !bacmp(&hdev->public_addr, BDADDR_ANY))
                        hci_dev_get_bd_addr_from_property(hdev);
 
         * In case any of them is set, the controller has to
         * start up as unconfigured.
         */
-       if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) ||
+       if (hci_test_quirk(hdev, HCI_QUIRK_EXTERNAL_CONFIG) ||
            invalid_bdaddr)
                hci_dev_set_flag(hdev, HCI_UNCONFIGURED);
 
         * then they need to be reprogrammed after the init procedure
         * completed.
         */
-       if (test_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks) &&
+       if (hci_test_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_DIAG) &&
            !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
            hci_dev_test_flag(hdev, HCI_VENDOR_DIAG) && hdev->set_diag)
                ret = hdev->set_diag(hdev, true);
        /* Reset device */
        skb_queue_purge(&hdev->cmd_q);
        atomic_set(&hdev->cmd_cnt, 1);
-       if (test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks) &&
+       if (hci_test_quirk(hdev, HCI_QUIRK_RESET_ON_CLOSE) &&
            !auto_off && !hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) {
                set_bit(HCI_INIT, &hdev->flags);
                hci_reset_sync(hdev);
                own_addr_type = ADDR_LE_DEV_PUBLIC;
 
        if (hci_is_adv_monitoring(hdev) ||
-           (test_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks) &&
+           (hci_test_quirk(hdev, HCI_QUIRK_STRICT_DUPLICATE_FILTER) &&
            hdev->discovery.result_filtering)) {
                /* Duplicate filter should be disabled when some advertisement
                 * monitor is activated, otherwise AdvMon can only receive one
                 * and LE scanning are done sequentially with separate
                 * timeouts.
                 */
-               if (test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY,
-                            &hdev->quirks)) {
+               if (hci_test_quirk(hdev, HCI_QUIRK_SIMULTANEOUS_DISCOVERY)) {
                        timeout = msecs_to_jiffies(DISCOV_LE_TIMEOUT);
                        /* During simultaneous discovery, we double LE scan
                         * interval. We must leave some time for the controller
        /* Some fake CSR controllers lock up after setting this type of
         * filter, so avoid sending the request altogether.
         */
-       if (test_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks))
+       if (hci_test_quirk(hdev, HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL))
                return 0;
 
        /* Always clear event filter when starting */
 
                /* Devices marked as raw-only are neither configured
                 * nor unconfigured controllers.
                 */
-               if (test_bit(HCI_QUIRK_RAW_DEVICE, &d->quirks))
+               if (hci_test_quirk(d, HCI_QUIRK_RAW_DEVICE))
                        continue;
 
                if (!hci_dev_test_flag(d, HCI_UNCONFIGURED)) {
                /* Devices marked as raw-only are neither configured
                 * nor unconfigured controllers.
                 */
-               if (test_bit(HCI_QUIRK_RAW_DEVICE, &d->quirks))
+               if (hci_test_quirk(d, HCI_QUIRK_RAW_DEVICE))
                        continue;
 
                if (hci_dev_test_flag(d, HCI_UNCONFIGURED)) {
                /* Devices marked as raw-only are neither configured
                 * nor unconfigured controllers.
                 */
-               if (test_bit(HCI_QUIRK_RAW_DEVICE, &d->quirks))
+               if (hci_test_quirk(d, HCI_QUIRK_RAW_DEVICE))
                        continue;
 
                if (hci_dev_test_flag(d, HCI_UNCONFIGURED))
 
 static bool is_configured(struct hci_dev *hdev)
 {
-       if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) &&
+       if (hci_test_quirk(hdev, HCI_QUIRK_EXTERNAL_CONFIG) &&
            !hci_dev_test_flag(hdev, HCI_EXT_CONFIGURED))
                return false;
 
-       if ((test_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks) ||
-            test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks)) &&
+       if ((hci_test_quirk(hdev, HCI_QUIRK_INVALID_BDADDR) ||
+            hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY)) &&
            !bacmp(&hdev->public_addr, BDADDR_ANY))
                return false;
 
 {
        u32 options = 0;
 
-       if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) &&
+       if (hci_test_quirk(hdev, HCI_QUIRK_EXTERNAL_CONFIG) &&
            !hci_dev_test_flag(hdev, HCI_EXT_CONFIGURED))
                options |= MGMT_OPTION_EXTERNAL_CONFIG;
 
-       if ((test_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks) ||
-            test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks)) &&
+       if ((hci_test_quirk(hdev, HCI_QUIRK_INVALID_BDADDR) ||
+            hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY)) &&
            !bacmp(&hdev->public_addr, BDADDR_ANY))
                options |= MGMT_OPTION_PUBLIC_ADDRESS;
 
        memset(&rp, 0, sizeof(rp));
        rp.manufacturer = cpu_to_le16(hdev->manufacturer);
 
-       if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks))
+       if (hci_test_quirk(hdev, HCI_QUIRK_EXTERNAL_CONFIG))
                options |= MGMT_OPTION_EXTERNAL_CONFIG;
 
        if (hdev->set_bdaddr)
                if (lmp_sc_capable(hdev))
                        settings |= MGMT_SETTING_SECURE_CONN;
 
-               if (test_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
-                            &hdev->quirks))
+               if (hci_test_quirk(hdev, HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED))
                        settings |= MGMT_SETTING_WIDEBAND_SPEECH;
        }
 
                settings |= MGMT_SETTING_ADVERTISING;
        }
 
-       if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) ||
-           hdev->set_bdaddr)
+       if (hci_test_quirk(hdev, HCI_QUIRK_EXTERNAL_CONFIG) || hdev->set_bdaddr)
                settings |= MGMT_SETTING_CONFIGURATION;
 
        if (cis_central_capable(hdev))
 
        bt_dev_dbg(hdev, "sock %p", sk);
 
-       if (!test_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks))
+       if (!hci_test_quirk(hdev, HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED))
                return mgmt_cmd_status(sk, hdev->id,
                                       MGMT_OP_SET_WIDEBAND_SPEECH,
                                       MGMT_STATUS_NOT_SUPPORTED);
                return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_EXTERNAL_CONFIG,
                                         MGMT_STATUS_INVALID_PARAMS);
 
-       if (!test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks))
+       if (!hci_test_quirk(hdev, HCI_QUIRK_EXTERNAL_CONFIG))
                return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_EXTERNAL_CONFIG,
                                       MGMT_STATUS_NOT_SUPPORTED);
 
 {
        struct mgmt_ev_ext_index ev;
 
-       if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
+       if (hci_test_quirk(hdev, HCI_QUIRK_RAW_DEVICE))
                return;
 
        if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) {
        struct mgmt_ev_ext_index ev;
        struct cmd_lookup match = { NULL, hdev, MGMT_STATUS_INVALID_INDEX };
 
-       if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
+       if (hci_test_quirk(hdev, HCI_QUIRK_RAW_DEVICE))
                return;
 
        mgmt_pending_foreach(0, hdev, true, cmd_complete_rsp, &match);
        if (hdev->discovery.rssi != HCI_RSSI_INVALID &&
            (rssi == HCI_RSSI_INVALID ||
            (rssi < hdev->discovery.rssi &&
-            !test_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks))))
+            !hci_test_quirk(hdev, HCI_QUIRK_STRICT_DUPLICATE_FILTER))))
                return  false;
 
        if (hdev->discovery.uuid_count != 0) {
        /* If duplicate filtering does not report RSSI changes, then restart
         * scanning to ensure updated result with updated RSSI values.
         */
-       if (test_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks)) {
+       if (hci_test_quirk(hdev, HCI_QUIRK_STRICT_DUPLICATE_FILTER)) {
                /* Validate RSSI value against the RSSI threshold once more. */
                if (hdev->discovery.rssi != HCI_RSSI_INVALID &&
                    rssi < hdev->discovery.rssi)
 
 
        handle_data = msft_find_handle_data(hdev, ev->monitor_handle, false);
 
-       if (!test_bit(HCI_QUIRK_USE_MSFT_EXT_ADDRESS_FILTER, &hdev->quirks)) {
+       if (!hci_test_quirk(hdev, HCI_QUIRK_USE_MSFT_EXT_ADDRESS_FILTER)) {
                if (!handle_data)
                        return;
                mgmt_handle = handle_data->mgmt_handle;