Skip to content

Commit 62bf102

Browse files
committed
rtc: cmos: Drop PNP device support
Previous changes effectively prevented PNP devices from being created for the CMOS RTC on x86 with ACPI. Although in principle a CMOS RTC PNP device may exist on an x86 system without ACPI (that is, an x86 system where there is no ACPI at all, not one booted with ACPI disabled), such systems were there in the field ~30 years ago and most likely they would not be able to run a contemporary Linux kernel. For the above reasons, drop the PNP device support from the rtc-cmos driver. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://patch.msgid.link/2355012.iZASKD2KPV@rafael.j.wysocki
1 parent 0139085 commit 62bf102

1 file changed

Lines changed: 8 additions & 105 deletions

File tree

drivers/rtc/rtc-cmos.c

Lines changed: 8 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,85 +1370,6 @@ static int __maybe_unused cmos_resume(struct device *dev)
13701370

13711371
static SIMPLE_DEV_PM_OPS(cmos_pm_ops, cmos_suspend, cmos_resume);
13721372

1373-
/*----------------------------------------------------------------*/
1374-
1375-
/* On non-x86 systems, a "CMOS" RTC lives most naturally on platform_bus.
1376-
* ACPI systems always list these as PNPACPI devices, and pre-ACPI PCs
1377-
* probably list them in similar PNPBIOS tables; so PNP is more common.
1378-
*
1379-
* We don't use legacy "poke at the hardware" probing. Ancient PCs that
1380-
* predate even PNPBIOS should set up platform_bus devices.
1381-
*/
1382-
1383-
#ifdef CONFIG_PNP
1384-
1385-
#include <linux/pnp.h>
1386-
1387-
static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
1388-
{
1389-
int irq;
1390-
1391-
if (pnp_port_start(pnp, 0) == 0x70 && !pnp_irq_valid(pnp, 0)) {
1392-
irq = 0;
1393-
#ifdef CONFIG_X86
1394-
/* Some machines contain a PNP entry for the RTC, but
1395-
* don't define the IRQ. It should always be safe to
1396-
* hardcode it on systems with a legacy PIC.
1397-
*/
1398-
if (nr_legacy_irqs())
1399-
irq = RTC_IRQ;
1400-
#endif
1401-
} else {
1402-
irq = pnp_irq(pnp, 0);
1403-
}
1404-
1405-
return cmos_do_probe(&pnp->dev, pnp_get_resource(pnp, IORESOURCE_IO, 0), irq);
1406-
}
1407-
1408-
static void cmos_pnp_remove(struct pnp_dev *pnp)
1409-
{
1410-
cmos_do_remove(&pnp->dev);
1411-
}
1412-
1413-
static void cmos_pnp_shutdown(struct pnp_dev *pnp)
1414-
{
1415-
struct device *dev = &pnp->dev;
1416-
struct cmos_rtc *cmos = dev_get_drvdata(dev);
1417-
1418-
if (system_state == SYSTEM_POWER_OFF) {
1419-
int retval = cmos_poweroff(dev);
1420-
1421-
if (cmos_aie_poweroff(dev) < 0 && !retval)
1422-
return;
1423-
}
1424-
1425-
cmos_do_shutdown(cmos->irq);
1426-
}
1427-
1428-
static const struct pnp_device_id rtc_ids[] = {
1429-
{ .id = "PNP0b00", },
1430-
{ .id = "PNP0b01", },
1431-
{ .id = "PNP0b02", },
1432-
{ },
1433-
};
1434-
MODULE_DEVICE_TABLE(pnp, rtc_ids);
1435-
1436-
static struct pnp_driver cmos_pnp_driver = {
1437-
.name = driver_name,
1438-
.id_table = rtc_ids,
1439-
.probe = cmos_pnp_probe,
1440-
.remove = cmos_pnp_remove,
1441-
.shutdown = cmos_pnp_shutdown,
1442-
1443-
/* flag ensures resume() gets called, and stops syslog spam */
1444-
.flags = PNP_DRIVER_RES_DO_NOT_CHANGE,
1445-
.driver = {
1446-
.pm = &cmos_pm_ops,
1447-
},
1448-
};
1449-
1450-
#endif /* CONFIG_PNP */
1451-
14521373
#ifdef CONFIG_OF
14531374
static const struct of_device_id of_cmos_match[] = {
14541375
{
@@ -1543,45 +1464,27 @@ static struct platform_driver cmos_platform_driver = {
15431464
}
15441465
};
15451466

1546-
#ifdef CONFIG_PNP
1547-
static bool pnp_driver_registered;
1548-
#endif
15491467
static bool platform_driver_registered;
15501468

15511469
static int __init cmos_init(void)
15521470
{
1553-
int retval = 0;
1471+
int retval;
15541472

1555-
#ifdef CONFIG_PNP
1556-
retval = pnp_register_driver(&cmos_pnp_driver);
1557-
if (retval == 0)
1558-
pnp_driver_registered = true;
1559-
#endif
1473+
if (cmos_rtc.dev)
1474+
return 0;
15601475

1561-
if (!cmos_rtc.dev) {
1562-
retval = platform_driver_probe(&cmos_platform_driver,
1563-
cmos_platform_probe);
1564-
if (retval == 0)
1565-
platform_driver_registered = true;
1566-
}
1476+
retval = platform_driver_probe(&cmos_platform_driver, cmos_platform_probe);
1477+
if (retval)
1478+
return retval;
15671479

1568-
if (retval == 0)
1569-
return 0;
1480+
platform_driver_registered = true;
15701481

1571-
#ifdef CONFIG_PNP
1572-
if (pnp_driver_registered)
1573-
pnp_unregister_driver(&cmos_pnp_driver);
1574-
#endif
1575-
return retval;
1482+
return 0;
15761483
}
15771484
module_init(cmos_init);
15781485

15791486
static void __exit cmos_exit(void)
15801487
{
1581-
#ifdef CONFIG_PNP
1582-
if (pnp_driver_registered)
1583-
pnp_unregister_driver(&cmos_pnp_driver);
1584-
#endif
15851488
if (platform_driver_registered)
15861489
platform_driver_unregister(&cmos_platform_driver);
15871490
}

0 commit comments

Comments
 (0)