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

Configure Feed

Select the types of activity you want to include in your feed.

ACPI: TAD: RTC: Refine timer value computations and checks

Since rtc_tm_to_ktime() may overflow for large RTC time values and
full second granularity is sufficient in timer value computations
in acpi_tad_rtc_set_alarm() and acpi_tad_rtc_read_alarm(), use
rtc_tm_to_time64() instead of that function, which also allows the
computations to be simplified.

Moreover, U32_MAX is a special "timer disabled" value, so make
acpi_tad_rtc_set_alarm() reject it when attempting to program the
alarm timers.

Fixes: 7572dcabe38d ("ACPI: TAD: Add alarm support to the RTC class device interface")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://patch.msgid.link/3414608.aeNJFYEL58@rafael.j.wysocki

+3 -5
+3 -5
drivers/acpi/acpi_tad.c
··· 680 680 681 681 acpi_tad_rt_to_tm(&rt, &tm_now); 682 682 683 - value = ktime_divns(ktime_sub(rtc_tm_to_ktime(t->time), 684 - rtc_tm_to_ktime(tm_now)), NSEC_PER_SEC); 685 - if (value <= 0 || value > U32_MAX) 683 + value = rtc_tm_to_time64(&t->time) - rtc_tm_to_time64(&tm_now); 684 + if (value <= 0 || value >= U32_MAX) 686 685 return -EINVAL; 687 686 } 688 687 ··· 744 745 745 746 if (retval != ACPI_TAD_WAKE_DISABLED) { 746 747 t->enabled = 1; 747 - t->time = rtc_ktime_to_tm(ktime_add_ns(rtc_tm_to_ktime(tm_now), 748 - (u64)retval * NSEC_PER_SEC)); 748 + rtc_time64_to_tm(rtc_tm_to_time64(&tm_now) + retval, &t->time); 749 749 } else { 750 750 t->enabled = 0; 751 751 t->time = tm_now;