From: "Marek Behún" <kabel@kernel.org>
To: Rob Pearce <rob@flitspace.org.uk>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v2 2/7] USB: serial: ftdi_sio: Add missing baud rate validation
Date: Wed, 13 Jul 2022 00:24:45 +0200 [thread overview]
Message-ID: <20220713002445.6afbccc9@thinkpad> (raw)
In-Reply-To: <33c0f2c5-5873-1d1c-8721-9c715f4034cb@flitspace.org.uk>
On Tue, 12 Jul 2022 18:27:28 +0100
Rob Pearce <rob@flitspace.org.uk> wrote:
> On 12/07/2022 12:53, Marek Behún wrote:
> > From: Pali Rohár <pali@kernel.org>
> >
> > Add lower checks for requested baud rate for FT8U232AM, FT232BM, FT2232C,
> > FT232RL, FTX, FT2232H, FT4232H and FT232H. For all of these the minimum
> > baud rate they can generate is 183 Baud.
> >
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> > Tested-by: Marek Behún <kabel@kernel.org>
> > Signed-off-by: Marek Behún <kabel@kernel.org>
> > ---
> > drivers/usb/serial/ftdi_sio.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
> > index ea40f367e70c..717b97f4e094 100644
> > --- a/drivers/usb/serial/ftdi_sio.c
> > +++ b/drivers/usb/serial/ftdi_sio.c
> > @@ -1330,7 +1330,7 @@ static u32 get_ftdi_divisor(struct tty_struct *tty,
> > }
> > break;
> > case FT8U232AM: /* 8U232AM chip */
> > - if (baud <= 3000000) {
> > + if (baud >= 183 && baud <= 3000000) {
> > div_value = ftdi_232am_baud_to_divisor(baud);
> > } else {
> > dev_dbg(dev, "%s - Baud rate too high!\n", __func__);
> Due to the above change, this debug message is now incorrect.
Thx for noticing that. I will update. Also I will probably do some more
refactors, I am not yet sure.
Marek
> > @@ -1343,7 +1343,7 @@ static u32 get_ftdi_divisor(struct tty_struct *tty,
> > case FT2232C: /* FT2232C chip */
> > case FT232RL: /* FT232RL chip */
> > case FTX: /* FT-X series */
> > - if (baud <= 3000000) {
> > + if (baud >= 183 && baud <= 3000000) {
> > u16 product_id = le16_to_cpu(
> > port->serial->dev->descriptor.idProduct);
> > if (((product_id == FTDI_NDI_HUC_PID) ||
> > @@ -1367,7 +1367,7 @@ static u32 get_ftdi_divisor(struct tty_struct *tty,
> > case FT232H: /* FT232H chip */
> > if ((baud <= 12000000) && (baud >= 1200)) {
> > div_value = ftdi_2232h_baud_to_divisor(baud);
> > - } else if (baud < 1200) {
> > + } else if (baud >= 183 && baud < 1200) {
> > div_value = ftdi_232bm_baud_to_divisor(baud);
> > } else {
> > dev_dbg(dev, "%s - Baud rate too high!\n", __func__);
> As above
>
>
next prev parent reply other threads:[~2022-07-12 22:24 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 11:52 [PATCH v2 0/7] ftdi_sio driver improvements Marek Behún
2022-07-12 11:53 ` [PATCH v2 1/7] USB: serial: ftdi_sio: Fix divisor overflow Marek Behún
2022-07-24 12:02 ` Johan Hovold
2022-07-12 11:53 ` [PATCH v2 2/7] USB: serial: ftdi_sio: Add missing baud rate validation Marek Behún
2022-07-12 17:27 ` Rob Pearce
2022-07-12 22:24 ` Marek Behún [this message]
2022-07-12 11:53 ` [PATCH v2 3/7] USB: serial: ftdi_sio: Extract SIO divisor code to function Marek Behún
2022-07-24 12:06 ` Johan Hovold
2022-08-18 14:11 ` Pali Rohár
2022-09-13 14:49 ` Johan Hovold
2022-09-13 15:30 ` Pali Rohár
2022-09-13 15:44 ` Johan Hovold
2022-07-12 11:53 ` [PATCH v2 4/7] USB: serial: ftdi_sio: Do not reset baud rate to 9600 Baud on error Marek Behún
2022-07-24 12:20 ` Johan Hovold
2022-08-18 14:12 ` Pali Rohár
2022-09-13 14:54 ` Johan Hovold
2022-07-12 11:53 ` [PATCH v2 5/7] USB: serial: ftdi_sio: Fix baud rate rounding for ASYNC_SPD_CUST Marek Behún
2022-07-24 12:26 ` Johan Hovold
2022-07-12 11:53 ` [PATCH v2 6/7] USB: serial: ftdi_sio: Fix custom_divisor and c_*speed " Marek Behún
2022-07-24 12:28 ` Johan Hovold
2022-07-24 12:33 ` Pali Rohár
2022-07-24 12:54 ` Johan Hovold
2022-07-24 12:59 ` Pali Rohár
2022-07-24 13:08 ` Johan Hovold
2022-08-18 14:09 ` Pali Rohár
2022-09-13 14:59 ` Johan Hovold
2022-09-14 8:48 ` Pali Rohár
2022-09-14 8:58 ` Johan Hovold
2022-09-14 9:10 ` Pali Rohár
2022-09-14 9:18 ` Johan Hovold
2022-09-14 9:20 ` Pali Rohár
2022-07-12 11:53 ` [PATCH v2 7/7] USB: serial: ftdi_sio: Fill c_*speed fields with real baud rate Marek Behún
2022-07-24 12:41 ` Johan Hovold
2022-08-18 14:17 ` Pali Rohár
2022-09-13 15:02 ` Johan Hovold
2022-09-13 15:24 ` Pali Rohár
2022-09-13 15:34 ` 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=20220713002445.6afbccc9@thinkpad \
--to=kabel@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=rob@flitspace.org.uk \
/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).