Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
From: Hui Wang <hui.wang@canonical.com>
To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org,
	johan.hedberg@gmail.com
Subject: [PATCH] Bluetooth: btusb: Add a module parameter ignore_id for debugging
Date: Sun,  2 Aug 2020 12:21:38 +0800
Message-ID: <20200802042138.9149-1-hui.wang@canonical.com> (raw)

There is always an on-board usb bluetooth hci on the laptops, if
the bluetooth function doesn't work well like a bt headset can't work
with HSP/HFP mode, we often plug an external usb BT hci to verify if
that headset could work with the exteral BT hci or not, in this
situation, there will be 2 hcis (hci0 and hci1) in the system, and
so far, the gnome can't handle the hci1 well so we met lots of
problems when debugging with hci1 under gnome.

After adding this new module parameter, we could ban the on-board
usb hci by putting btusb.ignore_id=idVendor,idProduct to the bootargs,
then the external usb hci will be hci0 and there is only one hci
in the system. We could easily debug with the external usb bluetooth
hci after this change.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 drivers/bluetooth/btusb.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 5f022e9cf667..f6ab0cb313ed 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -32,6 +32,7 @@ static bool force_scofix;
 static bool enable_autosuspend = IS_ENABLED(CONFIG_BT_HCIBTUSB_AUTOSUSPEND);
 
 static bool reset = true;
+static u16 ignore_id[2];
 
 static struct usb_driver btusb_driver;
 
@@ -3714,11 +3715,17 @@ static int btusb_probe(struct usb_interface *intf,
 	struct gpio_desc *reset_gpio;
 	struct btusb_data *data;
 	struct hci_dev *hdev;
+	struct usb_device *dev;
 	unsigned ifnum_base;
 	int i, err;
 
 	BT_DBG("intf %p id %p", intf, id);
 
+	dev = interface_to_usbdev(intf);
+	if (ignore_id[0] == le16_to_cpu(dev->descriptor.idVendor) &&
+	    ignore_id[1] == le16_to_cpu(dev->descriptor.idProduct))
+		return -ENODEV;
+
 	/* interface numbers are hardcoded in the spec */
 	if (intf->cur_altsetting->desc.bInterfaceNumber != 0) {
 		if (!(id->driver_info & BTUSB_IFNUM_2))
@@ -4273,6 +4280,10 @@ MODULE_PARM_DESC(enable_autosuspend, "Enable USB autosuspend by default");
 module_param(reset, bool, 0644);
 MODULE_PARM_DESC(reset, "Send HCI reset command on initialization");
 
+module_param_array(ignore_id, ushort, NULL, 0644);
+MODULE_PARM_DESC(ignore_id, "btusb will ignore this device if the id matches."
+		 " e.g. ignore_id=idVendor,idProduct");
+
 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
 MODULE_DESCRIPTION("Generic Bluetooth USB driver ver " VERSION);
 MODULE_VERSION(VERSION);
-- 
2.17.1


             reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-02  4:21 Hui Wang [this message]
2020-08-02 14:58 ` Marcel Holtmann
2020-08-03  2:55   ` Hui Wang
2020-08-03  6:45     ` Marcel Holtmann
2020-08-03  7:59       ` Hui Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200802042138.9149-1-hui.wang@canonical.com \
    --to=hui.wang@canonical.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org
	public-inbox-index linux-bluetooth

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git