Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
465ddff7 145f5646

+10 -12
+10 -12
drivers/tty/serial/sa1100.c
··· 879 879 880 880 static int sa1100_serial_probe(struct platform_device *dev) 881 881 { 882 - struct resource *res = dev->resource; 882 + struct resource *res; 883 883 int i; 884 884 885 - for (i = 0; i < dev->num_resources; i++, res++) 886 - if (res->flags & IORESOURCE_MEM) 887 - break; 885 + res = platform_get_resource(dev, IORESOURCE_MEM, 0); 886 + if (!res) 887 + return -EINVAL; 888 888 889 - if (i < dev->num_resources) { 890 - for (i = 0; i < NR_PORTS; i++) { 891 - if (sa1100_ports[i].port.mapbase != res->start) 892 - continue; 893 - 894 - sa1100_serial_add_one_port(&sa1100_ports[i], dev); 889 + for (i = 0; i < NR_PORTS; i++) 890 + if (sa1100_ports[i].port.mapbase == res->start) 895 891 break; 896 - } 897 - } 892 + if (i == NR_PORTS) 893 + return -ENODEV; 894 + 895 + sa1100_serial_add_one_port(&sa1100_ports[i], dev); 898 896 899 897 return 0; 900 898 }