usb: gadget: f_acm: make bInterfaceProtocol configurable
PATCH v2 1/1 usb: gadget: f_acm: make bInterfaceProtocol configurable
The bInterfaceProtocol is hardcoded to USB_CDC_ACM_PROTO_AT_V25TER. This will lead to problems with ModemManger which will gladly try to probe that port as a modem if the gadget also has a network function. ModemManager will try to send AT commands to the ACM port. Make the bInterfaceProtocol configurable. For this, track the number of instances and only allow write to the property if there are no intances (yet).
This will also set bFunctionProtocol to the same value, see commit 5c8db070b448 ("USB: Change acm_iad_descriptor bFunctionProtocol to USB_CDC_ACM_PROTO_AT_V25TER") for more details.
---
See the following link for the filter logic:
https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/blob/main/src/mm-filter.c?ref_type=heads#L303
v2:
- rename refcnt to instances
- add a comment what the mutex will protect
- mention the intention of "instances" in the commit message
--- .../ABI/testing/configfs-usb-gadget-acm | 7 +++ drivers/usb/gadget/function/f_acm.c | 52 ++++++++++++++++++- drivers/usb/gadget/function/u_serial.h | 4 ++ 3 files changed, 61 insertions(+), 2 deletions(-)
Documentation/ABI/testing/configfs-usb-gadget-acm +7 -0
@@ -6,3 +6,10 @@ Description: This item contains just one readonly attribute: port_num. It contains the port number of the /dev/ttyGS<n> device associated with acm function's instance "name". + +What: /config/usb-gadget/gadget/functions/acm.name/protocol +Date: Aug 2024 +KernelVersion: 6.13 +Description: + Reported bInterfaceProtocol for the ACM device. For legacy + reasons, this defaults to 1 (USB_CDC_ACM_PROTO_AT_V25TER).
drivers/usb/gadget/function/f_acm.c +50 -2
115 lines not on this page · raw message
drivers/usb/gadget/function/u_serial.h +4 -0
@@ -17,6 +17,10 @@struct f_serial_opts {struct usb_function_instance func_inst;u8 port_num; +u8 protocol; + +struct mutex lock;/* protect instances */ +int instances; };/*
Signature · 1 line
2.39.2