[PATCH] Bluetooth: btusb: add sysfs attribute to control USB alt setting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When a Bluetooth raw socket is open, the HCI event related to SCO
connection changes are not dispatched to the hci_event module, and
the underlying Bluetooth controller's USB Interface 1 will not be
updated accordingly.

This patch adds `isoc_alt` sysfs attribute, allowing user space
to update the alternate setting of the USB interface alternate
setting as needed.

BUG=b:382526205
TEST=read and write /sys/class/bluetooth/hci0/isoc_alt

Series-to: linux-bluetooth@xxxxxxxxxxxxxxx
Series-to: luiz.dentz@xxxxxxxxx
Series-cc: chromeos-bluetooth-upstreaming@xxxxxxxxxxxx

Commit-notes:
This commit has been tested on a chromebook with AX211.
END

Change-Id: Ifc708cc471a8834b344c26fce1ce2fe3e5992cad
Signed-off-by: Ying Hsu <yinghsu@xxxxxxxxxxxx>
---
 drivers/bluetooth/btusb.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 279fe6c115fa..e8446f3e026e 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3645,6 +3645,32 @@ static const struct file_operations force_poll_sync_fops = {
 	.llseek		= default_llseek,
 };
 
+static ssize_t isoc_alt_show(struct device *dev,
+			     struct device_attribute *attr,
+			     char *buf)
+{
+	struct btusb_data *data = dev_get_drvdata(dev);
+
+	return sysfs_emit(buf, "%d\n", data->isoc_altsetting);
+}
+
+static ssize_t isoc_alt_store(struct device *dev,
+			      struct device_attribute *attr,
+			      const char *buf, size_t count)
+{
+	struct btusb_data *data = dev_get_drvdata(dev);
+	int alt;
+	int ret;
+
+	if (kstrtoint(buf, 10, &alt))
+		return -EINVAL;
+
+	ret = btusb_switch_alt_setting(data->hdev, alt);
+	return ret < 0 ? ret : count;
+}
+
+static DEVICE_ATTR_RW(isoc_alt);
+
 static int btusb_probe(struct usb_interface *intf,
 		       const struct usb_device_id *id)
 {
@@ -4032,6 +4058,10 @@ static int btusb_probe(struct usb_interface *intf,
 	debugfs_create_file("force_poll_sync", 0644, hdev->debugfs, data,
 			    &force_poll_sync_fops);
 
+	err = device_create_file(&intf->dev, &dev_attr_isoc_alt);
+	if (err)
+		goto out_free_dev;
+
 	return 0;
 
 out_free_dev:
@@ -4052,6 +4082,8 @@ static void btusb_disconnect(struct usb_interface *intf)
 		return;
 
 	hdev = data->hdev;
+	device_remove_file(&intf->dev, &dev_attr_isoc_alt);
+
 	usb_set_intfdata(data->intf, NULL);
 
 	if (data->isoc)
-- 
2.47.0.338.g60cca15819-goog





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux