Linux USB
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Crescent Hsieh <crescentcy.hsieh@moxa.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	FangpingFP.Cheng@moxa.com, Epson.Chiang@moxa.com,
	EddieSY.Lin@moxa.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/6] USB: serial: add generic write control callbacks
Date: Thu, 15 Oct 2026 11:53:22 +0200	[thread overview]
Message-ID: <atCikmW89iycQzTp@hovoldconsulting.com> (raw)
In-Reply-To: <20260811060501.2307836-5-crescentcy.hsieh@moxa.com>

On Tue, Aug 11, 2026 at 02:04:59PM +0800, Crescent Hsieh wrote:
> Some USB serial devices use device-specific flow control to determine
> whether write submission may proceed. The generic write path currently
> provides no way to pause submission based on driver-specific state. It
> also provides no way for a driver to restore its state if URB submission
> fails.
> 
> Add an optional write_ready() callback to struct usb_serial_driver. Call
> it with port->lock held after confirming that data is queued and a write
> URB is available. If the callback returns false, stop write processing
> and leave the data in the FIFO. The driver must call
> usb_serial_generic_write_start() when writes may proceed again.
> 
> Add an optional write_rollback() callback for restoring driver-specific
> state after usb_submit_urb() fails. Call it with port->lock held after
> restoring the generic transmit accounting, and pass it the length of the
> prepared transfer.
> 
> Drivers which do not provide these callbacks retain the existing generic
> write behaviour.
> 
> Signed-off-by: Crescent Hsieh <crescentcy.hsieh@moxa.com>

> @@ -171,9 +173,7 @@ int usb_serial_generic_write_start(struct usb_serial_port *port,
>  	spin_unlock_irqrestore(&port->lock, flags);
>  
>  	urb = port->write_urbs[i];
> -	count = port->serial->type->prepare_write_buffer(port,
> -						urb->transfer_buffer,
> -						port->bulk_out_size);
> +	count = type->prepare_write_buffer(port, urb->transfer_buffer, port->bulk_out_size);

I kept the last line break here to keep the line under 80 chars.

> @@ -436,4 +444,3 @@ module_exit(usb_serial_module_exit);
>  	usb_serial_module_driver(KBUILD_MODNAME, __serial_drivers, __ids)
>  
>  #endif /* __LINUX_USB_SERIAL_H */
> -

And dropped this unrelated change.

Johan

  reply	other threads:[~2026-10-15  9:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11  6:04 [PATCH v3 0/6] USB: serial: mxuport: add MUX50U support and updates Crescent Hsieh
2026-08-11  6:04 ` [PATCH v3 1/6] USB: serial: mxuport: clean up product ID definitions and device table Crescent Hsieh
2026-08-11  6:04 ` [PATCH v3 2/6] USB: serial: mxuport: clean up firmware version handling Crescent Hsieh
2026-08-11  6:04 ` [PATCH v3 3/6] USB: serial: mxuport: add MUX50U-based device support Crescent Hsieh
2026-08-11  6:04 ` [PATCH v3 4/6] USB: serial: add generic write control callbacks Crescent Hsieh
2026-10-15  9:53   ` Johan Hovold [this message]
2026-08-11  6:05 ` [PATCH v3 5/6] USB: serial: mxuport: handle SEND_NEXT transmit flow control Crescent Hsieh
2026-08-11  6:05 ` [PATCH v3 6/6] USB: serial: mxuport: support RS485 mode configuration Crescent Hsieh
2026-09-10  3:03 ` [PATCH v3 0/6] USB: serial: mxuport: add MUX50U support and updates Crescent Hsieh
2026-09-10 12:56   ` Johan Hovold
2026-09-10 12:57     ` Johan Hovold
2026-10-05  5:43       ` Crescent Hsieh
2026-10-05  8:15         ` Johan Hovold
2026-10-15  9:51 ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=atCikmW89iycQzTp@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=EddieSY.Lin@moxa.com \
    --cc=Epson.Chiang@moxa.com \
    --cc=FangpingFP.Cheng@moxa.com \
    --cc=crescentcy.hsieh@moxa.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox