All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Tomasz Moń" <tomasz.mon@camlingroup.com>
To: linux-serial@vger.kernel.org
Cc: "Phil Elwell" <phil@raspberrypi.com>,
	"Daniel Mack" <daniel@zonque.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Krzysztof Drobiński" <k.drobinski@camlintechnologies.com>,
	"Lech Perczak" <l.perczak@camlintechnologies.com>,
	"Tomasz Moń" <tomasz.mon@camlingroup.com>
Subject: [PATCH 2/6] sc16is7xx: Update status lines in single call
Date: Mon, 21 Feb 2022 11:56:14 +0100	[thread overview]
Message-ID: <20220221105618.3503470-3-tomasz.mon@camlingroup.com> (raw)
In-Reply-To: <20220221105618.3503470-1-tomasz.mon@camlingroup.com>

From: Lech Perczak <l.perczak@camlintechnologies.com>

RTS, DTR and LOOP bits can be updated in a single MCR register update.
This reduces the number of (slow) SPI/I2C bus transactions.

Signed-off-by: Lech Perczak <l.perczak@camlintechnologies.com>
Signed-off-by: Tomasz Moń <tomasz.mon@camlingroup.com>
---
 drivers/tty/serial/sc16is7xx.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 3800733452fe..c62531b2efe2 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -787,19 +787,24 @@ static void sc16is7xx_reg_proc(struct kthread_work *ws)
 	spin_unlock_irqrestore(&one->port.lock, irqflags);
 
 	if (config.flags & SC16IS7XX_RECONF_MD) {
+		u8 mcr = 0;
+
+		/* Device ignores RTS setting when hardware flow is enabled */
+		if (one->port.mctrl & TIOCM_RTS)
+			mcr |= SC16IS7XX_MCR_RTS_BIT;
+
+		if (one->port.mctrl & TIOCM_DTR)
+			mcr |= SC16IS7XX_MCR_DTR_BIT;
+
+		if (one->port.mctrl & TIOCM_LOOP)
+			mcr |= SC16IS7XX_MCR_LOOP_BIT;
 		sc16is7xx_port_update(&one->port, SC16IS7XX_MCR_REG,
+				      SC16IS7XX_MCR_RTS_BIT |
+				      SC16IS7XX_MCR_DTR_BIT |
 				      SC16IS7XX_MCR_LOOP_BIT,
-				      (one->port.mctrl & TIOCM_LOOP) ?
-				      SC16IS7XX_MCR_LOOP_BIT : 0);
-		sc16is7xx_port_update(&one->port, SC16IS7XX_MCR_REG,
-				      SC16IS7XX_MCR_RTS_BIT,
-				      (one->port.mctrl & TIOCM_RTS) ?
-				      SC16IS7XX_MCR_RTS_BIT : 0);
-		sc16is7xx_port_update(&one->port, SC16IS7XX_MCR_REG,
-				      SC16IS7XX_MCR_DTR_BIT,
-				      (one->port.mctrl & TIOCM_DTR) ?
-				      SC16IS7XX_MCR_DTR_BIT : 0);
+				      mcr);
 	}
+
 	if (config.flags & SC16IS7XX_RECONF_IER)
 		sc16is7xx_port_update(&one->port, SC16IS7XX_IER_REG,
 				      config.ier_clear, 0);
-- 
2.25.1


  parent reply	other threads:[~2022-02-21 11:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21 10:56 [PATCH 0/6] sc16is7xx: Hardware flow control fixes Tomasz Moń
2022-02-21 10:56 ` [PATCH 1/6] sc16is7xx: Preserve EFR bits on update Tomasz Moń
2022-02-21 10:56 ` Tomasz Moń [this message]
2022-02-21 10:56 ` [PATCH 3/6] sc16is7xx: Separate GPIOs from modem control lines Tomasz Moń
2022-02-21 10:56 ` [PATCH 4/6] sc16is7xx: Properly resume TX after stop Tomasz Moń
2022-02-21 10:56 ` [PATCH 5/6] sc16is7xx: Handle modem status lines Tomasz Moń
2022-02-21 10:56 ` [PATCH 6/6] sc16is7xx: Set AUTOCTS and AUTORTS bits Tomasz Moń
2022-02-25  9:25 ` [PATCH 0/6] sc16is7xx: Hardware flow control fixes Greg Kroah-Hartman
2022-02-25  9:37   ` Tomasz Moń
2022-02-25 10:47     ` Greg Kroah-Hartman
2022-02-25 11:26       ` 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=20220221105618.3503470-3-tomasz.mon@camlingroup.com \
    --to=tomasz.mon@camlingroup.com \
    --cc=daniel@zonque.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=k.drobinski@camlintechnologies.com \
    --cc=l.perczak@camlintechnologies.com \
    --cc=linux-serial@vger.kernel.org \
    --cc=phil@raspberrypi.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 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.