| #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 <string> |
| |
| #include "boost/filesystem.hpp" // NOLINT: boost::filesystem is commonly used in BMC |
| #include "hal_common_config.pb.h" |
| #include "tlbmc/hal/sysfs/hwmon.h" |
| |
| namespace milotic_tlbmc { |
| |
| struct I2cSysfsConfig { |
| std::string i2c_sysfs_path = "/sys/bus/i2c/devices/"; |
| }; |
| |
| // The class is thread-safe. |
| class I2cSysfs : public HwmonSysfs { |
| public: |
| // Default constructor for unit tests. |
| I2cSysfs() : I2cSysfs(I2cSysfsConfig()) {} |
| |
| explicit I2cSysfs(const I2cSysfsConfig& config) : config_(config) {} |
| |
| virtual ~I2cSysfs() = default; |
| |
| boost::filesystem::path GetBusPath(uint64_t bus) const override; |
| |
| std::string GetDeviceDirectoryName( |
| const HalCommonConfig& config) const override; |
| |
| bool IsDevicePresent(const HalCommonConfig& config) const override; |
| |
| std::string GetI2cSysfsPath() const { return config_.i2c_sysfs_path; } |
| |
| private: |
| const I2cSysfsConfig config_; |
| }; |
| |
| } // namespace milotic_tlbmc |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_SYSFS_I2C_H_ |