blob: f52a3ca560f6059201de46277c135153da1b4542 [file] [log] [blame]
#ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_SYSFS_I2C_H_
#define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_SYSFS_I2C_H_
#include <cstdint>
#include <filesystem> // NOLINT: filesystem is available on BMC
#include <string>
#include <string_view>
#include "absl/status/status.h"
#include "boost/filesystem.hpp" // NOLINT: boost::filesystem is commonly used in BMC
#include "i2c_common_config.pb.h"
namespace milotic_tlbmc {
struct I2cSysfsConfig {
std::string i2c_sysfs_path = "/sys/bus/i2c/devices/";
};
// The class is thread-safe.
class I2cSysfs {
public:
explicit I2cSysfs(const I2cSysfsConfig& config) : config_(config) {}
virtual ~I2cSysfs() = default;
boost::filesystem::path Geti2cBusPath(uint64_t bus) const;
static std::string GetDeviceDirectoryName(const I2cCommonConfig& config);
virtual absl::Status NewDevice(const I2cCommonConfig& config,
std::string_view driver_name) const;
virtual absl::Status DeleteDevice(const I2cCommonConfig& config) const;
bool IsDevicePresent(const I2cCommonConfig& config) const;
private:
const I2cSysfsConfig config_;
};
} // namespace milotic_tlbmc
#endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_SYSFS_I2C_H_