firmware_handler: Print full FW path before loading

As of now ueventd only prints the firmware name
requested by the uevent, but in case the device
has multiple firmware going by the same name it's
more interesting to know what file ends up actually
being used for the firmware request.

Test: m, check logcat
Change-Id: Ia90d387f09789d8e8b337a1a178144fad553d37b
This commit is contained in:
Luca Stefani 2024-04-05 10:22:34 +02:00
parent 09071c46d8
commit 3e4159a22e
2 changed files with 5 additions and 3 deletions

View file

@ -264,8 +264,9 @@ std::string FirmwareHandler::GetFirmwarePath(const Uevent& uevent) const {
return uevent.firmware;
}
void FirmwareHandler::ProcessFirmwareEvent(const std::string& root,
void FirmwareHandler::ProcessFirmwareEvent(const std::string& path,
const std::string& firmware) const {
std::string root = "/sys" + path;
std::string loading = root + "/loading";
std::string data = root + "/data";
@ -296,6 +297,7 @@ void FirmwareHandler::ProcessFirmwareEvent(const std::string& root,
", fstat failed: " + strerror(errno));
return false;
}
LOG(INFO) << "found " << file << " for " << path;
LoadFirmware(firmware, root, fw_fd.get(), sb.st_size, loading_fd.get(), data_fd.get());
return true;
};
@ -362,7 +364,7 @@ void FirmwareHandler::HandleUevent(const Uevent& uevent) {
if (pid == 0) {
Timer t;
auto firmware = GetFirmwarePath(uevent);
ProcessFirmwareEvent("/sys" + uevent.path, firmware);
ProcessFirmwareEvent(uevent.path, firmware);
LOG(INFO) << "loading " << uevent.path << " took " << t;
_exit(EXIT_SUCCESS);
}

View file

@ -57,7 +57,7 @@ class FirmwareHandler : public UeventHandler {
Result<std::string> RunExternalHandler(const std::string& handler, uid_t uid, gid_t gid,
const Uevent& uevent) const;
std::string GetFirmwarePath(const Uevent& uevent) const;
void ProcessFirmwareEvent(const std::string& root, const std::string& firmware) const;
void ProcessFirmwareEvent(const std::string& path, const std::string& firmware) const;
bool ForEachFirmwareDirectory(std::function<bool(const std::string&)> handler) const;
std::vector<std::string> firmware_directories_;