mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andre Werner <andre.werner@systec-electronic.com>
To: gregkh@linuxfoundation.org, jirislaby@kernel.org,
	hvilleneuve@dimonoff.com, andy@kernel.org,
	devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	lech.perczak@camlingroup.com, krzk+dt@kernel.org,
	conor+dt@kernel.org, robh@kernel.org,
	Andre Werner <andre.werner@systec-electronic.com>
Subject: [PATCH v7] serial: sc16is7xx: Add polling mode if no IRQ pin is available
Date: Thu, 16 Jan 2025 09:34:47 +0100	[thread overview]
Message-ID: <20250116083447.453615-1-andre.werner@systec-electronic.com> (raw)
In-Reply-To: <CAHp75Vc==m3mE1TtxjHnpwL-d8W4rFnKreu7XB7MWspJKCCOGA@mail.gmail.com>

Fall back to polling mode if no interrupt is configured because there
is no possibility to connect the interrupt pin.

If no interrupt pin is available the driver uses a delayed worker to
poll the state of interrupt status registers (IIR).

Signed-off-by: Andre Werner <andre.werner@systec-electronic.com>
Link: https://lore.kernel.org/r/20250110073104.1029633-2-andre.werner@systec-electronic.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
V2:
- Change warning for polling mode to debug log entry
- Correct typo: Resuse -> Reuse
- Format define with missing tabs for SC16IS7XX_POLL_PERIOD
- Format struct declaration sc16is7xx_one_config with missing tabs for polling and shutdown
- Adapt dtbinding with new polling feature
V3:
- Use suffix with units and drop a comment SC16IS7XX_POLL_PERIOD_MS. Sorry for that miss.
- Make Kernel lowercase.
V4:
- Reword commit messages for better understanding.
- Remove 'shutdown' property for canceling delayed worker.
- Rename worker function: sc16is7xx_transmission_poll -> sc16is7xx_poll_proc
- Unify argument for worker functions: kthread_work *work -> kthread_work *ws
V5:
- Replace of_property check with IRQ number check to set polling
  property. This will add support for usage without device tree
  definitions. Thanks for that advice.
- Add blank line es requested.
V6:
- Use polling mode for IRQ numbers <= 0 which encounter no valid IRQ
  were found/defined.
V7:
- Try to improve and unify comments as requested.
- Fix typo in commit message: pull -> poll
---
 drivers/tty/serial/sc16is7xx.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 7b51cdc274fd..348ddc3103cd 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -868,10 +868,12 @@ static void sc16is7xx_poll_proc(struct kthread_work *ws)
 {
 	struct sc16is7xx_port *s = container_of(ws, struct sc16is7xx_port, poll_work.work);
 
-	/* Reuse standard IRQ handler. Interrupt ID is unused in this context. */
+	/*
+	 * Reuse standard IRQ handler. Interrupt ID is unused in this
+	 * context and set to zero.
+	 */
 	sc16is7xx_irq(0, s);
 
-	/* Setup delay based on SC16IS7XX_POLL_PERIOD_MS */
 	kthread_queue_delayed_work(&s->kworker, &s->poll_work,
 				   msecs_to_jiffies(SC16IS7XX_POLL_PERIOD_MS));
 }
@@ -1561,7 +1563,7 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype,
 	/* Always ask for fixed clock rate from a property. */
 	device_property_read_u32(dev, "clock-frequency", &uartclk);
 
-	s->polling = !!irq;
+	s->polling = (irq <= 0);
 	if (s->polling)
 		dev_dbg(dev,
 			"No interrupt pin definition, falling back to polling mode\n");
@@ -1694,7 +1696,7 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype,
 #endif
 
 	if (s->polling) {
-		/* Initialize kernel thread for polling */
+		/* Initialize a kthread work struct that is dedicated to polling */
 		kthread_init_delayed_work(&s->poll_work, sc16is7xx_poll_proc);
 		return 0;
 	}
-- 
2.48.0


  reply	other threads:[~2025-01-16  8:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14  7:04 [PATCH v7 1/2] dt-bindings: serial: sc16is7xx: Add description for polling mode Andre Werner
2025-01-14  7:04 ` [PATCH v7 2/2] serial: sc16is7xx: Add polling mode if no IRQ pin is available Andre Werner
2025-01-14 14:56   ` Andy Shevchenko
2025-01-15  5:23     ` [External Email] " Andre Werner
2025-01-15 15:08       ` Andy Shevchenko
2025-01-16  8:34         ` Andre Werner [this message]
2025-01-16  8:42           ` [PATCH v7] " Andre Werner
2025-01-16  9:03             ` Andy Shevchenko
2025-01-16  9:32               ` [PATCH v1] serial: sc16is7xx: Extend IRQ check for negative valus Andre Werner
2025-01-16  9:42                 ` Jiri Slaby
2025-01-16  9:52                   ` [External Email] " Andre Werner
2025-01-16 10:01                     ` Jiri Slaby
2025-01-16 12:00                       ` Andy Shevchenko
2025-01-16  9:53                   ` Andy Shevchenko
2025-01-16 10:02                     ` Jiri Slaby
2025-01-16 12:01                       ` Andy Shevchenko
2025-01-16 17:13                       ` Andy Shevchenko
2025-01-16  9:02           ` [PATCH v7] serial: sc16is7xx: Add polling mode if no IRQ pin is available Andy Shevchenko
2025-01-17 11:50           ` Greg KH
2025-01-17 12:37             ` [External Email] " Andre Werner
2025-01-17 12:40               ` Greg KH

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=20250116083447.453615-1-andre.werner@systec-electronic.com \
    --to=andre.werner@systec-electronic.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hvilleneuve@dimonoff.com \
    --cc=jirislaby@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lech.perczak@camlingroup.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=robh@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

all inboxes | Powered by JetHome®