serial: 8250_ni: Switch to use platform_get_mem_or_io()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 21 Mar 2025 18:20:14 +0000 (20:20 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Apr 2025 14:51:19 +0000 (16:51 +0200)
Switch to use new platform_get_mem_or_io() instead of home grown analogue.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Chaitanya Vadrevu <chaitanya.vadrevu@emerson.com>
Reviewed-by: Chaitanya Vadrevu <chaitanya.vadrevu@emerson.com>
Link: https://lore.kernel.org/r/20250321182119.454507-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_ni.c

index 562f7f29e2096c3225e4238b29b4bc480a64774f..2dc510c0a5ef7412517c1be5705abb103f1e817c 100644 (file)
@@ -224,26 +224,26 @@ static int ni16550_get_regs(struct platform_device *pdev,
 {
        struct resource *regs;
 
-       regs = platform_get_resource(pdev, IORESOURCE_IO, 0);
-       if (regs) {
+       regs = platform_get_mem_or_io(pdev, 0);
+       if (!regs)
+               return dev_err_probe(&pdev->dev, -EINVAL, "no registers defined\n");
+
+       switch (resource_type(regs)) {
+       case IORESOURCE_IO:
                port->iotype = UPIO_PORT;
                port->iobase = regs->start;
 
                return 0;
-       }
-
-       regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (regs) {
+       case IORESOURCE_MEM:
                port->iotype = UPIO_MEM;
                port->mapbase = regs->start;
                port->mapsize = resource_size(regs);
                port->flags |= UPF_IOREMAP;
 
                return 0;
+       default:
+               return -EINVAL;
        }
-
-       dev_err(&pdev->dev, "no registers defined\n");
-       return -EINVAL;
 }
 
 /*