Skip to content

Commit 375bbba

Browse files
rafaeljwalexandrebelloni
authored andcommitted
rtc: cmos: Call rtc_wake_setup() from cmos_do_probe()
To reduce code duplication, move the invocation of rtc_wake_setup() into cmos_do_probe() and simplify the callers of the latter. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Zhang Rui <[email protected]> Tested-by: Zhang Rui <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/2143522.irdbgypaU6@kreacher Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 508ccdf commit 375bbba

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

drivers/rtc/rtc-cmos.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ static irqreturn_t cmos_interrupt(int irq, void *p)
744744
return IRQ_NONE;
745745
}
746746

747+
static inline void rtc_wake_setup(struct device *dev);
747748
static void cmos_wake_setup(struct device *dev);
748749

749750
#ifdef CONFIG_PNP
@@ -938,6 +939,13 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
938939
nvmem_cfg.size = address_space - NVRAM_OFFSET;
939940
devm_rtc_nvmem_register(cmos_rtc.rtc, &nvmem_cfg);
940941

942+
/*
943+
* Everything has gone well so far, so by default register a handler for
944+
* the ACPI RTC fixed event.
945+
*/
946+
if (!info)
947+
rtc_wake_setup(dev);
948+
941949
dev_info(dev, "%s%s, %d bytes nvram%s\n",
942950
!is_valid_irq(rtc_irq) ? "no alarms" :
943951
cmos_rtc.mon_alrm ? "alarms up to one year" :
@@ -1357,7 +1365,7 @@ static void rtc_wake_setup(struct device *dev)
13571365

13581366
static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
13591367
{
1360-
int irq, ret;
1368+
int irq;
13611369

13621370
if (pnp_port_start(pnp, 0) == 0x70 && !pnp_irq_valid(pnp, 0)) {
13631371
irq = 0;
@@ -1373,13 +1381,7 @@ static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
13731381
irq = pnp_irq(pnp, 0);
13741382
}
13751383

1376-
ret = cmos_do_probe(&pnp->dev, pnp_get_resource(pnp, IORESOURCE_IO, 0), irq);
1377-
if (ret)
1378-
return ret;
1379-
1380-
rtc_wake_setup(&pnp->dev);
1381-
1382-
return 0;
1384+
return cmos_do_probe(&pnp->dev, pnp_get_resource(pnp, IORESOURCE_IO, 0), irq);
13831385
}
13841386

13851387
static void cmos_pnp_remove(struct pnp_dev *pnp)
@@ -1463,7 +1465,7 @@ static inline void cmos_of_init(struct platform_device *pdev) {}
14631465
static int __init cmos_platform_probe(struct platform_device *pdev)
14641466
{
14651467
struct resource *resource;
1466-
int irq, ret;
1468+
int irq;
14671469

14681470
cmos_of_init(pdev);
14691471

@@ -1475,13 +1477,7 @@ static int __init cmos_platform_probe(struct platform_device *pdev)
14751477
if (irq < 0)
14761478
irq = -1;
14771479

1478-
ret = cmos_do_probe(&pdev->dev, resource, irq);
1479-
if (ret)
1480-
return ret;
1481-
1482-
rtc_wake_setup(&pdev->dev);
1483-
1484-
return 0;
1480+
return cmos_do_probe(&pdev->dev, resource, irq);
14851481
}
14861482

14871483
static int cmos_platform_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)