blob: d2654f14c54e30d2157679fe3c4704d64106a6ec [file] [log] [blame]
#include "tlbmc/hal/sysfs/i3c.h"
#include <cstdint>
#include <string>
#include "absl/strings/str_cat.h"
#include "hal_common_config.pb.h"
namespace milotic_tlbmc {
boost::filesystem::path I3cSysfs::GetBusPath(uint64_t bus) const {
boost::filesystem::path path(config_.i3c_sysfs_path);
path /= absl::StrCat("i3c-", bus);
return path;
}
bool I3cSysfs::IsDevicePresent(const HalCommonConfig& config) const {
boost::filesystem::path path = GetBusPath(config.bus());
path /= GetDeviceDirectoryName(config);
return boost::filesystem::exists(path);
}
std::string I3cSysfs::GetDeviceDirectoryName(
const HalCommonConfig& config) const {
return absl::StrCat(config.bus(), "-", absl::Hex(config.address()));
}
} // namespace milotic_tlbmc