summaryrefslogtreecommitdiff
path: root/init/firmware_handler.cpp
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2018-08-01 13:12:20 -0700
committerTom Cherry <tomcherry@google.com>2018-08-01 13:29:05 -0700
commit457e28f1292bbc1687038dfd15f4779ce3d8fd9e (patch)
treee1c4f3ab62e13ca49f9ee165849f6778146256fb /init/firmware_handler.cpp
parent081b710b2ee7f726f1bef282333c397006b6b37f (diff)
ueventd: require opt-in for modalias handling
Some devices have modules.alias and modules.dep for modprobe and other purposes but do not want to opt into ueventd auto loading their modules. Therefore we add a flag that can be added to ueventd configuration files to opt into this behavior. Bug: 111916071 Bug: 112048758 Test: check that modules are loaded with this opt-in Test: check that modules are not loaded without this opt-in Change-Id: Ifb281b273059b4671eea1ca5bc726c9e79f3adfb
Diffstat (limited to 'init/firmware_handler.cpp')
-rw-r--r--init/firmware_handler.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/init/firmware_handler.cpp b/init/firmware_handler.cpp
index 28bda34a2..740e82c99 100644
--- a/init/firmware_handler.cpp
+++ b/init/firmware_handler.cpp
@@ -35,8 +35,6 @@ using android::base::WriteFully;
namespace android {
namespace init {
-std::vector<std::string> firmware_directories;
-
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.
@@ -58,7 +56,10 @@ static bool IsBooting() {
return access("/dev/.booting", F_OK) == 0;
}
-static void ProcessFirmwareEvent(const Uevent& uevent) {
+FirmwareHandler::FirmwareHandler(std::vector<std::string> firmware_directories)
+ : firmware_directories_(std::move(firmware_directories)) {}
+
+void FirmwareHandler::ProcessFirmwareEvent(const Uevent& uevent) {
int booting = IsBooting();
LOG(INFO) << "firmware: loading '" << uevent.firmware << "' for '" << uevent.path << "'";
@@ -80,7 +81,7 @@ static void ProcessFirmwareEvent(const Uevent& uevent) {
}
try_loading_again:
- for (const auto& firmware_directory : firmware_directories) {
+ for (const auto& firmware_directory : firmware_directories_) {
std::string file = firmware_directory + uevent.firmware;
unique_fd fw_fd(open(file.c_str(), O_RDONLY | O_CLOEXEC));
struct stat sb;
@@ -104,7 +105,7 @@ try_loading_again:
write(loading_fd, "-1", 2);
}
-void HandleFirmwareEvent(const Uevent& uevent) {
+void FirmwareHandler::HandleUevent(const Uevent& uevent) {
if (uevent.subsystem != "firmware" || uevent.action != "add") return;
// Loading the firmware in a child means we can do that in parallel...