All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Alex Henrie <alexh@vpitech.com>
Cc: linux-usb@vger.kernel.org, johan@kernel.org,
	johanna.abrahamsson@afconsult.com, alexhenrie24@gmail.com
Subject: Re: [PATCH] USB: serial: cp210x: map B0 to B9600
Date: Sat, 26 Nov 2022 08:10:07 +0100	[thread overview]
Message-ID: <Y4G7z0fa7W/qseqw@kroah.com> (raw)
In-Reply-To: <20221126035825.6991-1-alexh@vpitech.com>

On Fri, Nov 25, 2022 at 08:58:25PM -0700, Alex Henrie wrote:
> When a baud rate of 0 is requested, both the 8250 driver and the FTDI
> driver reset the baud rate to the default of 9600 (see the comment above
> the uart_get_baud_rate function). Some old versions of the NXP blhost
> utility depend on this behavior. However, the CP210x driver resets the
> baud rate to the minimum supported rate of 300. Special-case B0 so that
> it returns the baud rate to the more sensible default of 9600.
> 
> Signed-off-by: Alex Henrie <alexh@vpitech.com>
> ---
>  drivers/usb/serial/cp210x.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
> index 3bcec419f463..2c910550dca8 100644
> --- a/drivers/usb/serial/cp210x.c
> +++ b/drivers/usb/serial/cp210x.c
> @@ -1051,9 +1051,14 @@ static void cp210x_change_speed(struct tty_struct *tty,
>  	 * This maps the requested rate to the actual rate, a valid rate on
>  	 * cp2102 or cp2103, or to an arbitrary rate in [1M, max_speed].
>  	 *
> -	 * NOTE: B0 is not implemented.
> +	 * NOTE: B0 is not implemented, apart from returning the baud rate to
> +	 * the default of B9600.
>  	 */
> -	baud = clamp(tty->termios.c_ospeed, priv->min_speed, priv->max_speed);
> +	if (tty->termios.c_ospeed) {
> +		baud = clamp(tty->termios.c_ospeed, priv->min_speed, priv->max_speed);
> +	} else {
> +		baud = 9600;
> +	}

No need for { } here (checkpatch.pl should have warned about this.)

thanks,

greg k-h

  reply	other threads:[~2022-11-26 10:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-26  3:58 [PATCH] USB: serial: cp210x: map B0 to B9600 Alex Henrie
2022-11-26  7:10 ` Greg KH [this message]
2022-11-28 18:06   ` Alex Henrie
2022-11-26 10:34 ` Sergey Shtylyov
2022-11-28 14:41 ` Johan Hovold
2022-11-28 18:08   ` Alex Henrie
2022-11-28 18:20     ` Russell King (Oracle)
2022-11-28 18:38       ` Alex Henrie
2022-11-29 14:15     ` Johan Hovold
2022-11-29 17:48       ` Alex Henrie
2022-11-28 18:12 ` [PATCH v2] " Alex Henrie

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=Y4G7z0fa7W/qseqw@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=alexh@vpitech.com \
    --cc=alexhenrie24@gmail.com \
    --cc=johan@kernel.org \
    --cc=johanna.abrahamsson@afconsult.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.