Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: cdc-acm: return correct error code on unsupported break

In ACM support for sending breaks to devices is optional.
If a device says that it doenot support sending breaks,
the host must respect that.
Given the number of optional features providing tty operations
for each combination is not practical and errors need to be
returned dynamically if unsupported features are requested.

In case a device does not support break, we want the tty layer
to treat that like it treats drivers that statically cannot
support sending a break. It ignores the inability and does nothing.
This patch uses EOPNOTSUPP to indicate that.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Fixes: 9e98966c7bb94 ("tty: rework break handling")
Link: https://lore.kernel.org/r/20231207132639.18250-1-oneukum@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Oliver Neukum and committed by
Greg Kroah-Hartman
66aad7d8 53b5ff83

+6
+3
drivers/tty/tty_io.c
··· 2489 2489 if (!retval) { 2490 2490 msleep_interruptible(duration); 2491 2491 retval = tty->ops->break_ctl(tty, 0); 2492 + } else if (retval == -EOPNOTSUPP) { 2493 + /* some drivers can tell only dynamically */ 2494 + retval = 0; 2492 2495 } 2493 2496 tty_write_unlock(tty); 2494 2497
+3
drivers/usb/class/cdc-acm.c
··· 916 916 struct acm *acm = tty->driver_data; 917 917 int retval; 918 918 919 + if (!(acm->ctrl_caps & USB_CDC_CAP_BRK)) 920 + return -EOPNOTSUPP; 921 + 919 922 retval = acm_send_break(acm, state ? 0xffff : 0); 920 923 if (retval < 0) 921 924 dev_dbg(&acm->control->dev,