diff options
Diffstat (limited to 'init/firmware_handler.cpp')
-rw-r--r-- | init/firmware_handler.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/init/firmware_handler.cpp b/init/firmware_handler.cpp index 844c6051f..8cd5cc5f9 100644 --- a/init/firmware_handler.cpp +++ b/init/firmware_handler.cpp @@ -30,10 +30,16 @@ #include "util.h" +using android::base::unique_fd; +using android::base::WriteFully; + +namespace android { +namespace init { + static void LoadFirmware(const Uevent& uevent, const std::string& root, int fw_fd, size_t fw_size, int loading_fd, int data_fd) { // Start transfer. - android::base::WriteFully(loading_fd, "1", 1); + WriteFully(loading_fd, "1", 1); // Copy the firmware. int rc = sendfile(data_fd, fw_fd, nullptr, fw_size); @@ -44,7 +50,7 @@ static void LoadFirmware(const Uevent& uevent, const std::string& root, int fw_f // Tell the firmware whether to abort or commit. const char* response = (rc != -1) ? "0" : "-1"; - android::base::WriteFully(loading_fd, response, strlen(response)); + WriteFully(loading_fd, response, strlen(response)); } static bool IsBooting() { @@ -60,13 +66,13 @@ static void ProcessFirmwareEvent(const Uevent& uevent) { std::string loading = root + "/loading"; std::string data = root + "/data"; - android::base::unique_fd loading_fd(open(loading.c_str(), O_WRONLY | O_CLOEXEC)); + unique_fd loading_fd(open(loading.c_str(), O_WRONLY | O_CLOEXEC)); if (loading_fd == -1) { PLOG(ERROR) << "couldn't open firmware loading fd for " << uevent.firmware; return; } - android::base::unique_fd data_fd(open(data.c_str(), O_WRONLY | O_CLOEXEC)); + unique_fd data_fd(open(data.c_str(), O_WRONLY | O_CLOEXEC)); if (data_fd == -1) { PLOG(ERROR) << "couldn't open firmware data fd for " << uevent.firmware; return; @@ -78,7 +84,7 @@ static void ProcessFirmwareEvent(const Uevent& uevent) { try_loading_again: for (size_t i = 0; i < arraysize(firmware_dirs); i++) { std::string file = firmware_dirs[i] + uevent.firmware; - android::base::unique_fd fw_fd(open(file.c_str(), O_RDONLY | O_CLOEXEC)); + unique_fd fw_fd(open(file.c_str(), O_RDONLY | O_CLOEXEC)); struct stat sb; if (fw_fd != -1 && fstat(fw_fd, &sb) != -1) { LoadFirmware(uevent, root, fw_fd, sb.st_size, loading_fd, data_fd); @@ -130,3 +136,6 @@ void HandleFirmwareEvent(const Uevent& uevent) { waitpid(pid, nullptr, 0); } + +} // namespace init +} // namespace android |