From: Johan Hovold <johan@kernel.org>
To: Lode Willems <me@lodewillems.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] USB: serial: CH341: add hardware flow control RTS/CTS
Date: Wed, 8 Jan 2025 11:13:41 +0100 [thread overview]
Message-ID: <Z35P1UNKlGzNSQiU@hovoldconsulting.com> (raw)
In-Reply-To: <20241218173611.10307-1-me@lodewillems.com>
On Wed, Dec 18, 2024 at 06:25:05PM +0100, Lode Willems wrote:
> This adds support for enabling and disabling
> RTS/CTS hardware flow control.
> Tested using CH341A and CH340E.
>
> Fixes part of the following bug report:
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=197109
>
> Signed-off-by: Lode Willems <me@lodewillems.com>
> ---
>
> Changes in v2:
> - Change the CH341_FLOW_CTL_* values to be 8 bits wide
> - Set flow control setting unconditionally
> - Prepare parameters and do one control request
> - Drop the error message
Thanks for the update.
> +#define CH341_REG_FLOW_CTL 0x27
> +#define CH341_FLOW_CTL_NONE 0x00
> +#define CH341_FLOW_CTL_RTSCTS 0x01
> +static void ch341_set_flow_control(struct tty_struct *tty,
> + struct usb_serial_port *port,
> + const struct ktermios *old_termios)
> +{
> + int r;
> + u16 flow_ctl;
> +
> + if (C_CRTSCTS(tty))
> + flow_ctl = ((u16)CH341_FLOW_CTL_RTSCTS << 8) | CH341_FLOW_CTL_RTSCTS;
> + else
> + flow_ctl = ((u16)CH341_FLOW_CTL_NONE << 8) | CH341_FLOW_CTL_NONE;
> +
> + r = ch341_control_out(port->serial->dev,
> + CH341_REQ_WRITE_REG,
> + ((u16)CH341_REG_FLOW_CTL << 8) | CH341_REG_FLOW_CTL,
> + flow_ctl);
I dropped the unnecessary casts above (and will follow-up with a patch
removing one such cast from the existing code). I also think preparing
the index argument once in the call (i.e. (flow_ctl << 8) | flow_ctl))
makes the code a bit more readable.
End result is here:
https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git/commit/?h=usb-next&id=35478bc369a67b703a079ee123c6e58290114aae
Johan
prev parent reply other threads:[~2025-01-08 10:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 17:25 Lode Willems
2025-01-08 10:13 ` 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=Z35P1UNKlGzNSQiU@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=me@lodewillems.com \
/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
all inboxes | Powered by JetHome®