blob: 8f160be3bd30262fc6f9c72695267ebaddcbfb7c [file]
#include "tlbmc/hal/sysfs/i3c.h"
#include <cstdint>
#include <string>
#include <string_view>
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "boost/system/error_code.hpp" // NOLINT
#include "hal_common_config.pb.h"
namespace milotic_tlbmc {
boost::filesystem::path I3cSysfs::GetBusPath(uint64_t bus) const {
return boost::filesystem::path(config_.i3c_sysfs_path);
}
bool I3cSysfs::IsDevicePresent(const HalCommonConfig& config) const {
boost::filesystem::path path = GetBusPath(config.bus());
path /= GetDeviceDirectoryName(config);
boost::system::error_code ec;
bool exists = boost::filesystem::exists(path, ec);
if (ec) {
LOG(ERROR) << "Error checking exists for path '" << path
<< "': " << ec.message();
return false;
}
return exists;
}
std::string I3cSysfs::GetDeviceDirectoryName(
const HalCommonConfig& config) const {
return absl::StrCat(config.bus(), "-", absl::Hex(config.address()));
}
// I3C has ability to auto-detect the device, so we don't need to create or
// delete the device.
absl::Status I3cSysfs::NewDevice(const HalCommonConfig& config,
std::string_view driver_name) const {
return absl::OkStatus();
}
absl::Status I3cSysfs::DeleteDevice(const HalCommonConfig& config) const {
return absl::OkStatus();
}
} // namespace milotic_tlbmc