Re: [PATCH] serial: 8250_pcilib: Replace deprecated PCI functions
From: Florian Eckert
Date: Mon Sep 29 2025 - 02:33:21 EST
On 2025-09-29 08:00, Jiri Slaby wrote:
On 26. 09. 25, 14:31, Florian Eckert wrote:
Signed-off-by: Florian Eckert <fe@xxxxxxxxxx>...
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -165,7 +165,15 @@ static int
setup_port(struct serial_private *priv, struct uart_8250_port *port,
u8 bar, unsigned int offset, int regshift)
{
- return serial8250_pci_setup_port(priv->dev, port, bar, offset, regshift);
+ void __iomem *iomem = NULL;
+
+ if (pci_resource_flags(priv->dev, bar) & IORESOURCE_MEM) {
+ iomem = pcim_iomap(priv->dev, bar, 0);
+ if (IS_ERR(iomem))
+ return -ENOMEM;
Why not to propagate the error?
Most other calls in the kernel of this function return
-ENOMEM on error. Therefore, I thought that this is the
correct return value. I can fix that in v2 if you like.
Let me know what you prefer.
Ugh, pcim_iomap() returns NULL on error, so the IS_ERR() check is all
wrong. What other places in the kernel use IS_ERR()? They need fixing.
You're right. The function returns a pointer here and my check IS_ERR()
is wrong. I mixed it up with the 'pcim_iomap_region()' function.
Because I wanted to use this function before. As far as I can see, the return
value of 'pcim_iomap()' is checked correctly in the linux sources.
Sorry for the noise.
I will adjust this and send a V2 patch.
--
Florian