public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	Sunil V L <sunilvl@ventanamicro.com>
Subject: [PATCH v1 5/7] serial: 8250_platform: Switch to use platform_get_mem_or_io()
Date: Mon, 12 Aug 2024 18:47:07 +0300	[thread overview]
Message-ID: <20240812154901.1068407-6-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20240812154901.1068407-1-andriy.shevchenko@linux.intel.com>

Switch to use new platform_get_mem_or_io() instead of home grown analogue.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250_platform.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_platform.c b/drivers/tty/serial/8250/8250_platform.c
index 38c083e90a7d..4a26bab8c9bd 100644
--- a/drivers/tty/serial/8250/8250_platform.c
+++ b/drivers/tty/serial/8250/8250_platform.c
@@ -113,21 +113,23 @@ static int serial8250_platform_probe(struct platform_device *pdev)
 	unsigned char iotype;
 	int ret, line;
 
-	regs = platform_get_resource(pdev, IORESOURCE_IO, 0);
-	if (regs) {
+	regs = platform_get_mem_or_io(pdev, 0);
+	if (!regs)
+		return dev_err_probe(dev, -EINVAL, "no registers defined\n");
+
+	switch (resource_type(regs)) {
+	case IORESOURCE_IO:
 		uart.port.iobase = regs->start;
 		iotype = UPIO_PORT;
-	} else {
-		regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-		if (!regs) {
-			dev_err(dev, "no registers defined\n");
-			return -EINVAL;
-		}
-
+		break;
+	case IORESOURCE_MEM:
 		uart.port.mapbase = regs->start;
 		uart.port.mapsize = resource_size(regs);
 		uart.port.flags = UPF_IOREMAP;
 		iotype = UPIO_MEM;
+		break;
+	default:
+		return -EINVAL;
 	}
 
 	/* Default clock frequency*/
-- 
2.43.0.rc1.1336.g36b5255a03ac


  parent reply	other threads:[~2024-08-12 15:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-12 15:47 [PATCH v1 0/7] serial: 8250_platform: refactor and clean up a bit Andy Shevchenko
2024-08-12 15:47 ` [PATCH v1 1/7] serial: 8250_platform: Remove duplicate mapping Andy Shevchenko
2024-08-12 15:47 ` [PATCH v1 2/7] serial: 8250_platform: Don't shadow error from serial8250_register_8250_port() Andy Shevchenko
2024-08-12 15:47 ` [PATCH v1 3/7] serial: 8250_platform: Use same check for ACPI in the whole driver Andy Shevchenko
2024-08-12 15:47 ` [PATCH v1 4/7] serial: 8250_platform: Tidy up ACPI ID table Andy Shevchenko
2024-08-12 15:47 ` Andy Shevchenko [this message]
2024-08-12 15:47 ` [PATCH v1 6/7] serial: 8250_platform: Refactor serial8250_probe() Andy Shevchenko
2024-08-12 15:47 ` [PATCH v1 7/7] serial: 8250_platform: Unify comment style Andy Shevchenko
2024-08-14  6:28 ` [PATCH v1 0/7] serial: 8250_platform: refactor and clean up a bit Sunil V L

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=20240812154901.1068407-6-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=sunilvl@ventanamicro.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