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

m68k: Fix WARNING splat in pmac_zilog driver

Don't add platform resources that won't be used. This avoids a
recently-added warning from the driver core, that can show up on a
multi-platform kernel when !MACH_IS_MAC.

------------[ cut here ]------------
WARNING: CPU: 0 PID: 0 at drivers/base/platform.c:224 platform_get_irq_optional+0x8e/0xce
0 is an invalid IRQ number
Modules linked in:
CPU: 0 PID: 0 Comm: swapper Not tainted 5.9.0-multi #1
Stack from 004b3f04:
004b3f04 00462c2f 00462c2f 004b3f20 0002e128 004754db 004b6ad4 004b3f4c
0002e19c 004754f7 000000e0 00285ba0 00000009 00000000 004b3f44 ffffffff
004754db 004b3f64 004b3f74 00285ba0 004754f7 000000e0 00000009 004754db
004fdf0c 005269e2 004fdf0c 00000000 004b3f88 00285cae 004b6964 00000000
004fdf0c 004b3fac 0051cc68 004b6964 00000000 004b6964 00000200 00000000
0051cc3e 0023c18a 004b3fc0 0051cd8a 004fdf0c 00000002 0052b43c 004b3fc8
Call Trace: [<0002e128>] __warn+0xa6/0xd6
[<0002e19c>] warn_slowpath_fmt+0x44/0x76
[<00285ba0>] platform_get_irq_optional+0x8e/0xce
[<00285ba0>] platform_get_irq_optional+0x8e/0xce
[<00285cae>] platform_get_irq+0x12/0x4c
[<0051cc68>] pmz_init_port+0x2a/0xa6
[<0051cc3e>] pmz_init_port+0x0/0xa6
[<0023c18a>] strlen+0x0/0x22
[<0051cd8a>] pmz_probe+0x34/0x88
[<0051cde6>] pmz_console_init+0x8/0x28
[<00511776>] console_init+0x1e/0x28
[<0005a3bc>] printk+0x0/0x16
[<0050a8a6>] start_kernel+0x368/0x4ce
[<005094f8>] _sinittext+0x4f8/0xc48
random: get_random_bytes called from print_oops_end_marker+0x56/0x80 with crng_init=0
---[ end trace 392d8e82eed68d6c ]---

Commit a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 is invalid"),
which introduced the WARNING, suggests that testing for irq == 0 is
undesirable. Instead of that comparison, just test for resource existence.

Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Joshua Thompson <funaho@jurai.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: stable@vger.kernel.org # v5.8+
Reported-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Link: https://lore.kernel.org/r/0c0fe1e4f11ccec202d4df09ea7d9d98155d101a.1606001297.git.fthain@telegraphics.com.au
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

authored by

Finn Thain and committed by
Geert Uytterhoeven
a7b5458c 428ec5f9

+18 -13
+9 -8
arch/m68k/mac/config.c
··· 775 775 struct platform_device scc_a_pdev = { 776 776 .name = "scc", 777 777 .id = 0, 778 - .num_resources = ARRAY_SIZE(scc_a_rsrcs), 779 - .resource = scc_a_rsrcs, 780 778 }; 781 779 EXPORT_SYMBOL(scc_a_pdev); 782 780 783 781 struct platform_device scc_b_pdev = { 784 782 .name = "scc", 785 783 .id = 1, 786 - .num_resources = ARRAY_SIZE(scc_b_rsrcs), 787 - .resource = scc_b_rsrcs, 788 784 }; 789 785 EXPORT_SYMBOL(scc_b_pdev); 790 786 ··· 807 811 808 812 /* Set up serial port resources for the console initcall. */ 809 813 810 - scc_a_rsrcs[0].start = (resource_size_t) mac_bi_data.sccbase + 2; 811 - scc_a_rsrcs[0].end = scc_a_rsrcs[0].start; 812 - scc_b_rsrcs[0].start = (resource_size_t) mac_bi_data.sccbase; 813 - scc_b_rsrcs[0].end = scc_b_rsrcs[0].start; 814 + scc_a_rsrcs[0].start = (resource_size_t)mac_bi_data.sccbase + 2; 815 + scc_a_rsrcs[0].end = scc_a_rsrcs[0].start; 816 + scc_a_pdev.num_resources = ARRAY_SIZE(scc_a_rsrcs); 817 + scc_a_pdev.resource = scc_a_rsrcs; 818 + 819 + scc_b_rsrcs[0].start = (resource_size_t)mac_bi_data.sccbase; 820 + scc_b_rsrcs[0].end = scc_b_rsrcs[0].start; 821 + scc_b_pdev.num_resources = ARRAY_SIZE(scc_b_rsrcs); 822 + scc_b_pdev.resource = scc_b_rsrcs; 814 823 815 824 switch (macintosh_config->scc_type) { 816 825 case MAC_SCC_PSC:
+9 -5
drivers/tty/serial/pmac_zilog.c
··· 1693 1693 1694 1694 #else 1695 1695 1696 + /* On PCI PowerMacs, pmz_probe() does an explicit search of the OpenFirmware 1697 + * tree to obtain the device_nodes needed to start the console before the 1698 + * macio driver. On Macs without OpenFirmware, global platform_devices take 1699 + * the place of those device_nodes. 1700 + */ 1696 1701 extern struct platform_device scc_a_pdev, scc_b_pdev; 1697 1702 1698 1703 static int __init pmz_init_port(struct uart_pmac_port *uap) 1699 1704 { 1700 - struct resource *r_ports; 1701 - int irq; 1705 + struct resource *r_ports, *r_irq; 1702 1706 1703 1707 r_ports = platform_get_resource(uap->pdev, IORESOURCE_MEM, 0); 1704 - irq = platform_get_irq(uap->pdev, 0); 1705 - if (!r_ports || irq <= 0) 1708 + r_irq = platform_get_resource(uap->pdev, IORESOURCE_IRQ, 0); 1709 + if (!r_ports || !r_irq) 1706 1710 return -ENODEV; 1707 1711 1708 1712 uap->port.mapbase = r_ports->start; 1709 1713 uap->port.membase = (unsigned char __iomem *) r_ports->start; 1710 1714 uap->port.iotype = UPIO_MEM; 1711 - uap->port.irq = irq; 1715 + uap->port.irq = r_irq->start; 1712 1716 uap->port.uartclk = ZS_CLOCK; 1713 1717 uap->port.fifosize = 1; 1714 1718 uap->port.ops = &pmz_pops;