Skip to content

Commit

Permalink
drivers: rtc: rtc_mc146818: Patch incorrect field comparisons
Browse files Browse the repository at this point in the history
Minutes and hour values are incorrectly compared with MAX_SEC.

Compare minutes and hour to MAX_MIN and MAX_HOUR respectively.

Signed-off-by: Daniel Kampert <DanielKampert@kampis-elektroecke.de>
  • Loading branch information
Kampi authored and carlescufi committed Jun 5, 2024
1 parent 87dbd81 commit 246e614
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/rtc/rtc_mc146818.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,13 @@ static int rtc_mc146818_alarm_get_time(const struct device *dev, uint16_t id, ui
}

value = rtc_read(RTC_ALARM_MIN);
if (value <= MAX_SEC) {
if (value <= MAX_MIN) {
timeptr->tm_min = value;
(*mask) |= RTC_ALARM_TIME_MASK_MINUTE;
}

value = rtc_read(RTC_ALARM_HOUR);
if (value <= MAX_SEC) {
if (value <= MAX_HOUR) {
timeptr->tm_hour = value;
(*mask) |= RTC_ALARM_TIME_MASK_HOUR;
}
Expand Down

0 comments on commit 246e614

Please sign in to comment.