public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>
Cc: johan@kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND 3/5] USB: serial: cp210x: Added comments to CRTSCT flag code.
Date: Mon, 25 Apr 2016 12:16:35 +0200	[thread overview]
Message-ID: <20160425101635.GI18866@localhost> (raw)
In-Reply-To: <1461517761-6240-1-git-send-email-konstantin.shkolnyy@gmail.com>

On Sun, Apr 24, 2016 at 12:09:21PM -0500, Konstantin Shkolnyy wrote:
> Documented "magic numbers" used in the CRTSCT flag code in terms of
> register bit names from the chip specification.

Documenting these is long overdue. I even started adding defines just to
be able to review the first patch in the series.

> Signed-off-by: Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>
> ---
>  drivers/usb/serial/cp210x.c | 38 ++++++++++++++++++++++++++++++++++----
>  1 file changed, 34 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
> index ede5c52..b2321a7 100644
> --- a/drivers/usb/serial/cp210x.c
> +++ b/drivers/usb/serial/cp210x.c
> @@ -790,7 +790,7 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
>  
>  	cp210x_read_reg_block(port, CP210X_GET_FLOW, modem_ctl,
>  			sizeof(modem_ctl));
> -	if (modem_ctl[0] & 0x08) {
> +	if (modem_ctl[0] & 0x08) { /* if SERIAL_CTS_HANDSHAKE */

But instead of adding comments like this one and below, please add
proper defines for the various flags and masks. That will make the code
mostly self-explanatory.

>  		dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
>  		cflag |= CRTSCTS;
>  	} else {
> @@ -952,17 +952,47 @@ static void cp210x_set_termios(struct tty_struct *tty,
>  			__func__, modem_ctl[0], modem_ctl[4], modem_ctl[7]);
>  
>  		if (cflag & CRTSCTS) {
> -			modem_ctl[0] &= ~0x7B;
> +			modem_ctl[0] &= ~0x7B; /* keep reserved D2 and D7 */
> +			/*
> +			 * D1-D0 SERIAL_DTR_MASK     =01b: DTR is held active
> +			 * D3 SERIAL_CTS_HANDSHAKE   =1: CTS is a handshake line
> +			 * D4 SERIAL_DSR_HANDSHAKE   =0
> +			 * D5 SERIAL_DCD_HANDSHAKE   =0
> +			 * D6 SERIAL_DSR_SENSITIVITY =0
> +			 */

> -		modem_ctl[7] = 0;
> +		modem_ctl[7] = 0; /* SERIAL_XOFF_CONTINUE = 0 */

And this would be better as a bit operation as well (as already
mentioned).

Thanks,
Johan

  reply	other threads:[~2016-04-25 10:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-24 17:09 [PATCH RESEND 3/5] USB: serial: cp210x: Added comments to CRTSCT flag code Konstantin Shkolnyy
2016-04-25 10:16 ` Johan Hovold [this message]
2016-04-25 18:09   ` [EXT] " Konstantin Shkolnyy
2016-04-26  7:26     ` Johan Hovold
2016-04-27 20:06       ` Konstantin Shkolnyy
2016-04-28 11:09         ` 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=20160425101635.GI18866@localhost \
    --to=johan@kernel.org \
    --cc=konstantin.shkolnyy@gmail.com \
    --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