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

From: Greg KH
Date: Wed Jan 08 2025 - 07:35:32 EST


On Fri, Dec 13, 2024 at 12:04:22PM +0800, Ying Hsu wrote:
> 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 <yinghsu@xxxxxxxxxxxx>
> ---
> This commit has been tested on a chromebook with AX211.
>
> Changes in v2:
> - Add check for the existence of a valid USB interface 1.

You forgot a Documentation/ABI/ entry.

Also, the code isn't quite right:

> @@ -4008,6 +4034,10 @@ static int btusb_probe(struct usb_interface *intf,
> data->isoc, data);
> if (err < 0)
> goto out_free_dev;
> +
> + err = device_create_file(&intf->dev, &dev_attr_isoc_alt);
> + if (err)
> + goto out_free_dev;

You just raced with userspace and lost. Please properly use a device
group instead. That makes for smaller code, and it works properly.

thanks,

greg k-h