Skip to content

Commit e9f850b

Browse files
rafaeljwalexandrebelloni
authored andcommitted
rtc: cmos: Use platform_get_irq_optional() in cmos_platform_probe()
The rtc-cmos driver can live without an IRQ and returning an error code from platform_get_irq() is not a problem for it in general, so make it call platform_get_irq_optional() in cmos_platform_probe() instead of platform_get_irq() to avoid a confusing error message printed by the latter if an IRQ cannot be found for index 0, which is possible on x86 platforms. Additionally, on x86, if the IRQ is not defined and the system has a legacy PIC, hardcode it to RTC_IRQ, which should be safe then (and which is what the dropped PNP code did). Fixes: d15f1c2 ("ACPI: PNP: Drop CMOS RTC PNP device support") Reported-by: Nathan Chancellor <nathan@kernel.org> Closes: https://lore.kernel.org/linux-acpi/20260303060752.GA2749263@ax162/ Tested-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/12857714.O9o76ZdvQC@rafael.j.wysocki Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent d1b091a commit e9f850b

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

drivers/rtc/rtc-cmos.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,9 +1493,18 @@ static int __init cmos_platform_probe(struct platform_device *pdev)
14931493
resource = platform_get_resource(pdev, IORESOURCE_IO, 0);
14941494
else
14951495
resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1496-
irq = platform_get_irq(pdev, 0);
1497-
if (irq < 0)
1496+
irq = platform_get_irq_optional(pdev, 0);
1497+
if (irq < 0) {
14981498
irq = -1;
1499+
#ifdef CONFIG_X86
1500+
/*
1501+
* On some x86 systems, the IRQ is not defined, but it should
1502+
* always be safe to hardcode it on systems with a legacy PIC.
1503+
*/
1504+
if (nr_legacy_irqs())
1505+
irq = RTC_IRQ;
1506+
#endif
1507+
}
14991508

15001509
return cmos_do_probe(&pdev->dev, resource, irq);
15011510
}

0 commit comments

Comments
 (0)