Re: [PATCH v2] USB: cdc-acm: restore the line coding after a reset-resume

From: Oliver Neukum

Date: Mon Nov 23 2026 - 05:23:29 EST


On 20.11.26 18:18, Piotr Kubik wrote:

/* devices aren't required to support these requests.
@@ -1739,10 +1749,27 @@ static int acm_resume(struct usb_interface *intf)
static int acm_reset_resume(struct usb_interface *intf)
{
struct acm *acm = usb_get_intfdata(intf);
+ bool last;
if (tty_port_initialized(&acm->port))
tty_port_tty_hangup(&acm->port, false);
+ spin_lock_irq(&acm->write_lock);
+ last = acm->susp_count == 1;
+ spin_unlock_irq(&acm->write_lock);
+
+ /*
+ * The device can lose its line coding, for example when it loses
+ * power during system suspend, and acm_tty_set_termios() sends the
+ * line coding only when it differs from acm->line. Send it from the
+ * last interface to resume, before acm_resume() restarts the URBs.
+ * In a runtime resume of the device, an autopm reference here would
+ * wait for this resume and never return.
+ */
+ if (last)
+ __acm_ctrl_msg(acm, USB_CDC_REQ_SET_LINE_CODING, 0,
+ &acm->line, sizeof(acm->line));

Thank you, I was a bit premature unfortunately. Could you use
the acm_set_line() macro, so that the driver stays consistent
in that regard?

Regards
Oliver