lpc_aspeed: implement close method
Implement close method on lpc aspeed, such that it'll unmap the memory
region and close the file handle to the driver.
Change-Id: Ie0417fb6c77a2b9d4b4db532b464738b2430a811
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/lpc_aspeed.cpp b/lpc_aspeed.cpp
index 7531382..f1caaa5 100644
--- a/lpc_aspeed.cpp
+++ b/lpc_aspeed.cpp
@@ -45,6 +45,17 @@
void LpcMapperAspeed::close()
{
+ if (mappedRegion)
+ {
+ sys->munmap(mappedRegion, regionSize);
+ mappedRegion = nullptr;
+ }
+
+ if (mappedFd != -1)
+ {
+ sys->close(mappedFd);
+ mappedFd = -1;
+ }
}
std::pair<std::uint32_t, std::uint32_t>