From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Johan Hovold <johan@kernel.org>
Cc: linux-usb@vger.kernel.org,
Sheng Long Wang <china_shenglong@163.com>,
Wang Sheng Long <shenglong.wang.ext@siemens.com>
Subject: Re: [PATCH 1/6] USB: serial: cp210x: add support for software flow control
Date: Mon, 18 Jan 2021 13:42:59 +0100 [thread overview]
Message-ID: <YAWCU9D+FTHgW5wj@kroah.com> (raw)
In-Reply-To: <20210118111331.5048-2-johan@kernel.org>
On Mon, Jan 18, 2021 at 12:13:26PM +0100, Johan Hovold wrote:
> From: Wang Sheng Long <shenglong.wang.ext@siemens.com>
>
> When data is transmitted between two serial ports, the phenomenon of
> data loss often occurs. The two kinds of flow control commonly used in
> serial communication are hardware flow control and software flow
> control.
>
> In serial communication, If you only use RX/TX/GND Pins, you can't do
> hardware flow. So we often used software flow control and prevent data
> loss. The user sets the software flow control through the application
> program, and the application program sets the software flow control mode
> for the serial port chip through the driver.
>
> For the cp210 serial port chip, its driver lacks the software flow
> control setting code, so the user cannot set the software flow control
> function through the application program. This adds the missing software
> flow control.
>
> Signed-off-by: Wang Sheng Long <shenglong.wang.ext@siemens.com>
> Link: https://lore.kernel.org/r/20210104094502.3942-1-china_shenglong@163.com
> [ johan: rework properly on top of recent termios changes ]
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> drivers/usb/serial/cp210x.c | 67 +++++++++++++++++++++++++++++++++++--
> 1 file changed, 65 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
> index fbb10dfc56e3..5bd14770065b 100644
> --- a/drivers/usb/serial/cp210x.c
> +++ b/drivers/usb/serial/cp210x.c
> @@ -377,6 +377,16 @@ static struct usb_serial_driver * const serial_drivers[] = {
> #define CONTROL_WRITE_DTR 0x0100
> #define CONTROL_WRITE_RTS 0x0200
>
> +/* CP210X_(GET|SET)_CHARS */
> +struct cp210x_special_chars {
> + u8 bEofChar;
> + u8 bErrorChar;
> + u8 bBreakChar;
> + u8 bEventChar;
> + u8 bXonChar;
> + u8 bXoffChar;
> +};
> +
> /* CP210X_VENDOR_SPECIFIC values */
> #define CP210X_READ_2NCONFIG 0x000E
> #define CP210X_READ_LATCH 0x00C2
> @@ -1074,11 +1084,38 @@ static void cp210x_disable_event_mode(struct usb_serial_port *port)
> port_priv->event_mode = false;
> }
>
> +static int cp210x_set_chars(struct usb_serial_port *port,
> + struct cp210x_special_chars *chars)
> +{
> + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
> + struct usb_serial *serial = port->serial;
> + void *dmabuf;
> + int result;
> +
> + dmabuf = kmemdup(chars, sizeof(*chars), GFP_KERNEL);
> + if (!dmabuf)
> + return -ENOMEM;
> +
> + result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
> + CP210X_SET_CHARS, REQTYPE_HOST_TO_INTERFACE, 0,
> + port_priv->bInterfaceNumber,
> + dmabuf, sizeof(*chars), USB_CTRL_SET_TIMEOUT);
> +
> + kfree(dmabuf);
> +
> + if (result < 0) {
> + dev_err(&port->dev, "failed to set special chars: %d\n", result);
> + return result;
> + }
This is an "open coded" usb_control_msg_send() call :)
Other than that minor thing:
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
next prev parent reply other threads:[~2021-01-18 12:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 11:13 [PATCH 0/6] USB: serial: cp210x: add software flow-control support Johan Hovold
2021-01-18 11:13 ` [PATCH 1/6] USB: serial: cp210x: add support for software flow control Johan Hovold
2021-01-18 12:42 ` Greg Kroah-Hartman [this message]
2021-01-18 13:33 ` Johan Hovold
2021-01-18 11:13 ` [PATCH 2/6] USB: serial: cp210x: set IXOFF thresholds Johan Hovold
2021-01-18 11:13 ` [PATCH 3/6] USB: serial: cp210x: update control-characters on every change Johan Hovold
2021-01-18 11:13 ` [PATCH 4/6] USB: serial: cp210x: drop short control-transfer checks Johan Hovold
2021-01-18 11:13 ` [PATCH 5/6] USB: serial: cp210x: drop unused includes Johan Hovold
2021-01-18 11:13 ` [PATCH 6/6] USB: serial: cp210x: add copyright notice Johan Hovold
2021-01-18 12:44 ` [PATCH 0/6] USB: serial: cp210x: add software flow-control support Greg Kroah-Hartman
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=YAWCU9D+FTHgW5wj@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=china_shenglong@163.com \
--cc=johan@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=shenglong.wang.ext@siemens.com \
/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;
as well as URLs for NNTP newsgroup(s).