[edk2-devel] [PATCH 1/2] ArmPlatformPkg/PL031RealTimeClockLib: cast EfiTimeToEpoch() val. to UINT32
Laszlo Ersek
lersek at redhat.com
Mon Dec 21 11:36:56 UTC 2020
In preparation for changing EfiTimeToEpoch()'s return type to UINTN, cast
EfiTimeToEpoch()'s retval to UINT32 explicitly, in LibSetTime().
Currently, this is a no-op, and even after widening the retval, it will
make no difference, as LibSetTime() explicitly restricts Time->Year under
2106, given that "the PL031 is a 32-bit counter counting seconds". The
patch is made for preventing compiler warnings.
Cc: Ard Biesheuvel <ard.biesheuvel at arm.com>
Cc: Leif Lindholm <leif at nuviainc.com>
Cc: Philippe Mathieu-Daudé <philmd at redhat.com>
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
index 0df4ceb1cb39..3afef4bf9ad4 100644
--- a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
+++ b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
@@ -180,53 +180,53 @@ EFIAPI
LibSetTime (
IN EFI_TIME *Time
)
{
EFI_STATUS Status;
UINT32 EpochSeconds;
// Because the PL031 is a 32-bit counter counting seconds,
// the maximum time span is just over 136 years.
// Time is stored in Unix Epoch format, so it starts in 1970,
// Therefore it can not exceed the year 2106.
if ((Time->Year < 1970) || (Time->Year >= 2106)) {
return EFI_UNSUPPORTED;
}
// Initialize the hardware if not already done
if (!mPL031Initialized) {
Status = InitializePL031 ();
if (EFI_ERROR (Status)) {
return Status;
}
}
- EpochSeconds = EfiTimeToEpoch (Time);
+ EpochSeconds = (UINT32)EfiTimeToEpoch (Time);
// Adjust for the correct time zone, i.e. convert to UTC time zone
// The timezone setting also reflects the DST setting of the clock
if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
EpochSeconds -= Time->TimeZone * SEC_PER_MIN;
} else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {
// Convert to un-adjusted time, i.e. fall back one hour
EpochSeconds -= SEC_PER_HOUR;
}
// Set the PL031
MmioWrite32 (mPL031RtcBase + PL031_RTC_LR_LOAD_REGISTER, EpochSeconds);
return EFI_SUCCESS;
}
/**
Returns the current wakeup alarm clock setting.
@param Enabled Indicates if the alarm is currently enabled or disabled.
@param Pending Indicates if the alarm signal is pending and requires acknowledgement.
@param Time The current alarm setting.
@retval EFI_SUCCESS The alarm settings were returned.
@retval EFI_INVALID_PARAMETER Any parameter is NULL.
@retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
**/
--
2.19.1.3.g30247aa5d201
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69314): https://edk2.groups.io/g/devel/message/69314
Mute This Topic: https://groups.io/mt/79123602/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list