Skip to content

Commit b48ee1f

Browse files
committed
rtc: cmos: Do not require IRQ if ACPI alarm is used
If the ACPI RTC fixed event is used, a dedicated IRQ is not required for the CMOS RTC alarm to work, so allow the driver to use the alarm without a valid IRQ in that case. Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Alexandre Belloni <[email protected]> Reviewed-by: Mario Limonciello (AMD) <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent db5dab0 commit b48ee1f

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

drivers/rtc/rtc-cmos.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ static inline void cmos_write_bank2(unsigned char val, unsigned char addr)
216216

217217
/*----------------------------------------------------------------*/
218218

219+
static bool cmos_no_alarm(struct cmos_rtc *cmos)
220+
{
221+
return !is_valid_irq(cmos->irq) && !cmos_use_acpi_alarm();
222+
}
223+
219224
static int cmos_read_time(struct device *dev, struct rtc_time *t)
220225
{
221226
int ret;
@@ -287,7 +292,7 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t)
287292
};
288293

289294
/* This not only a rtc_op, but also called directly */
290-
if (!is_valid_irq(cmos->irq))
295+
if (cmos_no_alarm(cmos))
291296
return -ETIMEDOUT;
292297

293298
/* Basic alarms only support hour, minute, and seconds fields.
@@ -520,7 +525,7 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
520525
int ret;
521526

522527
/* This not only a rtc_op, but also called directly */
523-
if (!is_valid_irq(cmos->irq))
528+
if (cmos_no_alarm(cmos))
524529
return -EIO;
525530

526531
ret = cmos_validate_alarm(dev, t);
@@ -1096,7 +1101,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
10961101
dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
10971102
goto cleanup1;
10981103
}
1099-
} else {
1104+
} else if (!cmos_use_acpi_alarm()) {
11001105
clear_bit(RTC_FEATURE_ALARM, cmos_rtc.rtc->features);
11011106
}
11021107

@@ -1121,7 +1126,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
11211126
acpi_rtc_event_setup(dev);
11221127

11231128
dev_info(dev, "%s%s, %d bytes nvram%s\n",
1124-
!is_valid_irq(rtc_irq) ? "no alarms" :
1129+
cmos_no_alarm(&cmos_rtc) ? "no alarms" :
11251130
cmos_rtc.mon_alrm ? "alarms up to one year" :
11261131
cmos_rtc.day_alrm ? "alarms up to one month" :
11271132
"alarms up to one day",
@@ -1147,7 +1152,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
11471152
static void cmos_do_shutdown(int rtc_irq)
11481153
{
11491154
spin_lock_irq(&rtc_lock);
1150-
if (is_valid_irq(rtc_irq))
1155+
if (!cmos_no_alarm(&cmos_rtc))
11511156
cmos_irq_disable(&cmos_rtc, RTC_IRQMASK);
11521157
spin_unlock_irq(&rtc_lock);
11531158
}

0 commit comments

Comments
 (0)