From: "Laszlo Ersek" <lersek@redhat.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: "Ard Biesheuvel" <ard.biesheuvel@arm.com>,
"Leif Lindholm" <leif@nuviainc.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH 1/2] ArmPlatformPkg/PL031RealTimeClockLib: cast EfiTimeToEpoch() val. to UINT32
Date: Mon, 21 Dec 2020 12:36:56 +0100 [thread overview]
Message-ID: <20201221113657.6779-2-lersek@redhat.com> (raw)
In-Reply-To: <20201221113657.6779-1-lersek@redhat.com>
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@arm.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@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
next prev parent reply other threads:[~2020-12-21 11:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-21 11:36 [PATCH 0/2] EmbeddedPkg/TimeBaseLib: remove useless truncation to 32-bit Laszlo Ersek
2020-12-21 11:36 ` Laszlo Ersek [this message]
2020-12-21 11:36 ` [PATCH 2/2] " Laszlo Ersek
2020-12-21 12:17 ` [PATCH 0/2] " Ard Biesheuvel
2020-12-21 15:57 ` [edk2-devel] " Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201221113657.6779-2-lersek@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox