Commit 66aad7d8 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

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: default avatarOliver Neukum <oneukum@suse.com>
Fixes: 9e98966c ("tty: rework break handling")
Link: https://lore.kernel.org/r/20231207132639.18250-1-oneukum@suse.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 53b5ff83
...@@ -2489,6 +2489,9 @@ static int send_break(struct tty_struct *tty, unsigned int duration) ...@@ -2489,6 +2489,9 @@ static int send_break(struct tty_struct *tty, unsigned int duration)
if (!retval) { if (!retval) {
msleep_interruptible(duration); msleep_interruptible(duration);
retval = tty->ops->break_ctl(tty, 0); retval = tty->ops->break_ctl(tty, 0);
} else if (retval == -EOPNOTSUPP) {
/* some drivers can tell only dynamically */
retval = 0;
} }
tty_write_unlock(tty); tty_write_unlock(tty);
......
...@@ -916,6 +916,9 @@ static int acm_tty_break_ctl(struct tty_struct *tty, int state) ...@@ -916,6 +916,9 @@ static int acm_tty_break_ctl(struct tty_struct *tty, int state)
struct acm *acm = tty->driver_data; struct acm *acm = tty->driver_data;
int retval; int retval;
if (!(acm->ctrl_caps & USB_CDC_CAP_BRK))
return -EOPNOTSUPP;
retval = acm_send_break(acm, state ? 0xffff : 0); retval = acm_send_break(acm, state ? 0xffff : 0);
if (retval < 0) if (retval < 0)
dev_dbg(&acm->control->dev, dev_dbg(&acm->control->dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment