linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "open list:SERIAL DRIVERS" <linux-serial@vger.kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Pali Rohár" <pali@kernel.org>
Subject: Re: [PATCH 4/7] USB: serial: ftdi_sio: Do not reset baudrate to 9600 on error
Date: Tue, 12 Jul 2022 14:11:07 +0200	[thread overview]
Message-ID: <20220712141107.24b3f44d@thinkpad> (raw)
In-Reply-To: <CAHp75VdamVbTZ2--GXLY6u_O9QmqN5GXTyZQ-NLfWWaEX6bBBw@mail.gmail.com>

I forgot to look at your comments before sending v2, ouch :(

On Fri, 8 Jul 2022 17:51:00 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Thu, Jul 7, 2022 at 4:57 PM Marek Behún <kabel@kernel.org> wrote:
> >
> > From: Pali Rohár <pali@kernel.org>
> >
> > On failure to set new baudrate, reset baudrate to the previous value  
> 
> a new
> baud rate
> 
> > (as is done by other serial drivers) instead of resetting to 9600.  
> 
> ...
> 
> > +                       baud = old_baud ? old_baud : 9600;  
> 
> Can be written as
> 
>   baud = old_baud ?: 9600;
> 
> ...
> 
> > +                       if (div_value == (u32)-1) {  
> 
> Oh, unsigned -1? Can you define it with a meaningful name and depends
> on the semantics use U32_MAX or GENMASK()?
> 
> > +                               baud = 9600;
> > +                               div_value = ftdi_sio_baud_to_divisor(baud);
> > +                       }  
> 
> ...
> 
> > +                       baud = (old_baud >= 183 && old_baud <= 3000000) ? old_baud : 9600;  
> 
> These repetitive magics are error prone (easy to make a mistake or
> off-by-one error). Can you create a simple helper for this?
> 


  parent reply	other threads:[~2022-07-12 12:11 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07 14:53 [PATCH 0/7] ftdi_sio driver improvements Marek Behún
2022-07-07 14:53 ` [PATCH 1/7] USB: serial: ftdi_sio: Fix divisor overflow Marek Behún
2022-07-07 15:07   ` Greg Kroah-Hartman
2022-07-07 15:37     ` Marek Behún
2022-07-07 15:50       ` Greg Kroah-Hartman
2022-07-07 14:53 ` [PATCH 2/7] USB: serial: ftdi_sio: Add missing baudrate validation Marek Behún
2022-07-07 15:08   ` Greg Kroah-Hartman
2022-07-07 16:22     ` Marek Behún
2022-07-07 16:50       ` Greg Kroah-Hartman
2022-07-07 14:53 ` [PATCH 3/7] USB: serial: ftdi_sio: Extract SIO divisor code to function Marek Behún
2022-07-07 15:06   ` Greg Kroah-Hartman
2022-07-07 15:41     ` Marek Behún
2022-07-07 15:09   ` Greg Kroah-Hartman
2022-07-07 15:50     ` Marek Behún
2022-07-07 14:53 ` [PATCH 4/7] USB: serial: ftdi_sio: Do not reset baudrate to 9600 on error Marek Behún
2022-07-07 15:10   ` Greg Kroah-Hartman
2022-07-07 15:52     ` Marek Behún
2022-07-07 16:06       ` Greg Kroah-Hartman
2022-07-08 15:51   ` Andy Shevchenko
2022-07-12 11:28     ` m.brock
2022-07-12 12:09       ` Marek Behún
2022-07-12 12:11     ` Marek Behún [this message]
2022-07-07 14:53 ` [PATCH 5/7] USB: serial: ftdi_sio: Fix baudrate rounding for ASYNC_SPD_CUST Marek Behún
2022-07-07 15:11   ` Greg Kroah-Hartman
2022-07-07 16:08     ` Marek Behún
2022-07-07 16:12       ` Greg Kroah-Hartman
2022-07-07 14:53 ` [PATCH 6/7] USB: serial: ftdi_sio: Fix custom_divisor and c_*speed " Marek Behún
2022-07-07 14:53 ` [PATCH 7/7] USB: serial: ftdi_sio: Fill c_*speed fields with real baudrate Marek Behún
2022-07-07 15:11   ` Greg Kroah-Hartman
2022-07-07 15:07 ` [PATCH 0/7] ftdi_sio driver improvements 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=20220712141107.24b3f44d@thinkpad \
    --to=kabel@kernel.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=pali@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;
as well as URLs for NNTP newsgroup(s).