serial: sa1100: use platform_get_resource()

Use platform_get_resource() to fetch the memory resource
instead of open-coded variant.

While here, fail the probe if no resource found or no port is added.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20200804134807.11589-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Andy Shevchenko 2020-08-04 16:48:07 +03:00 committed by Greg Kroah-Hartman
parent 145f5646be
commit 465ddff7e4

View File

@ -879,22 +879,20 @@ static int sa1100_serial_add_one_port(struct sa1100_port *sport, struct platform
static int sa1100_serial_probe(struct platform_device *dev)
{
struct resource *res = dev->resource;
struct resource *res;
int i;
for (i = 0; i < dev->num_resources; i++, res++)
if (res->flags & IORESOURCE_MEM)
break;
res = platform_get_resource(dev, IORESOURCE_MEM, 0);
if (!res)
return -EINVAL;
if (i < dev->num_resources) {
for (i = 0; i < NR_PORTS; i++) {
if (sa1100_ports[i].port.mapbase != res->start)
continue;
sa1100_serial_add_one_port(&sa1100_ports[i], dev);
for (i = 0; i < NR_PORTS; i++)
if (sa1100_ports[i].port.mapbase == res->start)
break;
}
}
if (i == NR_PORTS)
return -ENODEV;
sa1100_serial_add_one_port(&sa1100_ports[i], dev);
return 0;
}