Skip to content

Commit b16b327

Browse files
Ying HsuVudentz
authored andcommitted
Bluetooth: btusb: add sysfs attribute to control USB alt setting
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. Signed-off-by: Ying Hsu <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent a6587d7 commit b16b327

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

drivers/bluetooth/btusb.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3647,6 +3647,32 @@ static const struct file_operations force_poll_sync_fops = {
36473647
.llseek = default_llseek,
36483648
};
36493649

3650+
static ssize_t isoc_alt_show(struct device *dev,
3651+
struct device_attribute *attr,
3652+
char *buf)
3653+
{
3654+
struct btusb_data *data = dev_get_drvdata(dev);
3655+
3656+
return sysfs_emit(buf, "%d\n", data->isoc_altsetting);
3657+
}
3658+
3659+
static ssize_t isoc_alt_store(struct device *dev,
3660+
struct device_attribute *attr,
3661+
const char *buf, size_t count)
3662+
{
3663+
struct btusb_data *data = dev_get_drvdata(dev);
3664+
int alt;
3665+
int ret;
3666+
3667+
if (kstrtoint(buf, 10, &alt))
3668+
return -EINVAL;
3669+
3670+
ret = btusb_switch_alt_setting(data->hdev, alt);
3671+
return ret < 0 ? ret : count;
3672+
}
3673+
3674+
static DEVICE_ATTR_RW(isoc_alt);
3675+
36503676
static int btusb_probe(struct usb_interface *intf,
36513677
const struct usb_device_id *id)
36523678
{
@@ -4010,6 +4036,10 @@ static int btusb_probe(struct usb_interface *intf,
40104036
data->isoc, data);
40114037
if (err < 0)
40124038
goto out_free_dev;
4039+
4040+
err = device_create_file(&intf->dev, &dev_attr_isoc_alt);
4041+
if (err)
4042+
goto out_free_dev;
40134043
}
40144044

40154045
if (IS_ENABLED(CONFIG_BT_HCIBTUSB_BCM) && data->diag) {
@@ -4056,8 +4086,10 @@ static void btusb_disconnect(struct usb_interface *intf)
40564086
hdev = data->hdev;
40574087
usb_set_intfdata(data->intf, NULL);
40584088

4059-
if (data->isoc)
4089+
if (data->isoc) {
4090+
device_remove_file(&intf->dev, &dev_attr_isoc_alt);
40604091
usb_set_intfdata(data->isoc, NULL);
4092+
}
40614093

40624094
if (data->diag)
40634095
usb_set_intfdata(data->diag, NULL);

0 commit comments

Comments
 (0)