Linux Serial subsystem development
 help / color / mirror / Atom feed
From: Hugo Villeneuve <hugo@hugovil.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Jiri Slaby <jirislaby@kernel.org>
Cc: hugo@hugovil.com, ilpo.jarvinen@linux.intel.com,
	 linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	 Hugo Villeneuve <hvilleneuve@dimonoff.com>
Subject: [PATCH v2 07/15] serial: core: use uart_iotype_*() to simplify uart_report_port()
Date: Tue, 28 Apr 2026 13:53:53 -0400	[thread overview]
Message-ID: <20260428-tty-upio-v2-7-01c1857cf761@dimonoff.com> (raw)
In-Reply-To: <20260428-tty-upio-v2-0-01c1857cf761@dimonoff.com>

From: Hugo Villeneuve <hvilleneuve@dimonoff.com>

Make use of new functions uart_iotype_mmio() and uart_iotype_legacy_io()
to simplify and improve code readability. It will also prevent displaying
irrelevant I/O information for future IO types (ex: UPIO_BUS). Use %pa to
display the mapbase pointer, as it is done in earlycon_print_info().

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
---
On 32-bit cpu:
  no changes.
On 64-bit cpu:
  before:
    1004b800.serial: ttySC0 at MMIO 0x1004b800 (irq = 35, base_baud = 0) is a scif
    1004bc00.serial: ttySC1 at MMIO 0x1004bc00 (irq = 40, base_baud = 0) is a scif
  after:
    1004b800.serial: ttySC0 at MMIO 0x000000001004b800 (irq = 35, base_baud = 0) is a scif
    1004bc00.serial: ttySC1 at MMIO 0x000000001004bc00 (irq = 40, base_baud = 0) is a scif
---
 drivers/tty/serial/serial_core.c | 32 ++++++++++----------------------
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index e9986f9221f946c9075a8eea7ac28d2ad818f095..d0d4dba41fb9ee43403391d9d599abc1d64b48ec 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2483,31 +2483,19 @@ EXPORT_SYMBOL(uart_resume_port);
 static inline void
 uart_report_port(struct uart_driver *drv, struct uart_port *port)
 {
-	char address[64];
+	char address[64] = "";
 
-	switch (port->iotype) {
-	case UPIO_PORT:
-		scnprintf(address, sizeof(address), "I/O 0x%lx", port->iobase);
-		break;
-	case UPIO_HUB6:
-		scnprintf(address, sizeof(address),
-			  "I/O 0x%lx offset 0x%x", port->iobase, port->hub6);
-		break;
-	case UPIO_MEM:
-	case UPIO_MEM16:
-	case UPIO_MEM32:
-	case UPIO_MEM32BE:
-	case UPIO_AU:
-	case UPIO_TSI:
-		scnprintf(address, sizeof(address),
-			  "MMIO 0x%llx", (unsigned long long)port->mapbase);
-		break;
-	default:
-		strscpy(address, "*unknown*", sizeof(address));
-		break;
+	if (uart_iotype_mmio(port->iotype))
+		scnprintf(address, sizeof(address), " at MMIO %pa", &port->mapbase);
+	else if (uart_iotype_legacy_io(port->iotype)) {
+		if (port->iotype == UPIO_PORT)
+			scnprintf(address, sizeof(address), " at I/O 0x%lx", port->iobase);
+		else if (port->iotype == UPIO_HUB6)
+			scnprintf(address, sizeof(address), " at I/O 0x%lx offset 0x%x",
+				  port->iobase, port->hub6);
 	}
 
-	pr_info("%s%s%s at %s (irq = %u, base_baud = %u) is a %s\n",
+	pr_info("%s%s%s%s (irq = %u, base_baud = %u) is a %s\n",
 		port->dev ? dev_name(port->dev) : "",
 		port->dev ? ": " : "",
 		port->name,

-- 
2.47.3


  parent reply	other threads:[~2026-04-28 17:54 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28 17:53 [PATCH v2 00/15] serial: add new I/O type for SPI and I2C bus devices Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 01/15] serial: 8250_hub6: add hub6_match_port() Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 02/15] serial: core: add uart_iotype_mmio/legacy_io helper functions Hugo Villeneuve
2026-04-30 15:08   ` Andy Shevchenko
2026-04-30 15:30     ` Hugo Villeneuve
2026-05-01 11:48       ` Andy Shevchenko
2026-05-02 23:25     ` Maciej W. Rozycki
2026-05-04  8:48       ` Andy Shevchenko
2026-05-04 11:44         ` Maciej W. Rozycki
2026-05-04 14:30           ` Andy Shevchenko
2026-05-04 15:20             ` Maciej W. Rozycki
2026-05-04 15:59               ` Andy Shevchenko
2026-04-28 17:53 ` [PATCH v2 03/15] serial: core: use uart_iotype_*() to simplify uart_match_port() Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 04/15] serial: core: use uart_iotype_*() to simplify uart_line_info() Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 05/15] serial: core: replace snprintf with more robust scnprintf Hugo Villeneuve
2026-04-30 15:07   ` Andy Shevchenko
2026-05-04 15:27     ` Hugo Villeneuve
2026-05-04 15:59       ` Andy Shevchenko
2026-04-28 17:53 ` [PATCH v2 06/15] serial: core: fix indentation/alignment Hugo Villeneuve
2026-04-28 17:53 ` Hugo Villeneuve [this message]
2026-04-28 17:53 ` [PATCH v2 08/15] serial: earlycon: use uart_iotype_*() to simplify code Hugo Villeneuve
2026-04-30 15:03   ` Andy Shevchenko
2026-05-04 15:40     ` Hugo Villeneuve
2026-05-04 16:01       ` Andy Shevchenko
2026-04-28 17:53 ` [PATCH v2 09/15] serial: 8250: " Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 10/15] serial: 8250_rsa: " Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 11/15] serial: core: add new I/O type for SPI and I2C bus devices Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 12/15] serial: sc16is7xx: use new UPIO_BUS as iotype Hugo Villeneuve
2026-04-28 17:53 ` [PATCH v2 13/15] serial: max310x: " Hugo Villeneuve
2026-04-28 17:54 ` [PATCH v2 14/15] serial: max3100: " Hugo Villeneuve
2026-04-28 17:54 ` [PATCH v2 15/15] serial: uniformize serial port I/O infos display Hugo Villeneuve

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=20260428-tty-upio-v2-7-01c1857cf761@dimonoff.com \
    --to=hugo@hugovil.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hvilleneuve@dimonoff.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.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