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

Commit 1c144d5a authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "ueventd: add more logging when firmware loading fails"

parents f261f518 d38aafd2
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);