summaryrefslogtreecommitdiff
path: root/init/firmware_handler.cpp
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2017-06-23 23:19:53 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-06-23 23:19:53 +0000
commitb57e1180e36e44b78f45c03d98d62c22754d591c (patch)
treed87252e55756a56380cde35c6fbca9042b1c7723 /init/firmware_handler.cpp
parent56f021f0a40a88cfa98c432f8ee4f43e25e301df (diff)
parentd3d79b21968139b135ca24b13dd400494fe73965 (diff)
Merge "init: create android::init:: namespace" am: 040212706b
am: d3d79b2196 Change-Id: I3dccff251dda7d7452e33a7e71178c59f0c22169
Diffstat (limited to 'init/firmware_handler.cpp')
-rw-r--r--init/firmware_handler.cpp19
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