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 v5 3/3] USB: serial: cp210x: New access functions for large registers
Date: Mon, 29 Feb 2016 11:36:01 +0100	[thread overview]
Message-ID: <20160229103601.GE26559@localhost> (raw)
In-Reply-To: <1456696316-29980-1-git-send-email-konstantin.shkolnyy@gmail.com>

On Sun, Feb 28, 2016 at 03:51:56PM -0600, Konstantin Shkolnyy wrote:
> cp210x_get_config and cp210x_set_config are cumbersome to use. This change
> switches large register access to use new block functions. The old
> functions are removed because now they become unused.
> 
> Signed-off-by: Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>
> ---

> @@ -886,8 +788,9 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
>  		break;
>  	}
>  
> -	cp210x_get_config(port, CP210X_GET_FLOW, modem_ctl, 16);
> -	if (modem_ctl[0] & 0x0008) {
> +	cp210x_read_reg_block(port, CP210X_GET_FLOW, modem_ctl,
> +			sizeof(modem_ctl));
> +	if (modem_ctl[0] & 8) {

I changed this to 0x08 as it's a bitmask.

>  		dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
>  		cflag |= CRTSCTS;
>  	} else {
> @@ -956,7 +859,7 @@ static void cp210x_set_termios(struct tty_struct *tty,
>  	struct device *dev = &port->dev;
>  	unsigned int cflag, old_cflag;
>  	u16 bits;
> -	unsigned int modem_ctl[4];
> +	u8 modem_ctl[16];
>  
>  	cflag = tty->termios.c_cflag;
>  	old_cflag = old_termios->c_cflag;
> @@ -1040,27 +943,35 @@ static void cp210x_set_termios(struct tty_struct *tty,
>  	}
>  
>  	if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) {
> -		cp210x_get_config(port, CP210X_GET_FLOW, modem_ctl, 16);
> -		dev_dbg(dev, "%s - read modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x\n",
> -			__func__, modem_ctl[0], modem_ctl[1],
> -			modem_ctl[2], modem_ctl[3]);
> +
> +		/* Only bytes 0, 4 and 7 out of first 8 have functional bits */
> +
> +		cp210x_read_reg_block(port, CP210X_GET_FLOW, modem_ctl,
> +				sizeof(modem_ctl));
> +		dev_dbg(dev, "%s - read modem controls = %02x .. .. .. %02x .. .. %02x\n",
> +			__func__, modem_ctl[0], modem_ctl[4], modem_ctl[7]);

And here you're actually now leaving out XON/XOFF limits in the last 8
bytes. It would have been better to just dump the whole array and make
any such changes explicitly in a separate patch, but I left this in this
time.

>  		if (cflag & CRTSCTS) {
>  			modem_ctl[0] &= ~0x7B;
>  			modem_ctl[0] |= 0x09;
> -			modem_ctl[1] = 0x80;
> +			modem_ctl[4] = 0x80;
> +			/* FIXME - why clear reserved bits just read? */
> +			modem_ctl[5] = 0;
> +			modem_ctl[6] = 0;
> +			modem_ctl[7] = 0;
>  			dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
>  		} else {
>  			modem_ctl[0] &= ~0x7B;
>  			modem_ctl[0] |= 0x01;
> -			modem_ctl[1] |= 0x40;
> +			/* FIXME - OR here instead of assignment looks wrong */
> +			modem_ctl[4] |= 0x40;

These indeed looks like bugs, but I agree that fixing the accessor
functions first made sense.

Looking forward to the follow-up fixes. :)

All three patches now applied.

Thanks for sticking to this.

Johan

      reply	other threads:[~2016-02-29 10:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-28 21:51 [PATCH v5 3/3] USB: serial: cp210x: New access functions for large registers Konstantin Shkolnyy
2016-02-29 10:36 ` Johan Hovold [this message]

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=20160229103601.GE26559@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