diff options
author | Lei YU <mine260309@gmail.com> | 2017-09-01 16:22:40 +0800 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-10-26 01:55:28 +0000 |
commit | b5259a1e7433e997caf9c90565d8b0012a6e5820 (patch) | |
tree | 636cf5fb13351799f5712fac7435ffccddbd8be3 /i2c_occ.cpp | |
parent | 370f06b42bfd1912b3bb64038becdd90292d0f39 (diff) | |
download | openpower-occ-control-b5259a1e7433e997caf9c90565d8b0012a6e5820.tar.gz openpower-occ-control-b5259a1e7433e997caf9c90565d8b0012a6e5820.zip |
Add occ_ prefix for i2c occ dbus objects
I2c occ dbus objects path were their i2c addresses, e.g. 3_0050.
This does not indicate it's occ objects, and it does not work with
op-occ-disable/enable services, which searches "occ" key words in object
path.
So add "occ_" prefix for i2c occ dbus objects, e.g. occ_3_0050, to
indicate it's occ objects and work well with op-occ-disable/enable
services.
Change-Id: I21712f2fb7cf6138248f6986b84f99c90c3fa3a2
Signed-off-by: Lei YU <mine260309@gmail.com>
Diffstat (limited to 'i2c_occ.cpp')
-rw-r--r-- | i2c_occ.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/i2c_occ.cpp b/i2c_occ.cpp index ffbb844..c364967 100644 --- a/i2c_occ.cpp +++ b/i2c_occ.cpp @@ -1,4 +1,5 @@ #include <algorithm> +#include <cassert> #include <fstream> #include "config.h" @@ -13,9 +14,12 @@ namespace fs = std::experimental::filesystem; // The device name's length, e.g. "p8-occ-hwmon" constexpr auto DEVICE_NAME_LENGTH = 12; +// The occ name's length, e.g. "occ" +constexpr auto OCC_NAME_LENGTH = 3; // static assert to make sure the i2c occ device name is expected static_assert(sizeof(I2C_OCC_DEVICE_NAME) -1 == DEVICE_NAME_LENGTH); +static_assert(sizeof(OCC_NAME) -1 == OCC_NAME_LENGTH); std::string getFileContent(const fs::path& f) { @@ -63,6 +67,13 @@ void dbusToI2c(std::string& path) std::string getI2cDeviceName(const std::string& dbusPath) { auto name = fs::path(dbusPath).filename().string(); + + // Need to make sure the name starts with "occ" + assert(name.compare(0, OCC_NAME_LENGTH, OCC_NAME) == 0); + + // Change name like occ_3_0050 to 3_0050 + name.erase(0, OCC_NAME_LENGTH + 1); + dbusToI2c(name); return name; } |