Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f73c9a6a authored by Tom Cherry's avatar Tom Cherry Committed by android-build-merger
Browse files

Merge "ueventd: add more logging when firmware loading fails" am: 1c144d5a am: 1611a3aa

am: 9abec295

Change-Id: Iffa7b66fb54376884c8002d9280df993059f9e5c
parents 6d4d7936 9abec295
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -80,16 +80,27 @@ void FirmwareHandler::ProcessFirmwareEvent(const Uevent& uevent) {
        return;
    }

    std::vector<std::string> attempted_paths_and_errors;

try_loading_again:
    attempted_paths_and_errors.clear();
    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));
        if (fw_fd == -1) {
            attempted_paths_and_errors.emplace_back("firmware: attempted " + file +
                                                    ", open failed: " + strerror(errno));
            continue;
        }
        struct stat sb;
        if (fw_fd != -1 && fstat(fw_fd, &sb) != -1) {
        if (fstat(fw_fd, &sb) == -1) {
            attempted_paths_and_errors.emplace_back("firmware: attempted " + file +
                                                    ", fstat failed: " + strerror(errno));
            continue;
        }
        LoadFirmware(uevent, root, fw_fd, sb.st_size, loading_fd, data_fd);
        return;
    }
    }

    if (booting) {
        // If we're not fully booted, we may be missing
@@ -100,6 +111,9 @@ try_loading_again:
    }

    LOG(ERROR) << "firmware: could not find firmware for " << uevent.firmware;
    for (const auto& message : attempted_paths_and_errors) {
        LOG(ERROR) << message;
    }

    // Write "-1" as our response to the kernel's firmware request, since we have nothing for it.
    write(loading_fd, "-1", 2);