Skip to content

Commit

Permalink
rtc: mc146818-lib: Adjust failure return code for mc146818_get_time()
Browse files Browse the repository at this point in the history
commit af83863 upstream.

mc146818_get_time() calls mc146818_avoid_UIP() to avoid fetching the
time while RTC update is in progress (UIP). When this fails, the return
code is -EIO, but actually there was no IO failure.

The reason for the return from mc146818_avoid_UIP() is that the UIP
wasn't cleared in the time period. Adjust the return code to -ETIMEDOUT
to match the behavior.

Tested-by: Mateusz Jończyk <mat.jonczyk@o2.pl>
Reviewed-by: Mateusz Jończyk <mat.jonczyk@o2.pl>
Acked-by: Mateusz Jończyk <mat.jonczyk@o2.pl>
Cc:  <stable@vger.kernel.org>
Fixes: 2a61b0a ("rtc: mc146818-lib: refactor mc146818_get_time")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20231128053653.101798-2-mario.limonciello@amd.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
superm1 authored and gregkh committed Feb 1, 2024
1 parent 911e720 commit fd1f539
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-mc146818-lib.c
Expand Up @@ -138,7 +138,7 @@ int mc146818_get_time(struct rtc_time *time)

if (!mc146818_avoid_UIP(mc146818_get_time_callback, &p)) {
memset(time, 0, sizeof(*time));
return -EIO;
return -ETIMEDOUT;
}

if (!(p.ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
Expand Down

0 comments on commit fd1f539

Please sign in to comment.