Skip to content

Commit 66aad7d

Browse files
oneukumgregkh
authored andcommitted
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 <[email protected]> Fixes: 9e98966 ("tty: rework break handling") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 53b5ff8 commit 66aad7d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

drivers/tty/tty_io.c

+3
Original file line numberDiff line numberDiff line change
@@ -2489,6 +2489,9 @@ static int send_break(struct tty_struct *tty, unsigned int duration)
24892489
if (!retval) {
24902490
msleep_interruptible(duration);
24912491
retval = tty->ops->break_ctl(tty, 0);
2492+
} else if (retval == -EOPNOTSUPP) {
2493+
/* some drivers can tell only dynamically */
2494+
retval = 0;
24922495
}
24932496
tty_write_unlock(tty);
24942497

drivers/usb/class/cdc-acm.c

+3
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,9 @@ static int acm_tty_break_ctl(struct tty_struct *tty, int state)
916916
struct acm *acm = tty->driver_data;
917917
int retval;
918918

919+
if (!(acm->ctrl_caps & USB_CDC_CAP_BRK))
920+
return -EOPNOTSUPP;
921+
919922
retval = acm_send_break(acm, state ? 0xffff : 0);
920923
if (retval < 0)
921924
dev_dbg(&acm->control->dev,

0 commit comments

Comments
 (0)