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.

rtc: Add API function to return alarm time bound by hardware limit

Add rtc_bound_alarmtime() to return the requested alarm timeout bound by
the maxmum alarm timeout that is supported by a given RTC.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230915152238.1144706-2-linux@roeck-us.net

authored by

Guenter Roeck and committed by
Thomas Gleixner
a0fddaa0 6c774377

+17
+17
include/linux/rtc.h
··· 225 225 return (!(year % 4) && (year % 100)) || !(year % 400); 226 226 } 227 227 228 + /** 229 + * rtc_bound_alarmtime() - Return alarm time bound by rtc limit 230 + * @rtc: Pointer to rtc device structure 231 + * @requested: Requested alarm timeout 232 + * 233 + * Return: Alarm timeout bound by maximum alarm time supported by rtc. 234 + */ 235 + static inline ktime_t rtc_bound_alarmtime(struct rtc_device *rtc, 236 + ktime_t requested) 237 + { 238 + if (rtc->alarm_offset_max && 239 + rtc->alarm_offset_max * MSEC_PER_SEC < ktime_to_ms(requested)) 240 + return ms_to_ktime(rtc->alarm_offset_max * MSEC_PER_SEC); 241 + 242 + return requested; 243 + } 244 + 228 245 #define devm_rtc_register_device(device) \ 229 246 __devm_rtc_register_device(THIS_MODULE, device) 230 247