summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2018-09-14 14:50:03 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-10-18 16:43:22 -0400
commit94df8c9015798764d40665bb363bdbf27510f285 (patch)
treece26611a482f2f03a582838faec29eeb065a6c47
parent7db89e36d7c5649b826b607cb2d90e38bb02ab86 (diff)
downloadopenpower-occ-control-94df8c9015798764d40665bb363bdbf27510f285.zip
openpower-occ-control-94df8c9015798764d40665bb363bdbf27510f285.tar.gz
clang-format: Update to match docs repo
Update the .clang-format file and run clang-format-6.0. This .clang-format matches the example one in https://github.com/openbmc/docs/blob/master/cpp-style-and-conventions.md#clang-formatting Change-Id: Id6760866dedbaeafd83ea8ef2e0303e30b8955aa Signed-off-by: Gunnar Mills <gmills@us.ibm.com> Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
-rw-r--r--.clang-format99
-rw-r--r--app.cpp18
-rw-r--r--elog-errors.hpp503
-rw-r--r--file.hpp54
-rw-r--r--i2c_occ.cpp14
-rw-r--r--i2c_occ.hpp1
-rw-r--r--occ_device.cpp10
-rw-r--r--occ_device.hpp340
-rw-r--r--occ_errors.cpp56
-rw-r--r--occ_errors.hpp179
-rw-r--r--occ_finder.cpp59
-rw-r--r--occ_finder.hpp24
-rw-r--r--occ_manager.cpp52
-rw-r--r--occ_manager.hpp188
-rw-r--r--occ_pass_through.cpp72
-rw-r--r--occ_pass_through.hpp128
-rw-r--r--occ_presence.cpp25
-rw-r--r--occ_presence.hpp58
-rw-r--r--occ_status.cpp32
-rw-r--r--occ_status.hpp264
-rw-r--r--powercap.cpp61
-rw-r--r--powercap.hpp38
-rw-r--r--test/TestI2cOcc.cpp9
-rw-r--r--test/utest.cpp60
-rw-r--r--utils.cpp27
-rw-r--r--utils.hpp3
26 files changed, 1213 insertions, 1161 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..ea71ad6
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,99 @@
+---
+Language: Cpp
+# BasedOnStyle: LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlinesLeft: false
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: true
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: true
+ AfterObjCDeclaration: true
+ AfterStruct: true
+ AfterUnion: true
+ BeforeCatch: true
+ BeforeElse: true
+ IndentBraces: false
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: AfterColon
+ColumnLimit: 80
+CommentPragmas: '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+PointerAlignment: Left
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeBlocks: Regroup
+IncludeCategories:
+ - Regex: '^[<"](gtest|gmock)'
+ Priority: 5
+ - Regex: '^"config.h"'
+ Priority: -1
+ - Regex: '^".*\.hpp"'
+ Priority: 1
+ - Regex: '^<.*\.h>'
+ Priority: 2
+ - Regex: '^<.*'
+ Priority: 3
+ - Regex: '.*'
+ Priority: 4
+IndentCaseLabels: true
+IndentWidth: 4
+IndentWrappedFunctionNames: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+ReflowComments: true
+SortIncludes: true
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp11
+TabWidth: 4
+UseTab: Never
+...
+
diff --git a/app.cpp b/app.cpp
index ee02949..260e27b 100644
--- a/app.cpp
+++ b/app.cpp
@@ -1,17 +1,19 @@
-#include <phosphor-logging/log.hpp>
+#include "config.h"
+
+#include "elog-errors.hpp"
+#include "occ_events.hpp"
+#include "occ_manager.hpp"
+
+#include <org/open_power/OCC/Device/error.hpp>
#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
-#include <org/open_power/OCC/Device/error.hpp>
-#include "occ_manager.hpp"
-#include "occ_events.hpp"
-#include "elog-errors.hpp"
-#include "config.h"
using namespace phosphor::logging;
using namespace sdbusplus::org::open_power::OCC::Device::Error;
-using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
- Error::InternalFailure;
+using InternalFailure =
+ sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
int main(int argc, char* argv[])
{
diff --git a/elog-errors.hpp b/elog-errors.hpp
index 823ffdb..6f87a57 100644
--- a/elog-errors.hpp
+++ b/elog-errors.hpp
@@ -2,12 +2,12 @@
// See elog-gen.py for more details
#pragma once
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/exception.hpp>
#include <string>
#include <tuple>
#include <type_traits>
-#include <sdbusplus/exception.hpp>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog.hpp>
namespace sdbusplus
{
@@ -19,7 +19,7 @@ namespace Common
{
namespace Error
{
- struct Timeout;
+struct Timeout;
} // namespace Error
} // namespace Common
} // namespace openbmc_project
@@ -38,7 +38,7 @@ namespace Callout
{
namespace Error
{
- struct GPIO;
+struct GPIO;
} // namespace Error
} // namespace Callout
} // namespace Common
@@ -56,7 +56,7 @@ namespace Common
{
namespace Error
{
- struct InvalidArgument;
+struct InvalidArgument;
} // namespace Error
} // namespace Common
} // namespace openbmc_project
@@ -75,7 +75,7 @@ namespace Device
{
namespace Error
{
- struct WriteFailure;
+struct WriteFailure;
} // namespace Error
} // namespace Device
} // namespace OCC
@@ -95,7 +95,7 @@ namespace Host
{
namespace Error
{
- struct SoftOffTimeout;
+struct SoftOffTimeout;
} // namespace Error
} // namespace Host
} // namespace State
@@ -115,7 +115,7 @@ namespace Callout
{
namespace Error
{
- struct Inventory;
+struct Inventory;
} // namespace Error
} // namespace Callout
} // namespace Common
@@ -135,7 +135,7 @@ namespace Callout
{
namespace Error
{
- struct IIC;
+struct IIC;
} // namespace Error
} // namespace Callout
} // namespace Common
@@ -155,7 +155,7 @@ namespace File
{
namespace Error
{
- struct Open;
+struct Open;
} // namespace Error
} // namespace File
} // namespace Common
@@ -173,7 +173,7 @@ namespace Common
{
namespace Error
{
- struct InternalFailure;
+struct InternalFailure;
} // namespace Error
} // namespace Common
} // namespace openbmc_project
@@ -192,7 +192,7 @@ namespace Callout
{
namespace Error
{
- struct Device;
+struct Device;
} // namespace Error
} // namespace Callout
} // namespace Common
@@ -212,7 +212,7 @@ namespace Device
{
namespace Error
{
- struct WriteFailure;
+struct WriteFailure;
} // namespace Error
} // namespace Device
} // namespace Control
@@ -232,7 +232,7 @@ namespace Device
{
namespace Error
{
- struct ReadFailure;
+struct ReadFailure;
} // namespace Error
} // namespace Device
} // namespace Sensor
@@ -252,7 +252,7 @@ namespace File
{
namespace Error
{
- struct Seek;
+struct Seek;
} // namespace Error
} // namespace File
} // namespace Common
@@ -272,7 +272,7 @@ namespace Device
{
namespace Error
{
- struct ConfigFailure;
+struct ConfigFailure;
} // namespace Error
} // namespace Device
} // namespace OCC
@@ -292,7 +292,7 @@ namespace Device
{
namespace Error
{
- struct OpenFailure;
+struct OpenFailure;
} // namespace Error
} // namespace Device
} // namespace OCC
@@ -312,7 +312,7 @@ namespace Callout
{
namespace Error
{
- struct IPMISensor;
+struct IPMISensor;
} // namespace Error
} // namespace Callout
} // namespace Common
@@ -332,7 +332,7 @@ namespace Device
{
namespace Error
{
- struct ReadFailure;
+struct ReadFailure;
} // namespace Error
} // namespace Device
} // namespace OCC
@@ -352,7 +352,7 @@ namespace Host
{
namespace Error
{
- struct CommandNotSupported;
+struct CommandNotSupported;
} // namespace Error
} // namespace Host
} // namespace Control
@@ -360,7 +360,6 @@ namespace Error
} // namespace xyz
} // namespace sdbusplus
-
namespace phosphor
{
@@ -378,14 +377,12 @@ namespace Host
namespace _CommandNotSupported
{
-
-} // namespace _CommandNotSupported
+} // namespace _CommandNotSupported
struct CommandNotSupported
{
static constexpr auto L = level::ERR;
using metadata_types = std::tuple<>;
-
};
} // namespace Host
@@ -393,17 +390,17 @@ struct CommandNotSupported
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Control::Host::Error::CommandNotSupported>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Control::Host::Error::CommandNotSupported>
{
using type = xyz::openbmc_project::Control::Host::CommandNotSupported;
};
-}
+} // namespace details
namespace xyz
{
@@ -418,36 +415,35 @@ struct TIMEOUT_IN_MSEC
{
static constexpr auto str = "TIMEOUT_IN_MSEC=%llu";
static constexpr auto str_short = "TIMEOUT_IN_MSEC";
- using type = std::tuple<std::decay_t<decltype(str)>,uint64_t>;
- explicit constexpr TIMEOUT_IN_MSEC(uint64_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, uint64_t>;
+ explicit constexpr TIMEOUT_IN_MSEC(uint64_t a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _Timeout
+} // namespace _Timeout
struct Timeout
{
static constexpr auto L = level::ERR;
using TIMEOUT_IN_MSEC = _Timeout::TIMEOUT_IN_MSEC;
using metadata_types = std::tuple<TIMEOUT_IN_MSEC>;
-
};
} // namespace Common
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::Timeout>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Common::Error::Timeout>
{
using type = xyz::openbmc_project::Common::Timeout;
};
-}
+} // namespace details
namespace xyz
{
@@ -458,31 +454,29 @@ namespace Common
namespace _InternalFailure
{
-
-} // namespace _InternalFailure
+} // namespace _InternalFailure
struct InternalFailure
{
static constexpr auto L = level::ERR;
using metadata_types = std::tuple<>;
-
};
} // namespace Common
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure>
{
using type = xyz::openbmc_project::Common::InternalFailure;
};
-}
+} // namespace details
namespace xyz
{
@@ -497,20 +491,20 @@ struct ARGUMENT_NAME
{
static constexpr auto str = "ARGUMENT_NAME=%s";
static constexpr auto str_short = "ARGUMENT_NAME";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr ARGUMENT_NAME(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr ARGUMENT_NAME(const char* a) : _entry(entry(str, a)){};
type _entry;
};
struct ARGUMENT_VALUE
{
static constexpr auto str = "ARGUMENT_VALUE=%s";
static constexpr auto str_short = "ARGUMENT_VALUE";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr ARGUMENT_VALUE(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr ARGUMENT_VALUE(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _InvalidArgument
+} // namespace _InvalidArgument
struct InvalidArgument
{
@@ -518,24 +512,23 @@ struct InvalidArgument
using ARGUMENT_NAME = _InvalidArgument::ARGUMENT_NAME;
using ARGUMENT_VALUE = _InvalidArgument::ARGUMENT_VALUE;
using metadata_types = std::tuple<ARGUMENT_NAME, ARGUMENT_VALUE>;
-
};
} // namespace Common
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument>
{
using type = xyz::openbmc_project::Common::InvalidArgument;
};
-}
+} // namespace details
namespace xyz
{
@@ -552,20 +545,20 @@ struct ERRNO
{
static constexpr auto str = "ERRNO=%d";
static constexpr auto str_short = "ERRNO";
- using type = std::tuple<std::decay_t<decltype(str)>,int32_t>;
- explicit constexpr ERRNO(int32_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, int32_t>;
+ explicit constexpr ERRNO(int32_t a) : _entry(entry(str, a)){};
type _entry;
};
struct PATH
{
static constexpr auto str = "PATH=%s";
static constexpr auto str_short = "PATH";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr PATH(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr PATH(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _Open
+} // namespace _Open
struct Open
{
@@ -573,7 +566,6 @@ struct Open
using ERRNO = _Open::ERRNO;
using PATH = _Open::PATH;
using metadata_types = std::tuple<ERRNO, PATH>;
-
};
} // namespace File
@@ -581,17 +573,17 @@ struct Open
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::File::Error::Open>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Common::File::Error::Open>
{
using type = xyz::openbmc_project::Common::File::Open;
};
-}
+} // namespace details
namespace xyz
{
@@ -608,36 +600,36 @@ struct OFFSET
{
static constexpr auto str = "OFFSET=%ll";
static constexpr auto str_short = "OFFSET";
- using type = std::tuple<std::decay_t<decltype(str)>,int64_t>;
- explicit constexpr OFFSET(int64_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, int64_t>;
+ explicit constexpr OFFSET(int64_t a) : _entry(entry(str, a)){};
type _entry;
};
struct WHENCE
{
static constexpr auto str = "WHENCE=%d";
static constexpr auto str_short = "WHENCE";
- using type = std::tuple<std::decay_t<decltype(str)>,int32_t>;
- explicit constexpr WHENCE(int32_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, int32_t>;
+ explicit constexpr WHENCE(int32_t a) : _entry(entry(str, a)){};
type _entry;
};
struct ERRNO
{
static constexpr auto str = "ERRNO=%d";
static constexpr auto str_short = "ERRNO";
- using type = std::tuple<std::decay_t<decltype(str)>,int32_t>;
- explicit constexpr ERRNO(int32_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, int32_t>;
+ explicit constexpr ERRNO(int32_t a) : _entry(entry(str, a)){};
type _entry;
};
struct PATH
{
static constexpr auto str = "PATH=%s";
static constexpr auto str_short = "PATH";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr PATH(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr PATH(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _Seek
+} // namespace _Seek
struct Seek
{
@@ -647,7 +639,6 @@ struct Seek
using ERRNO = _Seek::ERRNO;
using PATH = _Seek::PATH;
using metadata_types = std::tuple<OFFSET, WHENCE, ERRNO, PATH>;
-
};
} // namespace File
@@ -655,17 +646,17 @@ struct Seek
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::File::Error::Seek>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Common::File::Error::Seek>
{
using type = xyz::openbmc_project::Common::File::Seek;
};
-}
+} // namespace details
namespace example
{
@@ -684,32 +675,33 @@ struct DEV_ADDR
{
static constexpr auto str = "DEV_ADDR=0x%.8X";
static constexpr auto str_short = "DEV_ADDR";
- using type = std::tuple<std::decay_t<decltype(str)>,uint32_t>;
- explicit constexpr DEV_ADDR(uint32_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, uint32_t>;
+ explicit constexpr DEV_ADDR(uint32_t a) : _entry(entry(str, a)){};
type _entry;
};
struct DEV_ID
{
static constexpr auto str = "DEV_ID=%u";
static constexpr auto str_short = "DEV_ID";
- using type = std::tuple<std::decay_t<decltype(str)>,uint32_t>;
- explicit constexpr DEV_ID(uint32_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, uint32_t>;
+ explicit constexpr DEV_ID(uint32_t a) : _entry(entry(str, a)){};
type _entry;
};
struct DEV_NAME
{
static constexpr auto str = "DEV_NAME=%s";
static constexpr auto str_short = "DEV_NAME";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr DEV_NAME(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr DEV_NAME(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _TestErrorTwo
+} // namespace _TestErrorTwo
struct TestErrorTwo : public sdbusplus::exception_t
{
- static constexpr auto errName = "example.xyz.openbmc_project.Example.Elog.TestErrorTwo";
+ static constexpr auto errName =
+ "example.xyz.openbmc_project.Example.Elog.TestErrorTwo";
static constexpr auto errDesc = "This is test error two";
static constexpr auto L = level::ERR;
using DEV_ADDR = _TestErrorTwo::DEV_ADDR;
@@ -739,8 +731,6 @@ struct TestErrorTwo : public sdbusplus::exception_t
} // namespace xyz
} // namespace example
-
-
namespace example
{
namespace xyz
@@ -758,16 +748,17 @@ struct STRING
{
static constexpr auto str = "STRING=%s";
static constexpr auto str_short = "STRING";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr STRING(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr STRING(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _AutoTestSimple
+} // namespace _AutoTestSimple
struct AutoTestSimple : public sdbusplus::exception_t
{
- static constexpr auto errName = "example.xyz.openbmc_project.Example.Elog.AutoTestSimple";
+ static constexpr auto errName =
+ "example.xyz.openbmc_project.Example.Elog.AutoTestSimple";
static constexpr auto errDesc = "This is a simple test error.";
static constexpr auto L = level::ERR;
using STRING = _AutoTestSimple::STRING;
@@ -795,8 +786,6 @@ struct AutoTestSimple : public sdbusplus::exception_t
} // namespace xyz
} // namespace example
-
-
namespace example
{
namespace xyz
@@ -814,29 +803,32 @@ struct CALLOUT_ERRNO_TEST
{
static constexpr auto str = "CALLOUT_ERRNO_TEST=%d";
static constexpr auto str_short = "CALLOUT_ERRNO_TEST";
- using type = std::tuple<std::decay_t<decltype(str)>,int32_t>;
- explicit constexpr CALLOUT_ERRNO_TEST(int32_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, int32_t>;
+ explicit constexpr CALLOUT_ERRNO_TEST(int32_t a) : _entry(entry(str, a)){};
type _entry;
};
struct CALLOUT_DEVICE_PATH_TEST
{
static constexpr auto str = "CALLOUT_DEVICE_PATH_TEST=%s";
static constexpr auto str_short = "CALLOUT_DEVICE_PATH_TEST";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr CALLOUT_DEVICE_PATH_TEST(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr CALLOUT_DEVICE_PATH_TEST(const char* a) :
+ _entry(entry(str, a)){};
type _entry;
};
-} // namespace _Callout
+} // namespace _Callout
struct Callout : public sdbusplus::exception_t
{
- static constexpr auto errName = "example.xyz.openbmc_project.Example.Device.Callout";
+ static constexpr auto errName =
+ "example.xyz.openbmc_project.Example.Device.Callout";
static constexpr auto errDesc = "Generic device callout";
static constexpr auto L = level::ERR;
using CALLOUT_ERRNO_TEST = _Callout::CALLOUT_ERRNO_TEST;
using CALLOUT_DEVICE_PATH_TEST = _Callout::CALLOUT_DEVICE_PATH_TEST;
- using metadata_types = std::tuple<CALLOUT_ERRNO_TEST, CALLOUT_DEVICE_PATH_TEST>;
+ using metadata_types =
+ std::tuple<CALLOUT_ERRNO_TEST, CALLOUT_DEVICE_PATH_TEST>;
const char* name() const noexcept
{
@@ -860,8 +852,6 @@ struct Callout : public sdbusplus::exception_t
} // namespace xyz
} // namespace example
-
-
namespace xyz
{
namespace openbmc_project
@@ -877,20 +867,21 @@ struct CALLOUT_ERRNO
{
static constexpr auto str = "CALLOUT_ERRNO=%d";
static constexpr auto str_short = "CALLOUT_ERRNO";
- using type = std::tuple<std::decay_t<decltype(str)>,int32_t>;
- explicit constexpr CALLOUT_ERRNO(int32_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, int32_t>;
+ explicit constexpr CALLOUT_ERRNO(int32_t a) : _entry(entry(str, a)){};
type _entry;
};
struct CALLOUT_DEVICE_PATH
{
static constexpr auto str = "CALLOUT_DEVICE_PATH=%s";
static constexpr auto str_short = "CALLOUT_DEVICE_PATH";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr CALLOUT_DEVICE_PATH(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr CALLOUT_DEVICE_PATH(const char* a) :
+ _entry(entry(str, a)){};
type _entry;
};
-} // namespace _Device
+} // namespace _Device
struct Device
{
@@ -898,7 +889,6 @@ struct Device
using CALLOUT_ERRNO = _Device::CALLOUT_ERRNO;
using CALLOUT_DEVICE_PATH = _Device::CALLOUT_DEVICE_PATH;
using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
};
} // namespace Callout
@@ -906,17 +896,17 @@ struct Device
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Callout::Error::Device>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Common::Callout::Error::Device>
{
using type = xyz::openbmc_project::Common::Callout::Device;
};
-}
+} // namespace details
namespace xyz
{
@@ -933,21 +923,23 @@ struct CALLOUT_GPIO_NUM
{
static constexpr auto str = "CALLOUT_GPIO_NUM=%u";
static constexpr auto str_short = "CALLOUT_GPIO_NUM";
- using type = std::tuple<std::decay_t<decltype(str)>,uint32_t>;
- explicit constexpr CALLOUT_GPIO_NUM(uint32_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, uint32_t>;
+ explicit constexpr CALLOUT_GPIO_NUM(uint32_t a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _GPIO
+} // namespace _GPIO
struct GPIO
{
static constexpr auto L = level::ERR;
using CALLOUT_GPIO_NUM = _GPIO::CALLOUT_GPIO_NUM;
- using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
- using metadata_types = std::tuple<CALLOUT_GPIO_NUM, CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
+ using CALLOUT_ERRNO =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
+ using CALLOUT_DEVICE_PATH =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
+ using metadata_types =
+ std::tuple<CALLOUT_GPIO_NUM, CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
};
} // namespace Callout
@@ -955,17 +947,17 @@ struct GPIO
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Callout::Error::GPIO>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Common::Callout::Error::GPIO>
{
using type = xyz::openbmc_project::Common::Callout::GPIO;
};
-}
+} // namespace details
namespace xyz
{
@@ -982,30 +974,32 @@ struct CALLOUT_IIC_BUS
{
static constexpr auto str = "CALLOUT_IIC_BUS=%s";
static constexpr auto str_short = "CALLOUT_IIC_BUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr CALLOUT_IIC_BUS(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr CALLOUT_IIC_BUS(const char* a) : _entry(entry(str, a)){};
type _entry;
};
struct CALLOUT_IIC_ADDR
{
static constexpr auto str = "CALLOUT_IIC_ADDR=0x%hx";
static constexpr auto str_short = "CALLOUT_IIC_ADDR";
- using type = std::tuple<std::decay_t<decltype(str)>,uint16_t>;
- explicit constexpr CALLOUT_IIC_ADDR(uint16_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, uint16_t>;
+ explicit constexpr CALLOUT_IIC_ADDR(uint16_t a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _IIC
+} // namespace _IIC
struct IIC
{
static constexpr auto L = level::ERR;
using CALLOUT_IIC_BUS = _IIC::CALLOUT_IIC_BUS;
using CALLOUT_IIC_ADDR = _IIC::CALLOUT_IIC_ADDR;
- using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
- using metadata_types = std::tuple<CALLOUT_IIC_BUS, CALLOUT_IIC_ADDR, CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
+ using CALLOUT_ERRNO =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
+ using CALLOUT_DEVICE_PATH =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
+ using metadata_types = std::tuple<CALLOUT_IIC_BUS, CALLOUT_IIC_ADDR,
+ CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
};
} // namespace Callout
@@ -1013,17 +1007,17 @@ struct IIC
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Callout::Error::IIC>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Common::Callout::Error::IIC>
{
using type = xyz::openbmc_project::Common::Callout::IIC;
};
-}
+} // namespace details
namespace xyz
{
@@ -1040,19 +1034,19 @@ struct CALLOUT_INVENTORY_PATH
{
static constexpr auto str = "CALLOUT_INVENTORY_PATH=%s";
static constexpr auto str_short = "CALLOUT_INVENTORY_PATH";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr CALLOUT_INVENTORY_PATH(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr CALLOUT_INVENTORY_PATH(const char* a) :
+ _entry(entry(str, a)){};
type _entry;
};
-} // namespace _Inventory
+} // namespace _Inventory
struct Inventory
{
static constexpr auto L = level::ERR;
using CALLOUT_INVENTORY_PATH = _Inventory::CALLOUT_INVENTORY_PATH;
using metadata_types = std::tuple<CALLOUT_INVENTORY_PATH>;
-
};
} // namespace Callout
@@ -1060,17 +1054,17 @@ struct Inventory
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Callout::Error::Inventory>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Common::Callout::Error::Inventory>
{
using type = xyz::openbmc_project::Common::Callout::Inventory;
};
-}
+} // namespace details
namespace xyz
{
@@ -1087,19 +1081,19 @@ struct CALLOUT_IPMI_SENSOR_NUM
{
static constexpr auto str = "CALLOUT_IPMI_SENSOR_NUM=%u";
static constexpr auto str_short = "CALLOUT_IPMI_SENSOR_NUM";
- using type = std::tuple<std::decay_t<decltype(str)>,uint32_t>;
- explicit constexpr CALLOUT_IPMI_SENSOR_NUM(uint32_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, uint32_t>;
+ explicit constexpr CALLOUT_IPMI_SENSOR_NUM(uint32_t a) :
+ _entry(entry(str, a)){};
type _entry;
};
-} // namespace _IPMISensor
+} // namespace _IPMISensor
struct IPMISensor
{
static constexpr auto L = level::ERR;
using CALLOUT_IPMI_SENSOR_NUM = _IPMISensor::CALLOUT_IPMI_SENSOR_NUM;
using metadata_types = std::tuple<CALLOUT_IPMI_SENSOR_NUM>;
-
};
} // namespace Callout
@@ -1107,17 +1101,17 @@ struct IPMISensor
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Callout::Error::IPMISensor>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Common::Callout::Error::IPMISensor>
{
using type = xyz::openbmc_project::Common::Callout::IPMISensor;
};
-}
+} // namespace details
namespace xyz
{
@@ -1130,15 +1124,14 @@ namespace Host
namespace _SoftOffTimeout
{
-
-} // namespace _SoftOffTimeout
+} // namespace _SoftOffTimeout
struct SoftOffTimeout
{
static constexpr auto L = level::ERR;
- using TIMEOUT_IN_MSEC = xyz::openbmc_project::Common::Timeout::TIMEOUT_IN_MSEC;
+ using TIMEOUT_IN_MSEC =
+ xyz::openbmc_project::Common::Timeout::TIMEOUT_IN_MSEC;
using metadata_types = std::tuple<TIMEOUT_IN_MSEC>;
-
};
} // namespace Host
@@ -1146,17 +1139,17 @@ struct SoftOffTimeout
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::State::Host::Error::SoftOffTimeout>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::State::Host::Error::SoftOffTimeout>
{
using type = xyz::openbmc_project::State::Host::SoftOffTimeout;
};
-}
+} // namespace details
namespace xyz
{
@@ -1169,16 +1162,16 @@ namespace Device
namespace _WriteFailure
{
-
-} // namespace _WriteFailure
+} // namespace _WriteFailure
struct WriteFailure
{
static constexpr auto L = level::ERR;
- using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
+ using CALLOUT_ERRNO =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
+ using CALLOUT_DEVICE_PATH =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
};
} // namespace Device
@@ -1186,17 +1179,17 @@ struct WriteFailure
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Control::Device::Error::WriteFailure>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Control::Device::Error::WriteFailure>
{
using type = xyz::openbmc_project::Control::Device::WriteFailure;
};
-}
+} // namespace details
namespace org
{
@@ -1209,16 +1202,16 @@ namespace Device
namespace _OpenFailure
{
-
-} // namespace _OpenFailure
+} // namespace _OpenFailure
struct OpenFailure
{
static constexpr auto L = level::ERR;
- using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
+ using CALLOUT_ERRNO =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
+ using CALLOUT_DEVICE_PATH =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
};
} // namespace Device
@@ -1226,17 +1219,17 @@ struct OpenFailure
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::OCC::Device::Error::OpenFailure>
+struct map_exception_type<
+ sdbusplus::org::open_power::OCC::Device::Error::OpenFailure>
{
using type = org::open_power::OCC::Device::OpenFailure;
};
-}
+} // namespace details
namespace org
{
@@ -1249,16 +1242,16 @@ namespace Device
namespace _ReadFailure
{
-
-} // namespace _ReadFailure
+} // namespace _ReadFailure
struct ReadFailure
{
static constexpr auto L = level::ERR;
- using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
+ using CALLOUT_ERRNO =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
+ using CALLOUT_DEVICE_PATH =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
};
} // namespace Device
@@ -1266,17 +1259,17 @@ struct ReadFailure
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::OCC::Device::Error::ReadFailure>
+struct map_exception_type<
+ sdbusplus::org::open_power::OCC::Device::Error::ReadFailure>
{
using type = org::open_power::OCC::Device::ReadFailure;
};
-}
+} // namespace details
namespace org
{
@@ -1289,16 +1282,16 @@ namespace Device
namespace _WriteFailure
{
-
-} // namespace _WriteFailure
+} // namespace _WriteFailure
struct WriteFailure
{
static constexpr auto L = level::ERR;
- using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
+ using CALLOUT_ERRNO =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
+ using CALLOUT_DEVICE_PATH =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
};
} // namespace Device
@@ -1306,17 +1299,17 @@ struct WriteFailure
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::OCC::Device::Error::WriteFailure>
+struct map_exception_type<
+ sdbusplus::org::open_power::OCC::Device::Error::WriteFailure>
{
using type = org::open_power::OCC::Device::WriteFailure;
};
-}
+} // namespace details
namespace org
{
@@ -1329,16 +1322,16 @@ namespace Device
namespace _ConfigFailure
{
-
-} // namespace _ConfigFailure
+} // namespace _ConfigFailure
struct ConfigFailure
{
static constexpr auto L = level::ERR;
- using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
+ using CALLOUT_ERRNO =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
+ using CALLOUT_DEVICE_PATH =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
};
} // namespace Device
@@ -1346,17 +1339,17 @@ struct ConfigFailure
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::OCC::Device::Error::ConfigFailure>
+struct map_exception_type<
+ sdbusplus::org::open_power::OCC::Device::Error::ConfigFailure>
{
using type = org::open_power::OCC::Device::ConfigFailure;
};
-}
+} // namespace details
namespace xyz
{
@@ -1369,16 +1362,16 @@ namespace Device
namespace _ReadFailure
{
-
-} // namespace _ReadFailure
+} // namespace _ReadFailure
struct ReadFailure
{
static constexpr auto L = level::ERR;
- using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
+ using CALLOUT_ERRNO =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
+ using CALLOUT_DEVICE_PATH =
+ xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
};
} // namespace Device
@@ -1386,17 +1379,17 @@ struct ReadFailure
} // namespace openbmc_project
} // namespace xyz
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Sensor::Device::Error::ReadFailure>
+struct map_exception_type<
+ sdbusplus::xyz::openbmc_project::Sensor::Device::Error::ReadFailure>
{
using type = xyz::openbmc_project::Sensor::Device::ReadFailure;
};
-}
+} // namespace details
namespace example
{
@@ -1415,41 +1408,46 @@ struct ERRNUM
{
static constexpr auto str = "ERRNUM=0x%.4X";
static constexpr auto str_short = "ERRNUM";
- using type = std::tuple<std::decay_t<decltype(str)>,uint16_t>;
- explicit constexpr ERRNUM(uint16_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, uint16_t>;
+ explicit constexpr ERRNUM(uint16_t a) : _entry(entry(str, a)){};
type _entry;
};
struct FILE_PATH
{
static constexpr auto str = "FILE_PATH=%s";
static constexpr auto str_short = "FILE_PATH";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr FILE_PATH(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr FILE_PATH(const char* a) : _entry(entry(str, a)){};
type _entry;
};
struct FILE_NAME
{
static constexpr auto str = "FILE_NAME=%s";
static constexpr auto str_short = "FILE_NAME";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr FILE_NAME(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr FILE_NAME(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _TestErrorOne
+} // namespace _TestErrorOne
struct TestErrorOne : public sdbusplus::exception_t
{
- static constexpr auto errName = "example.xyz.openbmc_project.Example.Elog.TestErrorOne";
+ static constexpr auto errName =
+ "example.xyz.openbmc_project.Example.Elog.TestErrorOne";
static constexpr auto errDesc = "this is test error one";
static constexpr auto L = level::INFO;
using ERRNUM = _TestErrorOne::ERRNUM;
using FILE_PATH = _TestErrorOne::FILE_PATH;
using FILE_NAME = _TestErrorOne::FILE_NAME;
- using DEV_ADDR = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ADDR;
- using DEV_ID = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ID;
- using DEV_NAME = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_NAME;
- using metadata_types = std::tuple<ERRNUM, FILE_PATH, FILE_NAME, DEV_ADDR, DEV_ID, DEV_NAME>;
+ using DEV_ADDR =
+ example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ADDR;
+ using DEV_ID =
+ example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ID;
+ using DEV_NAME =
+ example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_NAME;
+ using metadata_types =
+ std::tuple<ERRNUM, FILE_PATH, FILE_NAME, DEV_ADDR, DEV_ID, DEV_NAME>;
const char* name() const noexcept
{
@@ -1473,8 +1471,6 @@ struct TestErrorOne : public sdbusplus::exception_t
} // namespace xyz
} // namespace example
-
-
namespace example
{
namespace xyz
@@ -1492,22 +1488,26 @@ struct DEV_ADDR
{
static constexpr auto str = "DEV_ADDR=0x%.8X";
static constexpr auto str_short = "DEV_ADDR";
- using type = std::tuple<std::decay_t<decltype(str)>,uint32_t>;
- explicit constexpr DEV_ADDR(uint32_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, uint32_t>;
+ explicit constexpr DEV_ADDR(uint32_t a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _TestCallout
+} // namespace _TestCallout
struct TestCallout : public sdbusplus::exception_t
{
- static constexpr auto errName = "example.xyz.openbmc_project.Example.Elog.TestCallout";
+ static constexpr auto errName =
+ "example.xyz.openbmc_project.Example.Elog.TestCallout";
static constexpr auto errDesc = "This is test error TestCallout";
static constexpr auto L = level::ERR;
using DEV_ADDR = _TestCallout::DEV_ADDR;
- using CALLOUT_ERRNO_TEST = example::xyz::openbmc_project::Example::Device::Callout::CALLOUT_ERRNO_TEST;
- using CALLOUT_DEVICE_PATH_TEST = example::xyz::openbmc_project::Example::Device::Callout::CALLOUT_DEVICE_PATH_TEST;
- using metadata_types = std::tuple<DEV_ADDR, CALLOUT_ERRNO_TEST, CALLOUT_DEVICE_PATH_TEST>;
+ using CALLOUT_ERRNO_TEST = example::xyz::openbmc_project::Example::Device::
+ Callout::CALLOUT_ERRNO_TEST;
+ using CALLOUT_DEVICE_PATH_TEST = example::xyz::openbmc_project::Example::
+ Device::Callout::CALLOUT_DEVICE_PATH_TEST;
+ using metadata_types =
+ std::tuple<DEV_ADDR, CALLOUT_ERRNO_TEST, CALLOUT_DEVICE_PATH_TEST>;
const char* name() const noexcept
{
@@ -1531,8 +1531,6 @@ struct TestCallout : public sdbusplus::exception_t
} // namespace xyz
} // namespace example
-
-
namespace example
{
namespace xyz
@@ -1550,26 +1548,34 @@ struct FOO_DATA
{
static constexpr auto str = "FOO_DATA=%s";
static constexpr auto str_short = "FOO_DATA";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr FOO_DATA(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr FOO_DATA(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _Foo
+} // namespace _Foo
struct Foo : public sdbusplus::exception_t
{
- static constexpr auto errName = "example.xyz.openbmc_project.Example.Foo.Foo";
+ static constexpr auto errName =
+ "example.xyz.openbmc_project.Example.Foo.Foo";
static constexpr auto errDesc = "this is test error Foo";
static constexpr auto L = level::INFO;
using FOO_DATA = _Foo::FOO_DATA;
- using ERRNUM = example::xyz::openbmc_project::Example::Elog::TestErrorOne::ERRNUM;
- using FILE_PATH = example::xyz::openbmc_project::Example::Elog::TestErrorOne::FILE_PATH;
- using FILE_NAME = example::xyz::openbmc_project::Example::Elog::TestErrorOne::FILE_NAME;
- using DEV_ADDR = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ADDR;
- using DEV_ID = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ID;
- using DEV_NAME = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_NAME;
- using metadata_types = std::tuple<FOO_DATA, ERRNUM, FILE_PATH, FILE_NAME, DEV_ADDR, DEV_ID, DEV_NAME>;
+ using ERRNUM =
+ example::xyz::openbmc_project::Example::Elog::TestErrorOne::ERRNUM;
+ using FILE_PATH =
+ example::xyz::openbmc_project::Example::Elog::TestErrorOne::FILE_PATH;
+ using FILE_NAME =
+ example::xyz::openbmc_project::Example::Elog::TestErrorOne::FILE_NAME;
+ using DEV_ADDR =
+ example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ADDR;
+ using DEV_ID =
+ example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ID;
+ using DEV_NAME =
+ example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_NAME;
+ using metadata_types = std::tuple<FOO_DATA, ERRNUM, FILE_PATH, FILE_NAME,
+ DEV_ADDR, DEV_ID, DEV_NAME>;
const char* name() const noexcept
{
@@ -1593,8 +1599,6 @@ struct Foo : public sdbusplus::exception_t
} // namespace xyz
} // namespace example
-
-
namespace example
{
namespace xyz
@@ -1612,27 +1616,35 @@ struct BAR_DATA
{
static constexpr auto str = "BAR_DATA=%s";
static constexpr auto str_short = "BAR_DATA";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr BAR_DATA(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr BAR_DATA(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _Bar
+} // namespace _Bar
struct Bar : public sdbusplus::exception_t
{
- static constexpr auto errName = "example.xyz.openbmc_project.Example.Bar.Bar";
+ static constexpr auto errName =
+ "example.xyz.openbmc_project.Example.Bar.Bar";
static constexpr auto errDesc = "this is test error Bar";
static constexpr auto L = level::INFO;
using BAR_DATA = _Bar::BAR_DATA;
using FOO_DATA = example::xyz::openbmc_project::Example::Foo::Foo::FOO_DATA;
- using ERRNUM = example::xyz::openbmc_project::Example::Elog::TestErrorOne::ERRNUM;
- using FILE_PATH = example::xyz::openbmc_project::Example::Elog::TestErrorOne::FILE_PATH;
- using FILE_NAME = example::xyz::openbmc_project::Example::Elog::TestErrorOne::FILE_NAME;
- using DEV_ADDR = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ADDR;
- using DEV_ID = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ID;
- using DEV_NAME = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_NAME;
- using metadata_types = std::tuple<BAR_DATA, FOO_DATA, ERRNUM, FILE_PATH, FILE_NAME, DEV_ADDR, DEV_ID, DEV_NAME>;
+ using ERRNUM =
+ example::xyz::openbmc_project::Example::Elog::TestErrorOne::ERRNUM;
+ using FILE_PATH =
+ example::xyz::openbmc_project::Example::Elog::TestErrorOne::FILE_PATH;
+ using FILE_NAME =
+ example::xyz::openbmc_project::Example::Elog::TestErrorOne::FILE_NAME;
+ using DEV_ADDR =
+ example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ADDR;
+ using DEV_ID =
+ example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ID;
+ using DEV_NAME =
+ example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_NAME;
+ using metadata_types = std::tuple<BAR_DATA, FOO_DATA, ERRNUM, FILE_PATH,
+ FILE_NAME, DEV_ADDR, DEV_ID, DEV_NAME>;
const char* name() const noexcept
{
@@ -1656,9 +1668,6 @@ struct Bar : public sdbusplus::exception_t
} // namespace xyz
} // namespace example
-
-
-
} // namespace logging
} // namespace phosphor
diff --git a/file.hpp b/file.hpp
index bc5450f..9ad5213 100644
--- a/file.hpp
+++ b/file.hpp
@@ -10,39 +10,39 @@ namespace occ
*/
class FileDescriptor
{
- private:
- /** @brief File descriptor for the gpio input device */
- int fd = -1;
+ private:
+ /** @brief File descriptor for the gpio input device */
+ int fd = -1;
- public:
- FileDescriptor() = delete;
- FileDescriptor(const FileDescriptor&) = delete;
- FileDescriptor& operator=(const FileDescriptor&) = delete;
- FileDescriptor(FileDescriptor&&) = delete;
- FileDescriptor& operator=(FileDescriptor&&) = delete;
+ public:
+ FileDescriptor() = delete;
+ FileDescriptor(const FileDescriptor&) = delete;
+ FileDescriptor& operator=(const FileDescriptor&) = delete;
+ FileDescriptor(FileDescriptor&&) = delete;
+ FileDescriptor& operator=(FileDescriptor&&) = delete;
- /** @brief Saves File descriptor and uses it to do file operation
- *
- * @param[in] fd - File descriptor
- */
- FileDescriptor(int fd) : fd(fd)
- {
- // Nothing
- }
+ /** @brief Saves File descriptor and uses it to do file operation
+ *
+ * @param[in] fd - File descriptor
+ */
+ FileDescriptor(int fd) : fd(fd)
+ {
+ // Nothing
+ }
- ~FileDescriptor()
+ ~FileDescriptor()
+ {
+ if (fd >= 0)
{
- if (fd >=0)
- {
- close(fd);
- }
+ close(fd);
}
+ }
- int operator()()
- {
- return fd;
- }
+ int operator()()
+ {
+ return fd;
+ }
};
} // namespace occ
-} // namespace open-power
+} // namespace open_power
diff --git a/i2c_occ.cpp b/i2c_occ.cpp
index 00e4187..1c1a9ff 100644
--- a/i2c_occ.cpp
+++ b/i2c_occ.cpp
@@ -1,10 +1,11 @@
+#include "config.h"
+
+#include "i2c_occ.hpp"
+
#include <algorithm>
#include <cassert>
#include <fstream>
-#include "config.h"
-#include "i2c_occ.hpp"
-
#ifdef I2C_OCC
namespace i2c_occ
@@ -20,8 +21,8 @@ constexpr auto DEVICE_NAME_LENGTH = 12;
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);
+static_assert(sizeof(I2C_OCC_DEVICE_NAME) - 1 == DEVICE_NAME_LENGTH);
+static_assert(sizeof(OCC_NAME) - 1 == OCC_NAME_LENGTH);
static bool isMasterOcc(const fs::directory_entry& p)
{
@@ -48,7 +49,7 @@ std::vector<std::string> getOccHwmonDevices(const char* path)
if (fs::is_directory(path))
{
- for (auto & p : fs::directory_iterator(path))
+ for (auto& p : fs::directory_iterator(path))
{
// Check if a device's name is "p8-occ-hwmon"
auto f = p / "name";
@@ -102,4 +103,3 @@ std::string getI2cDeviceName(const std::string& dbusPath)
} // namespace i2c_occ
#endif
-
diff --git a/i2c_occ.hpp b/i2c_occ.hpp
index 66dc12c..3635ea1 100644
--- a/i2c_occ.hpp
+++ b/i2c_occ.hpp
@@ -67,4 +67,3 @@ std::string getI2cDeviceName(const std::string& dbusPath);
} // namespace i2c_occ
#endif
-
diff --git a/occ_device.cpp b/occ_device.cpp
index b100d46..b05dc09 100644
--- a/occ_device.cpp
+++ b/occ_device.cpp
@@ -1,7 +1,9 @@
-#include <iostream>
#include "occ_device.hpp"
+
#include "occ_status.hpp"
+#include <iostream>
+
namespace open_power
{
namespace occ
@@ -28,17 +30,17 @@ bool Device::master() const
void Device::throttleProcTempCallback(bool error)
{
- statusObject.throttleProcTemp(error);
+ statusObject.throttleProcTemp(error);
}
void Device::throttleProcPowerCallback(bool error)
{
- statusObject.throttleProcPower(error);
+ statusObject.throttleProcPower(error);
}
void Device::throttleMemTempCallback(bool error)
{
- statusObject.throttleMemTemp(error);
+ statusObject.throttleMemTemp(error);
}
} // namespace occ
diff --git a/occ_device.hpp b/occ_device.hpp
index efa46dc..448253a 100644
--- a/occ_device.hpp
+++ b/occ_device.hpp
@@ -1,11 +1,13 @@
#pragma once
-#include <fstream>
-#include <experimental/filesystem>
-#include "occ_events.hpp"
+#include "config.h"
+
#include "occ_errors.hpp"
+#include "occ_events.hpp"
#include "occ_presence.hpp"
-#include "config.h"
+
+#include <experimental/filesystem>
+#include <fstream>
namespace open_power
{
@@ -21,180 +23,166 @@ namespace fs = std::experimental::filesystem;
*/
class Device
{
- public:
- Device() = delete;
- ~Device() = default;
- Device(const Device&) = delete;
- Device& operator=(const Device&) = delete;
- Device(Device&&) = default;
- Device& operator=(Device&&) = default;
-
- /** @brief Constructs the Device object
- *
- * @param[in] event - Unique ptr reference to sd_event
- * @param[in] name - OCC instance name
- * @param[in] manager - OCC manager instance
- * @param[in] callback - Optional callback on errors
- */
- Device(EventPtr& event,
- const std::string& name,
- const Manager& manager,
- Status& status,
- std::function<void(bool)> callBack = nullptr) :
- config(name),
- errorFile(fs::path(config) / "occ_error"),
- statusObject(status),
- error(event, errorFile, callBack),
- presence(event,
- fs::path(config) / "occs_present",
- manager,
- callBack),
- throttleProcTemp(
- event,
- fs::path(config) / "occ_dvfs_ot",
- std::bind(std::mem_fn(&Device::throttleProcTempCallback),
- this,
- std::placeholders::_1)),
- throttleProcPower(
- event,
- fs::path(config) / "occ_dvfs_power",
- std::bind(std::mem_fn(&Device::throttleProcPowerCallback),
- this,
- std::placeholders::_1)),
- throttleMemTemp(
- event,
- fs::path(config) / "occ_mem_throttle",
- std::bind(std::mem_fn(&Device::throttleMemTempCallback),
- this,
- std::placeholders::_1))
- {
- // Nothing to do here
- }
-
- /** @brief Binds device to the OCC driver */
- inline void bind()
- {
- // Bind the device
- return write(bindPath, config);
- }
-
- /** @brief Un-binds device from the OCC driver */
- inline void unBind()
+ public:
+ Device() = delete;
+ ~Device() = default;
+ Device(const Device&) = delete;
+ Device& operator=(const Device&) = delete;
+ Device(Device&&) = default;
+ Device& operator=(Device&&) = default;
+
+ /** @brief Constructs the Device object
+ *
+ * @param[in] event - Unique ptr reference to sd_event
+ * @param[in] name - OCC instance name
+ * @param[in] manager - OCC manager instance
+ * @param[in] callback - Optional callback on errors
+ */
+ Device(EventPtr& event, const std::string& name, const Manager& manager,
+ Status& status, std::function<void(bool)> callBack = nullptr) :
+ config(name),
+ errorFile(fs::path(config) / "occ_error"), statusObject(status),
+ error(event, errorFile, callBack),
+ presence(event, fs::path(config) / "occs_present", manager, callBack),
+ throttleProcTemp(
+ event, fs::path(config) / "occ_dvfs_ot",
+ std::bind(std::mem_fn(&Device::throttleProcTempCallback), this,
+ std::placeholders::_1)),
+ throttleProcPower(
+ event, fs::path(config) / "occ_dvfs_power",
+ std::bind(std::mem_fn(&Device::throttleProcPowerCallback), this,
+ std::placeholders::_1)),
+ throttleMemTemp(event, fs::path(config) / "occ_mem_throttle",
+ std::bind(std::mem_fn(&Device::throttleMemTempCallback),
+ this, std::placeholders::_1))
+ {
+ // Nothing to do here
+ }
+
+ /** @brief Binds device to the OCC driver */
+ inline void bind()
+ {
+ // Bind the device
+ return write(bindPath, config);
+ }
+
+ /** @brief Un-binds device from the OCC driver */
+ inline void unBind()
+ {
+ // Unbind the device
+ return write(unBindPath, config);
+ }
+
+ /** @brief Returns if device is already bound.
+ *
+ * On device bind, a soft link by the name $config
+ * gets created in OCC_HWMON_PATH and gets removed
+ * on unbind
+ *
+ * @return true if bound, else false
+ */
+ inline bool bound() const
+ {
+ return fs::exists(OCC_HWMON_PATH + config);
+ }
+
+ /** @brief Starts to monitor for errors */
+ inline void addErrorWatch()
+ {
+ throttleProcTemp.addWatch();
+ throttleProcPower.addWatch();
+ throttleMemTemp.addWatch();
+ error.addWatch();
+ }
+
+ /** @brief stops monitoring for errors */
+ inline void removeErrorWatch()
+ {
+ // we can always safely remove watch even if we don't add it
+ presence.removeWatch();
+ error.removeWatch();
+ error.removeWatch();
+ throttleMemTemp.removeWatch();
+ throttleProcPower.removeWatch();
+ throttleProcTemp.removeWatch();
+ }
+
+ /** @brief Starts to watch how many OCCs are present on the master */
+ inline void addPresenceWatchMaster()
+ {
+ if (master())
{
- // Unbind the device
- return write(unBindPath, config);
+ presence.addWatch();
}
-
- /** @brief Returns if device is already bound.
- *
- * On device bind, a soft link by the name $config
- * gets created in OCC_HWMON_PATH and gets removed
- * on unbind
- *
- * @return true if bound, else false
- */
- inline bool bound() const
- {
- return fs::exists(OCC_HWMON_PATH + config);
- }
-
- /** @brief Starts to monitor for errors */
- inline void addErrorWatch()
- {
- throttleProcTemp.addWatch();
- throttleProcPower.addWatch();
- throttleMemTemp.addWatch();
- error.addWatch();
- }
-
- /** @brief stops monitoring for errors */
- inline void removeErrorWatch()
- {
- // we can always safely remove watch even if we don't add it
- presence.removeWatch();
- error.removeWatch();
- error.removeWatch();
- throttleMemTemp.removeWatch();
- throttleProcPower.removeWatch();
- throttleProcTemp.removeWatch();
- }
-
- /** @brief Starts to watch how many OCCs are present on the master */
- inline void addPresenceWatchMaster()
- {
- if (master())
- {
- presence.addWatch();
- }
- }
-
- private:
- /** @brief Config value to be used to do bind and unbind */
- const std::string config;
-
- /** @brief This file contains 0 for success, non-zero for errors */
- const fs::path errorFile;
-
- /** @brief To bind the device to the OCC driver, do:
- *
- * Write occ<#>-dev0 to: /sys/bus/platform/drivers/occ-hwmon/bind
- */
- static fs::path bindPath;
-
- /** @brief To un-bind the device from the OCC driver, do:
- * Write occ<#>-dev0 to: /sys/bus/platform/drivers/occ-hwmon/unbind
- */
- static fs::path unBindPath;
-
- /** Store the associated Status instance */
- Status& statusObject;
-
- /** Abstraction of error monitoring */
- Error error;
-
- /** Abstraction of OCC presence monitoring */
- Presence presence;
-
- /** Error instances for watching for throttling events */
- Error throttleProcTemp;
- Error throttleProcPower;
- Error throttleMemTemp;
-
- /** @brief file writer to achieve bind and unbind
- *
- * @param[in] filename - Name of file to be written
- * @param[in] data - Data to be written to
- * @return - None
- */
- void write(const fs::path& fileName, const std::string& data)
- {
- // If there is an error, move the exception all the way up
- std::ofstream file(fileName, std::ios::out);
- file << data;
- file.close();
- return;
- }
-
- /** @brief Returns if device represents the master OCC */
- bool master() const;
-
- /** @brief callback for the proc temp throttle event
- *
- * @param[in] error - True if an error is reported, false otherwise
- */
- void throttleProcTempCallback(bool error);
-
- /** @brief callback for the proc power throttle event
- *
- * @param[in] error - True if an error is reported, false otherwise
- */
- void throttleProcPowerCallback(bool error);
-
- /** @brief callback for the proc temp throttle event
- *
- * @param[in] error - True if an error is reported, false otherwise
- */
- void throttleMemTempCallback(bool error);
+ }
+
+ private:
+ /** @brief Config value to be used to do bind and unbind */
+ const std::string config;
+
+ /** @brief This file contains 0 for success, non-zero for errors */
+ const fs::path errorFile;
+
+ /** @brief To bind the device to the OCC driver, do:
+ *
+ * Write occ<#>-dev0 to: /sys/bus/platform/drivers/occ-hwmon/bind
+ */
+ static fs::path bindPath;
+
+ /** @brief To un-bind the device from the OCC driver, do:
+ * Write occ<#>-dev0 to: /sys/bus/platform/drivers/occ-hwmon/unbind
+ */
+ static fs::path unBindPath;
+
+ /** Store the associated Status instance */
+ Status& statusObject;
+
+ /** Abstraction of error monitoring */
+ Error error;
+
+ /** Abstraction of OCC presence monitoring */
+ Presence presence;
+
+ /** Error instances for watching for throttling events */
+ Error throttleProcTemp;
+ Error throttleProcPower;
+ Error throttleMemTemp;
+
+ /** @brief file writer to achieve bind and unbind
+ *
+ * @param[in] filename - Name of file to be written
+ * @param[in] data - Data to be written to
+ * @return - None
+ */
+ void write(const fs::path& fileName, const std::string& data)
+ {
+ // If there is an error, move the exception all the way up
+ std::ofstream file(fileName, std::ios::out);
+ file << data;
+ file.close();
+ return;
+ }
+
+ /** @brief Returns if device represents the master OCC */
+ bool master() const;
+
+ /** @brief callback for the proc temp throttle event
+ *
+ * @param[in] error - True if an error is reported, false otherwise
+ */
+ void throttleProcTempCallback(bool error);
+
+ /** @brief callback for the proc power throttle event
+ *
+ * @param[in] error - True if an error is reported, false otherwise
+ */
+ void throttleProcPowerCallback(bool error);
+
+ /** @brief callback for the proc temp throttle event
+ *
+ * @param[in] error - True if an error is reported, false otherwise
+ */
+ void throttleMemTempCallback(bool error);
};
} // namespace occ
diff --git a/occ_errors.cpp b/occ_errors.cpp
index f4a5f69..ae66a62 100644
--- a/occ_errors.cpp
+++ b/occ_errors.cpp
@@ -1,13 +1,16 @@
+#include "occ_errors.hpp"
+
+#include "elog-errors.hpp"
+
+#include <errno.h>
#include <fcntl.h>
-#include <unistd.h>
#include <sys/ioctl.h>
-#include <errno.h>
-#include <phosphor-logging/log.hpp>
+#include <unistd.h>
+
+#include <org/open_power/OCC/Device/error.hpp>
#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
-#include <org/open_power/OCC/Device/error.hpp>
-#include "occ_errors.hpp"
-#include "elog-errors.hpp"
namespace open_power
{
namespace occ
@@ -18,8 +21,8 @@ constexpr auto NO_ERROR = '0';
using namespace phosphor::logging;
using namespace sdbusplus::org::open_power::OCC::Device::Error;
-using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
- Error::InternalFailure;
+using InternalFailure =
+ sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
// Populate the file descriptor on the error file
void Error::openFile()
@@ -29,11 +32,10 @@ void Error::openFile()
fd = open(file.c_str(), O_RDONLY | O_NONBLOCK);
if (fd < 0)
{
- elog<OpenFailure>(
- phosphor::logging::org::open_power::OCC::Device::
- OpenFailure::CALLOUT_ERRNO(errno),
- phosphor::logging::org::open_power::OCC::Device::
- OpenFailure::CALLOUT_DEVICE_PATH(file.c_str()));
+ elog<OpenFailure>(phosphor::logging::org::open_power::OCC::Device::
+ OpenFailure::CALLOUT_ERRNO(errno),
+ phosphor::logging::org::open_power::OCC::Device::
+ OpenFailure::CALLOUT_DEVICE_PATH(file.c_str()));
}
}
@@ -41,14 +43,14 @@ void Error::openFile()
void Error::registerCallBack()
{
decltype(eventSource.get()) sourcePtr = nullptr;
- auto r = sd_event_add_io(event.get(), &sourcePtr, fd,
- EPOLLPRI | EPOLLERR, processEvents, this);
+ auto r = sd_event_add_io(event.get(), &sourcePtr, fd, EPOLLPRI | EPOLLERR,
+ processEvents, this);
eventSource.reset(sourcePtr);
if (r < 0)
{
log<level::ERR>("Failed to register callback handler",
- entry("ERROR=%s", strerror(-r)));
+ entry("ERROR=%s", strerror(-r)));
elog<InternalFailure>();
}
}
@@ -90,8 +92,8 @@ void Error::removeWatch()
}
// Callback handler when there is an activity on the FD
-int Error::processEvents(sd_event_source* es, int fd,
- uint32_t revents, void* userData)
+int Error::processEvents(sd_event_source* es, int fd, uint32_t revents,
+ void* userData)
{
auto error = static_cast<Error*>(userData);
@@ -108,10 +110,10 @@ void Error::analyzeEvent()
if (r < 0)
{
elog<ConfigFailure>(
- phosphor::logging::org::open_power::OCC::Device::
- ConfigFailure::CALLOUT_ERRNO(errno),
- phosphor::logging::org::open_power::OCC::Device::
- ConfigFailure::CALLOUT_DEVICE_PATH(file.c_str()));
+ phosphor::logging::org::open_power::OCC::Device::ConfigFailure::
+ CALLOUT_ERRNO(errno),
+ phosphor::logging::org::open_power::OCC::Device::ConfigFailure::
+ CALLOUT_DEVICE_PATH(file.c_str()));
}
// A non-zero data indicates an error condition
@@ -128,7 +130,7 @@ void Error::analyzeEvent()
// Reads so many bytes as passed in
std::string Error::readFile(int len) const
{
- auto data = std::make_unique<char[]>(len+1);
+ auto data = std::make_unique<char[]>(len + 1);
auto retries = 3;
auto delay = std::chrono::milliseconds{100};
@@ -164,10 +166,10 @@ std::string Error::readFile(int len) const
{
log<level::ERR>("Failure seeking error file to START");
elog<ConfigFailure>(
- phosphor::logging::org::open_power::OCC::Device::
- ConfigFailure::CALLOUT_ERRNO(errno),
- phosphor::logging::org::open_power::OCC::Device::
- ConfigFailure::CALLOUT_DEVICE_PATH(file.c_str()));
+ phosphor::logging::org::open_power::OCC::Device::ConfigFailure::
+ CALLOUT_ERRNO(errno),
+ phosphor::logging::org::open_power::OCC::Device::ConfigFailure::
+ CALLOUT_DEVICE_PATH(file.c_str()));
}
return std::string(data.get());
}
diff --git a/occ_errors.hpp b/occ_errors.hpp
index 12ae925..ebacc8a 100644
--- a/occ_errors.hpp
+++ b/occ_errors.hpp
@@ -1,10 +1,13 @@
#pragma once
+#include "config.h"
+
+#include "occ_events.hpp"
+
#include <unistd.h>
-#include <functional>
+
#include <experimental/filesystem>
-#include "occ_events.hpp"
-#include "config.h"
+#include <functional>
namespace open_power
{
namespace occ
@@ -17,94 +20,92 @@ namespace fs = std::experimental::filesystem;
*/
class Error
{
- public:
- Error() = delete;
- Error(const Error&) = delete;
- Error& operator=(const Error&) = delete;
- Error(Error&&) = default;
- Error& operator=(Error&&) = default;
-
- /** @brief Constructs the Error object
- *
- * @param[in] event - reference to sd_event unique_ptr
- * @param[in] file - File used by driver to communicate errors
- * @param[in] callBack - Optional function callback on error condition
- */
- Error(EventPtr& event,
- const fs::path& file,
- std::function<void(bool)> callBack = nullptr) :
- event(event),
- file(fs::path(DEV_PATH) / file),
- callBack(callBack)
- {
- // Nothing to do here.
- }
-
- ~Error()
+ public:
+ Error() = delete;
+ Error(const Error&) = delete;
+ Error& operator=(const Error&) = delete;
+ Error(Error&&) = default;
+ Error& operator=(Error&&) = default;
+
+ /** @brief Constructs the Error object
+ *
+ * @param[in] event - reference to sd_event unique_ptr
+ * @param[in] file - File used by driver to communicate errors
+ * @param[in] callBack - Optional function callback on error condition
+ */
+ Error(EventPtr& event, const fs::path& file,
+ std::function<void(bool)> callBack = nullptr) :
+ event(event),
+ file(fs::path(DEV_PATH) / file), callBack(callBack)
+ {
+ // Nothing to do here.
+ }
+
+ ~Error()
+ {
+ if (fd >= 0)
{
- if (fd>= 0)
- {
- close(fd);
- }
+ close(fd);
}
-
- /** @brief Starts to monitor for error conditions */
- void addWatch();
-
- /** @brief Removes error watch */
- void removeWatch();
-
- private:
- /** @brief sd_event wrapped in unique_ptr */
- EventPtr& event;
-
- /** @brief event source wrapped in unique_ptr */
- EventSourcePtr eventSource;
-
- /** @brief Current state of error watching */
- bool watching = false;
-
- /** @brief attaches FD to events and sets up callback handler */
- void registerCallBack();
-
- /** @brief Opens the file and populates fd */
- void openFile();
-
- /** @brief Callback handler when the FD has some activity on it
- *
- * @param[in] es - Populated event source
- * @param[in] fd - Associated File descriptor
- * @param[in] revents - Type of event
- * @param[in] userData - User data that was passed during registration
- *
- * @return - 0 or positive number on success and negative
- * errno otherwise
- */
- static int processEvents(sd_event_source* es, int fd,
- uint32_t revents, void* userData);
-
- /** @brief When the error event is received, analyzes it
- * and makes a callback to error handler if the
- * content denotes an error condition
- */
- virtual void analyzeEvent();
-
- protected:
- /** @brief File descriptor to watch for errors */
- int fd = -1;
-
- /** Error file */
- const fs::path file;
-
- /** @brief Optional function to call on error scenario */
- std::function<void(bool)> callBack;
-
- /** @brief Reads file data
- *
- * @return data read. Since its a /sysfs entry,
- * it would be a string
- */
- std::string readFile(int) const;
+ }
+
+ /** @brief Starts to monitor for error conditions */
+ void addWatch();
+
+ /** @brief Removes error watch */
+ void removeWatch();
+
+ private:
+ /** @brief sd_event wrapped in unique_ptr */
+ EventPtr& event;
+
+ /** @brief event source wrapped in unique_ptr */
+ EventSourcePtr eventSource;
+
+ /** @brief Current state of error watching */
+ bool watching = false;
+
+ /** @brief attaches FD to events and sets up callback handler */
+ void registerCallBack();
+
+ /** @brief Opens the file and populates fd */
+ void openFile();
+
+ /** @brief Callback handler when the FD has some activity on it
+ *
+ * @param[in] es - Populated event source
+ * @param[in] fd - Associated File descriptor
+ * @param[in] revents - Type of event
+ * @param[in] userData - User data that was passed during registration
+ *
+ * @return - 0 or positive number on success and negative
+ * errno otherwise
+ */
+ static int processEvents(sd_event_source* es, int fd, uint32_t revents,
+ void* userData);
+
+ /** @brief When the error event is received, analyzes it
+ * and makes a callback to error handler if the
+ * content denotes an error condition
+ */
+ virtual void analyzeEvent();
+
+ protected:
+ /** @brief File descriptor to watch for errors */
+ int fd = -1;
+
+ /** Error file */
+ const fs::path file;
+
+ /** @brief Optional function to call on error scenario */
+ std::function<void(bool)> callBack;
+
+ /** @brief Reads file data
+ *
+ * @return data read. Since its a /sysfs entry,
+ * it would be a string
+ */
+ std::string readFile(int) const;
};
} // namespace occ
diff --git a/occ_finder.cpp b/occ_finder.cpp
index 0c02c35..a9f98d6 100644
--- a/occ_finder.cpp
+++ b/occ_finder.cpp
@@ -1,12 +1,14 @@
+#include "config.h"
+
+#include "occ_finder.hpp"
+
#include <algorithm>
-#include <iterator>
#include <experimental/filesystem>
-#include <sdbusplus/server.hpp>
+#include <iterator>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
+#include <sdbusplus/server.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
-#include "occ_finder.hpp"
-#include "config.h"
namespace open_power
{
namespace occ
@@ -23,27 +25,22 @@ constexpr auto toChar(size_t c)
}
template <typename T>
-T getDbusProperty(sdbusplus::bus::bus& bus,
- const std::string& service,
- const std::string& objPath,
- const std::string& interface,
+T getDbusProperty(sdbusplus::bus::bus& bus, const std::string& service,
+ const std::string& objPath, const std::string& interface,
const std::string& property)
{
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
constexpr auto PROPERTY_INTF = "org.freedesktop.DBus.Properties";
- auto method = bus.new_method_call(
- service.c_str(),
- objPath.c_str(),
- PROPERTY_INTF,
- "Get");
+ auto method = bus.new_method_call(service.c_str(), objPath.c_str(),
+ PROPERTY_INTF, "Get");
method.append(interface, property);
auto reply = bus.call(method);
if (reply.is_method_error())
{
- log<level::ERR>("Failed to get property",
+ log<level::ERR>("Failed to get property",
entry("PROPERTY=%s", property.c_str()),
entry("PATH=%s", objPath.c_str()),
entry("INTERFACE=%s", interface.c_str()));
@@ -65,19 +62,15 @@ std::vector<std::string> get(sdbusplus::bus::bus& bus)
using Interfaces = std::vector<Interface>;
auto mapper =
- bus.new_method_call(
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper",
- "GetSubTree");
+ bus.new_method_call("xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetSubTree");
auto depth = 0;
Path path = CPU_SUBPATH;
- Interfaces interfaces
- {
+ Interfaces interfaces{
"xyz.openbmc_project.Inventory.Item",
- "xyz.openbmc_project.State.Decorator.OperationalStatus"
- };
+ "xyz.openbmc_project.State.Decorator.OperationalStatus"};
mapper.append(path);
mapper.append(depth);
@@ -110,9 +103,7 @@ std::vector<std::string> get(sdbusplus::bus::bus& bus)
{
Criteria match{};
match.emplace_back(std::make_tuple(
- "xyz.openbmc_project.Inventory.Item",
- "Present",
- true));
+ "xyz.openbmc_project.Inventory.Item", "Present", true));
// Select only if the CPU is marked 'Present'.
// Local variable to make it readable
@@ -120,8 +111,7 @@ std::vector<std::string> get(sdbusplus::bus::bus& bus)
auto service = entry->second.begin()->first;
if (matchCriteria(bus, path, service, match))
{
- occs.emplace_back(std::string(OCC_NAME) +
- toChar(count));
+ occs.emplace_back(std::string(OCC_NAME) + toChar(count));
}
}
}
@@ -129,16 +119,13 @@ std::vector<std::string> get(sdbusplus::bus::bus& bus)
return occs;
}
-bool matchCriteria(sdbusplus::bus::bus& bus,
- const std::string& path,
- const std::string& service,
- const Criteria& match)
+bool matchCriteria(sdbusplus::bus::bus& bus, const std::string& path,
+ const std::string& service, const Criteria& match)
{
- for (const auto& iter: match)
+ for (const auto& iter : match)
{
- auto result = getDbusProperty<bool>(bus, service, path,
- std::get<0>(iter),
- std::get<1>(iter));
+ auto result = getDbusProperty<bool>(
+ bus, service, path, std::get<0>(iter), std::get<1>(iter));
if (result != std::get<2>(iter))
{
return false;
diff --git a/occ_finder.hpp b/occ_finder.hpp
index 557d468..59b5984 100644
--- a/occ_finder.hpp
+++ b/occ_finder.hpp
@@ -1,8 +1,8 @@
#pragma once
-#include <vector>
-#include <string>
#include <sdbusplus/bus.hpp>
+#include <string>
+#include <vector>
namespace open_power
{
@@ -21,10 +21,10 @@ using Match = std::tuple<Interface, Property, Value>;
using Criteria = std::vector<Match>;
/** @brief Get OCC objects on the system by mapping them to CPU inventory
- * @returns vector of occ objects, such as occ0, occ1, and so on.
- *
- * @param[in] bus - sdbusplus handler
- */
+ * @returns vector of occ objects, such as occ0, occ1, and so on.
+ *
+ * @param[in] bus - sdbusplus handler
+ */
std::vector<std::string> get(sdbusplus::bus::bus& bus);
/** @brief Returns true if the inventory item matches the criteria
@@ -36,10 +36,8 @@ std::vector<std::string> get(sdbusplus::bus::bus& bus);
*
* @return true on match, false otherwise
*/
-bool matchCriteria(sdbusplus::bus::bus& bus,
- const std::string& path,
- const std::string& service,
- const Criteria& match);
+bool matchCriteria(sdbusplus::bus::bus& bus, const std::string& path,
+ const std::string& service, const Criteria& match);
/** @brief Gets the value associated with the given object
* and the interface.
@@ -54,10 +52,8 @@ bool matchCriteria(sdbusplus::bus::bus& bus,
*/
template <typename T>
-T getDbusProperty(sdbusplus::bus::bus& bus,
- const std::string& service,
- const std::string& objPath,
- const std::string& interface,
+T getDbusProperty(sdbusplus::bus::bus& bus, const std::string& service,
+ const std::string& objPath, const std::string& interface,
const std::string& property);
} // namespace finder
diff --git a/occ_manager.cpp b/occ_manager.cpp
index 6fd0652..d420eea 100644
--- a/occ_manager.cpp
+++ b/occ_manager.cpp
@@ -1,12 +1,15 @@
-#include <experimental/filesystem>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include <xyz/openbmc_project/Common/error.hpp>
-#include "occ_finder.hpp"
+#include "config.h"
+
#include "occ_manager.hpp"
+
#include "i2c_occ.hpp"
+#include "occ_finder.hpp"
#include "utils.hpp"
-#include "config.h"
+
+#include <experimental/filesystem>
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/log.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
namespace open_power
{
@@ -45,33 +48,26 @@ void Manager::createObjects(const std::string& occ)
auto path = fs::path(OCC_CONTROL_ROOT) / occ;
passThroughObjects.emplace_back(
- std::make_unique<PassThrough>(
- bus,
- path.c_str()));
-
- statusObjects.emplace_back(
- std::make_unique<Status>(
- bus,
- event,
- path.c_str(),
- *this,
- std::bind(std::mem_fn(&Manager::statusCallBack),
- this, std::placeholders::_1)));
+ std::make_unique<PassThrough>(bus, path.c_str()));
+
+ statusObjects.emplace_back(std::make_unique<Status>(
+ bus, event, path.c_str(), *this,
+ std::bind(std::mem_fn(&Manager::statusCallBack), this,
+ std::placeholders::_1)));
// Create the power cap monitor object for master occ (0)
if (!pcap)
{
pcap = std::make_unique<open_power::occ::powercap::PowerCap>(
- bus,
- *statusObjects.front());
+ bus, *statusObjects.front());
}
}
void Manager::statusCallBack(bool status)
{
using namespace phosphor::logging;
- using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
- Error::InternalFailure;
+ using InternalFailure =
+ sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
// At this time, it won't happen but keeping it
// here just in case something changes in the future
@@ -86,7 +82,7 @@ void Manager::statusCallBack(bool status)
// Only start presence detection if all the OCCs are bound
if (activeCount == statusObjects.size())
{
- for (auto &obj : statusObjects)
+ for (auto& obj : statusObjects)
{
obj->addPresenceWatchMaster();
}
@@ -107,17 +103,11 @@ void Manager::initStatusObjects()
name = std::string(OCC_NAME) + '_' + name;
auto path = fs::path(OCC_CONTROL_ROOT) / name;
statusObjects.emplace_back(
- std::make_unique<Status>(
- bus,
- event,
- path.c_str(),
- *this));
+ std::make_unique<Status>(bus, event, path.c_str(), *this));
}
// The first device is master occ
pcap = std::make_unique<open_power::occ::powercap::PowerCap>(
- bus,
- *statusObjects.front(),
- occMasterName);
+ bus, *statusObjects.front(), occMasterName);
}
#endif
diff --git a/occ_manager.hpp b/occ_manager.hpp
index 542c7d9..20002e4 100644
--- a/occ_manager.hpp
+++ b/occ_manager.hpp
@@ -1,13 +1,14 @@
#pragma once
-#include <cstring>
-#include <vector>
-#include <functional>
-#include <sdbusplus/bus.hpp>
#include "occ_pass_through.hpp"
#include "occ_status.hpp"
#include "powercap.hpp"
+#include <cstring>
+#include <functional>
+#include <sdbusplus/bus.hpp>
+#include <vector>
+
namespace sdbusRule = sdbusplus::bus::match::rules;
namespace open_power
{
@@ -19,102 +20,99 @@ namespace occ
*/
struct Manager
{
- public:
- Manager() = delete;
- Manager(const Manager&) = delete;
- Manager& operator=(const Manager&) = delete;
- Manager(Manager&&) = delete;
- Manager& operator=(Manager&&) = delete;
- ~Manager() = default;
-
- /** @brief Adds OCC pass-through and status objects on the bus
- * when corresponding CPU inventory is created.
- *
- * @param[in] bus - handle to the bus
- * @param[in] event - Unique ptr reference to sd_event
- */
- Manager(sdbusplus::bus::bus& bus,
- EventPtr& event) :
- bus(bus),
- event(event)
- {
+ public:
+ Manager() = delete;
+ Manager(const Manager&) = delete;
+ Manager& operator=(const Manager&) = delete;
+ Manager(Manager&&) = delete;
+ Manager& operator=(Manager&&) = delete;
+ ~Manager() = default;
+
+ /** @brief Adds OCC pass-through and status objects on the bus
+ * when corresponding CPU inventory is created.
+ *
+ * @param[in] bus - handle to the bus
+ * @param[in] event - Unique ptr reference to sd_event
+ */
+ Manager(sdbusplus::bus::bus& bus, EventPtr& event) : bus(bus), event(event)
+ {
#ifdef I2C_OCC
- // I2C OCC status objects are initialized directly
- initStatusObjects();
+ // I2C OCC status objects are initialized directly
+ initStatusObjects();
#else
- findAndCreateObjects();
+ findAndCreateObjects();
#endif
- }
-
- inline auto getNumOCCs() const
- {
- return activeCount;
- }
-
- private:
- /** @brief Checks if the CPU inventory is present and if so, creates
- * the occ D-Bus objects. Else, registers a handler to be
- * called when inventory is created.
- */
- void findAndCreateObjects();
-
- /** @brief Callback that responds to cpu creation in the inventory -
- * by creating the needed objects.
- *
- * @param[in] msg - bus message
- *
- * @returns 0 to indicate success
- */
- int cpuCreated(sdbusplus::message::message& msg);
-
- /** @brief Create child OCC objects.
- *
- * @param[in] occ - the occ name, such as occ0.
- */
- void createObjects(const std::string& occ);
-
- /** @brief Callback handler invoked by Status object when the OccActive
- * property is changed. This is needed to make sure that the
- * error detection is started only after all the OCCs are bound.
- * Similarly, when one of the OCC gets its OccActive property
- * un-set, then the OCC error detection needs to be stopped on
- * all the OCCs
- *
- * @param[in] status - OccActive status
- */
- void statusCallBack(bool status);
-
- /** @brief Sends a Heartbeat command to host control command handler */
- void sendHeartBeat();
-
- /** @brief reference to the bus */
- sdbusplus::bus::bus& bus;
-
- /** @brief reference to sd_event wrapped in unique_ptr */
- EventPtr& event;
-
- /** @brief OCC pass-through objects */
- std::vector<std::unique_ptr<PassThrough>> passThroughObjects;
-
- /** @brief OCC Status objects */
- std::vector<std::unique_ptr<Status>> statusObjects;
-
- /** @brief Power cap monitor and occ notification object */
- std::unique_ptr<open_power::occ::powercap::PowerCap> pcap;
-
- /** @brief sbdbusplus match objects */
- std::vector<sdbusplus::bus::match_t> cpuMatches;
-
- /** @brief Number of OCCs that are bound */
- uint8_t activeCount = 0;
+ }
+
+ inline auto getNumOCCs() const
+ {
+ return activeCount;
+ }
+
+ private:
+ /** @brief Checks if the CPU inventory is present and if so, creates
+ * the occ D-Bus objects. Else, registers a handler to be
+ * called when inventory is created.
+ */
+ void findAndCreateObjects();
+
+ /** @brief Callback that responds to cpu creation in the inventory -
+ * by creating the needed objects.
+ *
+ * @param[in] msg - bus message
+ *
+ * @returns 0 to indicate success
+ */
+ int cpuCreated(sdbusplus::message::message& msg);
+
+ /** @brief Create child OCC objects.
+ *
+ * @param[in] occ - the occ name, such as occ0.
+ */
+ void createObjects(const std::string& occ);
+
+ /** @brief Callback handler invoked by Status object when the OccActive
+ * property is changed. This is needed to make sure that the
+ * error detection is started only after all the OCCs are bound.
+ * Similarly, when one of the OCC gets its OccActive property
+ * un-set, then the OCC error detection needs to be stopped on
+ * all the OCCs
+ *
+ * @param[in] status - OccActive status
+ */
+ void statusCallBack(bool status);
+
+ /** @brief Sends a Heartbeat command to host control command handler */
+ void sendHeartBeat();
+
+ /** @brief reference to the bus */
+ sdbusplus::bus::bus& bus;
+
+ /** @brief reference to sd_event wrapped in unique_ptr */
+ EventPtr& event;
+
+ /** @brief OCC pass-through objects */
+ std::vector<std::unique_ptr<PassThrough>> passThroughObjects;
+
+ /** @brief OCC Status objects */
+ std::vector<std::unique_ptr<Status>> statusObjects;
+
+ /** @brief Power cap monitor and occ notification object */
+ std::unique_ptr<open_power::occ::powercap::PowerCap> pcap;
+
+ /** @brief sbdbusplus match objects */
+ std::vector<sdbusplus::bus::match_t> cpuMatches;
+
+ /** @brief Number of OCCs that are bound */
+ uint8_t activeCount = 0;
#ifdef I2C_OCC
- /** @brief Init Status objects for I2C OCC devices
- *
- * It iterates in /sys/bus/i2c/devices, finds all occ hwmon devices
- * and creates status objects.
- */
- void initStatusObjects();
+ /** @brief Init Status objects for I2C OCC devices
+ *
+ * It iterates in /sys/bus/i2c/devices, finds all occ hwmon devices
+ * and creates status objects.
+ */
+ void initStatusObjects();
#endif
};
diff --git a/occ_pass_through.cpp b/occ_pass_through.cpp
index 424cc22..a92d824 100644
--- a/occ_pass_through.cpp
+++ b/occ_pass_through.cpp
@@ -1,31 +1,31 @@
-#include <memory>
-#include <algorithm>
-#include <fcntl.h>
+#include "config.h"
+
+#include "occ_pass_through.hpp"
+
+#include "elog-errors.hpp"
+
#include <errno.h>
-#include <string>
+#include <fcntl.h>
#include <unistd.h>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog.hpp>
+
+#include <algorithm>
+#include <memory>
#include <org/open_power/OCC/Device/error.hpp>
-#include "occ_pass_through.hpp"
-#include "elog-errors.hpp"
-#include "config.h"
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/log.hpp>
+#include <string>
namespace open_power
{
namespace occ
{
-PassThrough::PassThrough(
- sdbusplus::bus::bus& bus,
- const char* path) :
- Iface(bus, path),
- path(path),
+PassThrough::PassThrough(sdbusplus::bus::bus& bus, const char* path) :
+ Iface(bus, path), path(path),
devicePath(OCC_DEV_PATH + std::to_string((this->path.back() - '0') + 1)),
activeStatusSignal(
- bus,
- sdbusRule::propertiesChanged(path, "org.open_power.OCC.Status"),
- std::bind(std::mem_fn(&PassThrough::activeStatusEvent),
- this, std::placeholders::_1))
+ bus, sdbusRule::propertiesChanged(path, "org.open_power.OCC.Status"),
+ std::bind(std::mem_fn(&PassThrough::activeStatusEvent), this,
+ std::placeholders::_1))
{
// Nothing to do.
}
@@ -37,8 +37,8 @@ void PassThrough::openDevice()
if (!occActive)
{
- log<level::INFO>("OCC is inactive; cannot perform pass-through");
- return;
+ log<level::INFO>("OCC is inactive; cannot perform pass-through");
+ return;
}
fd = open(devicePath.c_str(), O_RDWR | O_NONBLOCK);
@@ -46,10 +46,10 @@ void PassThrough::openDevice()
{
// This would log and terminate since its not handled.
elog<OpenFailure>(
- phosphor::logging::org::open_power::OCC::Device::
- OpenFailure::CALLOUT_ERRNO(errno),
- phosphor::logging::org::open_power::OCC::Device::
- OpenFailure::CALLOUT_DEVICE_PATH(devicePath.c_str()));
+ phosphor::logging::org::open_power::OCC::Device::OpenFailure::
+ CALLOUT_ERRNO(errno),
+ phosphor::logging::org::open_power::OCC::Device::OpenFailure::
+ CALLOUT_DEVICE_PATH(devicePath.c_str()));
}
return;
}
@@ -68,7 +68,7 @@ std::vector<int32_t> PassThrough::send(std::vector<int32_t> command)
using namespace phosphor::logging;
using namespace sdbusplus::org::open_power::OCC::Device::Error;
- std::vector<int32_t> response {};
+ std::vector<int32_t> response{};
openDevice();
@@ -85,7 +85,7 @@ std::vector<int32_t> PassThrough::send(std::vector<int32_t> command)
// Populate uint8_t version of vector.
std::transform(command.begin(), command.end(), cmdInBytes.begin(),
- [](decltype(cmdInBytes)::value_type x){return x;});
+ [](decltype(cmdInBytes)::value_type x) { return x; });
ssize_t size = cmdInBytes.size() * sizeof(decltype(cmdInBytes)::value_type);
auto rc = write(fd, cmdInBytes.data(), size);
@@ -93,16 +93,16 @@ std::vector<int32_t> PassThrough::send(std::vector<int32_t> command)
{
// This would log and terminate since its not handled.
elog<WriteFailure>(
- phosphor::logging::org::open_power::OCC::Device::
- WriteFailure::CALLOUT_ERRNO(errno),
- phosphor::logging::org::open_power::OCC::Device::
- WriteFailure::CALLOUT_DEVICE_PATH(devicePath.c_str()));
+ phosphor::logging::org::open_power::OCC::Device::WriteFailure::
+ CALLOUT_ERRNO(errno),
+ phosphor::logging::org::open_power::OCC::Device::WriteFailure::
+ CALLOUT_DEVICE_PATH(devicePath.c_str()));
}
// Now read the response. This would be the content of occ-sram
- while(1)
+ while (1)
{
- uint8_t data {};
+ uint8_t data{};
auto len = read(fd, &data, sizeof(data));
if (len > 0)
{
@@ -123,10 +123,10 @@ std::vector<int32_t> PassThrough::send(std::vector<int32_t> command)
{
// This would log and terminate since its not handled.
elog<ReadFailure>(
- phosphor::logging::org::open_power::OCC::Device::
- ReadFailure::CALLOUT_ERRNO(errno),
- phosphor::logging::org::open_power::OCC::Device::
- ReadFailure::CALLOUT_DEVICE_PATH(devicePath.c_str()));
+ phosphor::logging::org::open_power::OCC::Device::ReadFailure::
+ CALLOUT_ERRNO(errno),
+ phosphor::logging::org::open_power::OCC::Device::ReadFailure::
+ CALLOUT_DEVICE_PATH(devicePath.c_str()));
}
}
diff --git a/occ_pass_through.hpp b/occ_pass_through.hpp
index 384a065..a28eb6a 100644
--- a/occ_pass_through.hpp
+++ b/occ_pass_through.hpp
@@ -1,9 +1,9 @@
#pragma once
-#include <string>
+#include <org/open_power/OCC/PassThrough/server.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
-#include <org/open_power/OCC/PassThrough/server.hpp>
+#include <string>
namespace open_power
{
@@ -21,69 +21,67 @@ namespace sdbusRule = sdbusplus::bus::match::rules;
*/
class PassThrough : public Iface
{
- public:
- PassThrough() = delete;
- PassThrough(const PassThrough&) = delete;
- PassThrough& operator=(const PassThrough&) = delete;
- PassThrough(PassThrough&&) = default;
- PassThrough& operator=(PassThrough&&) = default;
-
- /** @brief Ctor to put pass-through d-bus object on the bus
- * @param[in] bus - Bus to attach to
- * @param[in] path - Path to attach at
- */
- PassThrough(sdbusplus::bus::bus& bus,
- const char* path);
-
- ~PassThrough()
- {
- closeDevice();
- }
-
- /** @brief Pass through command to OCC
- * @param[in] command - command to pass-through
- * @returns OCC response as an array
- */
- std::vector<std::int32_t>
- send(std::vector<std::int32_t> command) override;
-
- private:
- /** @brief Pass-through occ path on the bus */
- std::string path;
-
- /** @brief OCC device path
- * For now, here is the hard-coded mapping until
- * the udev rule is in.
- * occ0 --> /dev/occ1
- * occ1 --> /dev/occ2
- * ...
- */
- std::string devicePath;
-
- /** @brief Indicates whether or not the OCC is currently active */
- bool occActive = false;
-
- /** brief file descriptor associated with occ device */
- int fd = -1;
-
- /** @brief Subscribe to OCC Status signal
- *
- * Once the OCC status gets to active, only then we will get /dev/occ2
- * populated and hence need to wait on that before opening that
- */
- sdbusplus::bus::match_t activeStatusSignal;
-
- /** Opens devicePath and populates file descritor */
- void openDevice();
-
- /** Closed the fd associated with opened device */
- void closeDevice();
-
- /** @brief Callback function on OCC Status change signals
- *
- * @param[in] msg - Data associated with subscribed signal
- */
- void activeStatusEvent(sdbusplus::message::message& msg);
+ public:
+ PassThrough() = delete;
+ PassThrough(const PassThrough&) = delete;
+ PassThrough& operator=(const PassThrough&) = delete;
+ PassThrough(PassThrough&&) = default;
+ PassThrough& operator=(PassThrough&&) = default;
+
+ /** @brief Ctor to put pass-through d-bus object on the bus
+ * @param[in] bus - Bus to attach to
+ * @param[in] path - Path to attach at
+ */
+ PassThrough(sdbusplus::bus::bus& bus, const char* path);
+
+ ~PassThrough()
+ {
+ closeDevice();
+ }
+
+ /** @brief Pass through command to OCC
+ * @param[in] command - command to pass-through
+ * @returns OCC response as an array
+ */
+ std::vector<std::int32_t> send(std::vector<std::int32_t> command) override;
+
+ private:
+ /** @brief Pass-through occ path on the bus */
+ std::string path;
+
+ /** @brief OCC device path
+ * For now, here is the hard-coded mapping until
+ * the udev rule is in.
+ * occ0 --> /dev/occ1
+ * occ1 --> /dev/occ2
+ * ...
+ */
+ std::string devicePath;
+
+ /** @brief Indicates whether or not the OCC is currently active */
+ bool occActive = false;
+
+ /** brief file descriptor associated with occ device */
+ int fd = -1;
+
+ /** @brief Subscribe to OCC Status signal
+ *
+ * Once the OCC status gets to active, only then we will get /dev/occ2
+ * populated and hence need to wait on that before opening that
+ */
+ sdbusplus::bus::match_t activeStatusSignal;
+
+ /** Opens devicePath and populates file descritor */
+ void openDevice();
+
+ /** Closed the fd associated with opened device */
+ void closeDevice();
+
+ /** @brief Callback function on OCC Status change signals
+ *
+ * @param[in] msg - Data associated with subscribed signal
+ */
+ void activeStatusEvent(sdbusplus::message::message& msg);
};
} // namespace occ
diff --git a/occ_presence.cpp b/occ_presence.cpp
index 59b886a..ab9b322 100644
--- a/occ_presence.cpp
+++ b/occ_presence.cpp
@@ -1,14 +1,17 @@
+#include "occ_presence.hpp"
+
+#include "elog-errors.hpp"
+#include "occ_manager.hpp"
+
+#include <errno.h>
#include <fcntl.h>
-#include <unistd.h>
#include <sys/ioctl.h>
-#include <errno.h>
-#include <phosphor-logging/log.hpp>
+#include <unistd.h>
+
+#include <org/open_power/OCC/Device/error.hpp>
#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
-#include <org/open_power/OCC/Device/error.hpp>
-#include "occ_presence.hpp"
-#include "occ_manager.hpp"
-#include "elog-errors.hpp"
namespace open_power
{
@@ -27,10 +30,10 @@ void Presence::analyzeEvent()
if (r < 0)
{
elog<ConfigFailure>(
- phosphor::logging::org::open_power::OCC::Device::
- ConfigFailure::CALLOUT_ERRNO(errno),
- phosphor::logging::org::open_power::OCC::Device::
- ConfigFailure::CALLOUT_DEVICE_PATH(file.c_str()));
+ phosphor::logging::org::open_power::OCC::Device::ConfigFailure::
+ CALLOUT_ERRNO(errno),
+ phosphor::logging::org::open_power::OCC::Device::ConfigFailure::
+ CALLOUT_DEVICE_PATH(file.c_str()));
}
auto data = readFile(len);
diff --git a/occ_presence.hpp b/occ_presence.hpp
index e0bd3ad..9e66acc 100644
--- a/occ_presence.hpp
+++ b/occ_presence.hpp
@@ -13,39 +13,37 @@ class Manager;
*/
class Presence : public Error
{
- public:
- Presence() = delete;
- Presence(const Presence&) = delete;
- Presence& operator=(const Presence&) = delete;
- Presence(Presence&&) = default;
- Presence& operator=(Presence&&) = default;
+ public:
+ Presence() = delete;
+ Presence(const Presence&) = delete;
+ Presence& operator=(const Presence&) = delete;
+ Presence(Presence&&) = default;
+ Presence& operator=(Presence&&) = default;
- /** @brief Constructs the Presence object
- *
- * @param[in] event - Reference to sd_event unique_ptr
- * @param[in] file - File used by driver to communicate errors
- * @param[in] mgr - OCC manager instance
- * @param[in] callBack - Optional function callback on error condition
- */
- Presence(EventPtr& event,
- const fs::path& file,
- const Manager& mgr,
- std::function<void(bool)> callBack = nullptr) :
- Error(event, file, callBack),
- manager(mgr)
- {
- // Nothing to do here.
- }
+ /** @brief Constructs the Presence object
+ *
+ * @param[in] event - Reference to sd_event unique_ptr
+ * @param[in] file - File used by driver to communicate errors
+ * @param[in] mgr - OCC manager instance
+ * @param[in] callBack - Optional function callback on error condition
+ */
+ Presence(EventPtr& event, const fs::path& file, const Manager& mgr,
+ std::function<void(bool)> callBack = nullptr) :
+ Error(event, file, callBack),
+ manager(mgr)
+ {
+ // Nothing to do here.
+ }
- private:
- /** Store the manager instance to enable getting number of OCCs */
- const Manager& manager;
+ private:
+ /** Store the manager instance to enable getting number of OCCs */
+ const Manager& manager;
- /** @brief When the error event is received, analyzes it
- * and makes a callback to error handler if the
- * content denotes an error condition
- */
- void analyzeEvent() override;
+ /** @brief When the error event is received, analyzes it
+ * and makes a callback to error handler if the
+ * content denotes an error condition
+ */
+ void analyzeEvent() override;
};
} // namespace occ
diff --git a/occ_status.cpp b/occ_status.cpp
index 26f2979..c2c4bae 100644
--- a/occ_status.cpp
+++ b/occ_status.cpp
@@ -1,7 +1,9 @@
-#include <phosphor-logging/log.hpp>
#include "occ_status.hpp"
+
#include "occ_sensor.hpp"
#include "utils.hpp"
+
+#include <phosphor-logging/log.hpp>
namespace open_power
{
namespace occ
@@ -87,17 +89,13 @@ void Status::resetOCC()
// This will throw exception on failure
auto service = getService(bus, CONTROL_HOST_PATH, CONTROL_HOST_INTF);
- auto method = bus.new_method_call(service.c_str(),
- CONTROL_HOST_PATH,
- CONTROL_HOST_INTF,
- "Execute");
+ auto method = bus.new_method_call(service.c_str(), CONTROL_HOST_PATH,
+ CONTROL_HOST_INTF, "Execute");
// OCC Reset control command
- method.append(convertForMessage(
- Control::Host::Command::OCCReset).c_str());
+ method.append(convertForMessage(Control::Host::Command::OCCReset).c_str());
// OCC Sensor ID for callout reasons
- method.append(sdbusplus::message::variant<uint8_t>(
- sensorMap.at(instance)));
+ method.append(sdbusplus::message::variant<uint8_t>(sensorMap.at(instance)));
bus.call_noreply(method);
return;
}
@@ -114,19 +112,19 @@ void Status::hostControlEvent(sdbusplus::message::message& msg)
msg.read(cmdCompleted, cmdStatus);
log<level::DEBUG>("Host control signal values",
- entry("COMMAND=%s",cmdCompleted.c_str()),
- entry("STATUS=%s",cmdStatus.c_str()));
+ entry("COMMAND=%s", cmdCompleted.c_str()),
+ entry("STATUS=%s", cmdStatus.c_str()));
- if(Control::Host::convertResultFromString(cmdStatus) !=
- Control::Host::Result::Success)
+ if (Control::Host::convertResultFromString(cmdStatus) !=
+ Control::Host::Result::Success)
{
- if(Control::Host::convertCommandFromString(cmdCompleted) ==
- Control::Host::Command::OCCReset)
+ if (Control::Host::convertCommandFromString(cmdCompleted) ==
+ Control::Host::Command::OCCReset)
{
// Must be a Timeout. Log an Error trace
log<level::ERR>("Error resetting the OCC.",
- entry("PATH=%s", path.c_str()),
- entry("SENSORID=0x%X",sensorMap.at(instance)));
+ entry("PATH=%s", path.c_str()),
+ entry("SENSORID=0x%X", sensorMap.at(instance)));
}
}
return;
diff --git a/occ_status.hpp b/occ_status.hpp
index f14bd7d..9e6c687 100644
--- a/occ_status.hpp
+++ b/occ_status.hpp
@@ -1,13 +1,14 @@
#pragma once
+#include "i2c_occ.hpp"
+#include "occ_device.hpp"
+#include "occ_events.hpp"
+
#include <functional>
+#include <org/open_power/Control/Host/server.hpp>
+#include <org/open_power/OCC/Status/server.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
-#include <org/open_power/OCC/Status/server.hpp>
-#include <org/open_power/Control/Host/server.hpp>
-#include "occ_events.hpp"
-#include "occ_device.hpp"
-#include "i2c_occ.hpp"
namespace open_power
{
@@ -38,142 +39,135 @@ const std::string sysfsName = "occ-hwmon";
*/
class Status : public Interface
{
- public:
- Status() = delete;
- ~Status() = default;
- Status(const Status&) = delete;
- Status& operator=(const Status&) = delete;
- Status(Status&&) = default;
- Status& operator=(Status&&) = default;
-
- /** @brief Constructs the Status object and
- * the underlying device object
- *
- * @param[in] bus - DBus bus to attach to
- * @param[in] event - sd_event unique pointer reference
- * @param[in] path - DBus object path
- * @param[in] manager - OCC manager instance
- * @param[in] callBack - Callback handler to invoke during
- * property change
- */
- Status(sdbusplus::bus::bus& bus,
- EventPtr& event,
- const char* path,
- const Manager& manager,
- std::function<void(bool)> callBack = nullptr)
- : Interface(bus, path, true),
- bus(bus),
- path(path),
- callBack(callBack),
- instance(((this->path.back() - '0'))),
- device(event,
+ public:
+ Status() = delete;
+ ~Status() = default;
+ Status(const Status&) = delete;
+ Status& operator=(const Status&) = delete;
+ Status(Status&&) = default;
+ Status& operator=(Status&&) = default;
+
+ /** @brief Constructs the Status object and
+ * the underlying device object
+ *
+ * @param[in] bus - DBus bus to attach to
+ * @param[in] event - sd_event unique pointer reference
+ * @param[in] path - DBus object path
+ * @param[in] manager - OCC manager instance
+ * @param[in] callBack - Callback handler to invoke during
+ * property change
+ */
+ Status(sdbusplus::bus::bus& bus, EventPtr& event, const char* path,
+ const Manager& manager,
+ std::function<void(bool)> callBack = nullptr) :
+ Interface(bus, path, true),
+ bus(bus), path(path), callBack(callBack),
+ instance(((this->path.back() - '0'))),
+ device(event,
#ifdef I2C_OCC
- i2c_occ::getI2cDeviceName(path),
+ i2c_occ::getI2cDeviceName(path),
#else
- sysfsName + "." + std::to_string(instance + 1),
+ sysfsName + "." + std::to_string(instance + 1),
#endif
- manager,
- *this,
- std::bind(std::mem_fn(&Status::deviceErrorHandler), this,
- std::placeholders::_1)),
- hostControlSignal(
- bus,
- sdbusRule::type::signal() +
- sdbusRule::member("CommandComplete") +
- sdbusRule::path("/org/open_power/control/host0") +
- sdbusRule::interface("org.open_power.Control.Host") +
- sdbusRule::argN(0, Control::convertForMessage(
- Control::Host::Command::OCCReset)),
- std::bind(std::mem_fn(&Status::hostControlEvent),
- this, std::placeholders::_1))
- {
- // Check to see if we have OCC already bound. If so, just set it
- if (device.bound())
- {
- this->occActive(true);
- }
-
- // Announce that we are ready
- this->emit_object_added();
- }
-
- /** @brief Since we are overriding the setter-occActive but not the
- * getter-occActive, we need to have this using in order to
- * allow passthrough usage of the getter-occActive
- */
- using Base::Status::occActive;
-
- /** @brief SET OccActive to True or False
- *
- * @param[in] value - Intended value
- *
- * @return - Updated value of the property
- */
- bool occActive(bool value) override;
-
- /** @brief Starts OCC error detection */
- inline void addErrorWatch()
- {
- return device.addErrorWatch();
- }
-
- /** @brief Stops OCC error detection */
- inline void removeErrorWatch()
- {
- return device.removeErrorWatch();
- }
-
- /** @brief Starts to watch how many OCCs are present on the master */
- inline void addPresenceWatchMaster()
+ manager, *this,
+ std::bind(std::mem_fn(&Status::deviceErrorHandler), this,
+ std::placeholders::_1)),
+ hostControlSignal(
+ bus,
+ sdbusRule::type::signal() + sdbusRule::member("CommandComplete") +
+ sdbusRule::path("/org/open_power/control/host0") +
+ sdbusRule::interface("org.open_power.Control.Host") +
+ sdbusRule::argN(0, Control::convertForMessage(
+ Control::Host::Command::OCCReset)),
+ std::bind(std::mem_fn(&Status::hostControlEvent), this,
+ std::placeholders::_1))
+ {
+ // Check to see if we have OCC already bound. If so, just set it
+ if (device.bound())
{
- return device.addPresenceWatchMaster();
+ this->occActive(true);
}
- private:
-
- /** @brief sdbus handle */
- sdbusplus::bus::bus& bus;
-
- /** @brief OCC dbus object path */
- std::string path;
-
- /** @brief Callback handler to be invoked during property change.
- * This is a handler in Manager class
- */
- std::function<void(bool)> callBack;
-
- /** @brief OCC instance number. Ex, 0,1, etc */
- int instance;
-
- /** @brief OCC instance to Sensor ID mapping */
- static const std::map<instanceID, sensorID> sensorMap;
-
- /** @brief OCC device object to do bind and unbind */
- Device device;
-
- /** @brief Subscribe to host control signal
- *
- * Once the OCC reset is requested, BMC sends that message to host.
- * If the host does not ack the message, then there would be a timeout
- * and we need to catch that to log an error
- **/
- sdbusplus::bus::match_t hostControlSignal;
-
- /** @brief Callback handler when device errors are detected
- *
- * @param[in] error - True if an error is reported, false otherwise
- */
- void deviceErrorHandler(bool error);
-
- /** @brief Callback function on host control signals
- *
- * @param[in] msg - Data associated with subscribed signal
- */
- void hostControlEvent(sdbusplus::message::message& msg);
-
- /** @brief Sends a message to host control command handler to reset OCC
- */
- void resetOCC();
+ // Announce that we are ready
+ this->emit_object_added();
+ }
+
+ /** @brief Since we are overriding the setter-occActive but not the
+ * getter-occActive, we need to have this using in order to
+ * allow passthrough usage of the getter-occActive
+ */
+ using Base::Status::occActive;
+
+ /** @brief SET OccActive to True or False
+ *
+ * @param[in] value - Intended value
+ *
+ * @return - Updated value of the property
+ */
+ bool occActive(bool value) override;
+
+ /** @brief Starts OCC error detection */
+ inline void addErrorWatch()
+ {
+ return device.addErrorWatch();
+ }
+
+ /** @brief Stops OCC error detection */
+ inline void removeErrorWatch()
+ {
+ return device.removeErrorWatch();
+ }
+
+ /** @brief Starts to watch how many OCCs are present on the master */
+ inline void addPresenceWatchMaster()
+ {
+ return device.addPresenceWatchMaster();
+ }
+
+ private:
+ /** @brief sdbus handle */
+ sdbusplus::bus::bus& bus;
+
+ /** @brief OCC dbus object path */
+ std::string path;
+
+ /** @brief Callback handler to be invoked during property change.
+ * This is a handler in Manager class
+ */
+ std::function<void(bool)> callBack;
+
+ /** @brief OCC instance number. Ex, 0,1, etc */
+ int instance;
+
+ /** @brief OCC instance to Sensor ID mapping */
+ static const std::map<instanceID, sensorID> sensorMap;
+
+ /** @brief OCC device object to do bind and unbind */
+ Device device;
+
+ /** @brief Subscribe to host control signal
+ *
+ * Once the OCC reset is requested, BMC sends that message to host.
+ * If the host does not ack the message, then there would be a timeout
+ * and we need to catch that to log an error
+ **/
+ sdbusplus::bus::match_t hostControlSignal;
+
+ /** @brief Callback handler when device errors are detected
+ *
+ * @param[in] error - True if an error is reported, false otherwise
+ */
+ void deviceErrorHandler(bool error);
+
+ /** @brief Callback function on host control signals
+ *
+ * @param[in] msg - Data associated with subscribed signal
+ */
+ void hostControlEvent(sdbusplus::message::message& msg);
+
+ /** @brief Sends a message to host control command handler to reset OCC
+ */
+ void resetOCC();
};
} // namespace occ
diff --git a/powercap.cpp b/powercap.cpp
index 4c0c330..bc4d3ca 100644
--- a/powercap.cpp
+++ b/powercap.cpp
@@ -1,5 +1,5 @@
-#include <powercap.hpp>
#include <phosphor-logging/log.hpp>
+#include <powercap.hpp>
namespace open_power
{
@@ -8,7 +8,7 @@ namespace occ
namespace powercap
{
-constexpr auto PCAP_PATH = "/xyz/openbmc_project/control/host0/power_cap";
+constexpr auto PCAP_PATH = "/xyz/openbmc_project/control/host0/power_cap";
constexpr auto PCAP_INTERFACE = "xyz.openbmc_project.Control.Power.Cap";
constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
@@ -20,21 +20,17 @@ constexpr auto POWER_CAP_ENABLE_PROP = "PowerCapEnable";
using namespace phosphor::logging;
-std::string PowerCap::getService(std::string path,
- std::string interface)
+std::string PowerCap::getService(std::string path, std::string interface)
{
- auto mapper = bus.new_method_call(MAPPER_BUSNAME,
- MAPPER_PATH,
- MAPPER_INTERFACE,
- "GetObject");
+ auto mapper = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
+ MAPPER_INTERFACE, "GetObject");
mapper.append(path, std::vector<std::string>({interface}));
auto mapperResponseMsg = bus.call(mapper);
if (mapperResponseMsg.is_method_error())
{
- log<level::ERR>("Error in mapper call",
- entry("PATH=%s", path.c_str()),
+ log<level::ERR>("Error in mapper call", entry("PATH=%s", path.c_str()),
entry("INTERFACE=%s", interface.c_str()));
// TODO openbmc/openbmc#851 - Once available, throw returned error
throw std::runtime_error("Error in mapper call");
@@ -64,17 +60,16 @@ uint32_t PowerCap::getOccInput(uint32_t pcap, bool pcapEnabled)
// If pcap is not disabled then just return the pcap with the derating
// factor applied.
- return( (static_cast<uint64_t>(pcap) * PS_DERATING_FACTOR) /100);
+ return ((static_cast<uint64_t>(pcap) * PS_DERATING_FACTOR) / 100);
}
uint32_t PowerCap::getPcap()
{
- auto settingService = getService(PCAP_PATH,PCAP_INTERFACE);
+ auto settingService = getService(PCAP_PATH, PCAP_INTERFACE);
- auto method = this->bus.new_method_call(settingService.c_str(),
- PCAP_PATH,
- "org.freedesktop.DBus.Properties",
- "Get");
+ auto method =
+ this->bus.new_method_call(settingService.c_str(), PCAP_PATH,
+ "org.freedesktop.DBus.Properties", "Get");
method.append(PCAP_INTERFACE, POWER_CAP_PROP);
auto reply = this->bus.call(method);
@@ -92,12 +87,11 @@ uint32_t PowerCap::getPcap()
bool PowerCap::getPcapEnabled()
{
- auto settingService = getService(PCAP_PATH,PCAP_INTERFACE);
+ auto settingService = getService(PCAP_PATH, PCAP_INTERFACE);
- auto method = this->bus.new_method_call(settingService.c_str(),
- PCAP_PATH,
- "org.freedesktop.DBus.Properties",
- "Get");
+ auto method =
+ this->bus.new_method_call(settingService.c_str(), PCAP_PATH,
+ "org.freedesktop.DBus.Properties", "Get");
method.append(PCAP_INTERFACE, POWER_CAP_ENABLE_PROP);
auto reply = this->bus.call(method);
@@ -117,7 +111,7 @@ void PowerCap::writeOcc(uint32_t pcapValue)
{
// Create path out to master occ hwmon entry
std::unique_ptr<fs::path> fileName =
- std::make_unique<fs::path>(OCC_HWMON_PATH);
+ std::make_unique<fs::path>(OCC_HWMON_PATH);
*fileName /= occMasterName;
*fileName /= "/hwmon/";
@@ -129,11 +123,11 @@ void PowerCap::writeOcc(uint32_t pcapValue)
// Append on the hwmon string where we write the user power cap
*fileName /= "/caps1_user";
- auto pcapString {std::to_string(pcapValue)};
+ auto pcapString{std::to_string(pcapValue)};
log<level::INFO>("Writing pcap value to hwmon",
- entry("PCAP_PATH=%s",fileName->c_str()),
- entry("PCAP_VALUE=%s",pcapString.c_str()));
+ entry("PCAP_PATH=%s", fileName->c_str()),
+ entry("PCAP_VALUE=%s", pcapString.c_str()));
// Open the hwmon file and write the power cap
std::ofstream file(*fileName, std::ios::out);
file << pcapString;
@@ -160,8 +154,8 @@ void PowerCap::pcapChanged(sdbusplus::message::message& msg)
auto valPropMap = msgData.find(POWER_CAP_PROP);
if (valPropMap != msgData.end())
{
- pcap = sdbusplus::message::variant_ns::get<uint32_t>(
- valPropMap->second);
+ pcap =
+ sdbusplus::message::variant_ns::get<uint32_t>(valPropMap->second);
pcapEnabled = getPcapEnabled();
}
else
@@ -169,8 +163,8 @@ void PowerCap::pcapChanged(sdbusplus::message::message& msg)
valPropMap = msgData.find(POWER_CAP_ENABLE_PROP);
if (valPropMap != msgData.end())
{
- pcapEnabled = sdbusplus::message::variant_ns::get<bool>(
- valPropMap->second);
+ pcapEnabled =
+ sdbusplus::message::variant_ns::get<bool>(valPropMap->second);
pcap = getPcap();
}
else
@@ -180,9 +174,8 @@ void PowerCap::pcapChanged(sdbusplus::message::message& msg)
}
}
- log<level::INFO>("Power Cap Property Change",
- entry("PCAP=%u",pcap),
- entry("PCAP_ENABLED=%u",pcapEnabled));
+ log<level::INFO>("Power Cap Property Change", entry("PCAP=%u", pcap),
+ entry("PCAP_ENABLED=%u", pcapEnabled));
// Determine desired action to write to occ
@@ -194,8 +187,8 @@ void PowerCap::pcapChanged(sdbusplus::message::message& msg)
return;
}
-} // namespace open_power
+} // namespace powercap
} // namespace occ
-}// namespace powercap
+} // namespace open_power
diff --git a/powercap.hpp b/powercap.hpp
index 6a5f0d1..b28be8c 100644
--- a/powercap.hpp
+++ b/powercap.hpp
@@ -1,9 +1,11 @@
#pragma once
+#include "config.h"
+
+#include "occ_status.hpp"
+
#include <sdbusplus/bus.hpp>
#include <sdbusplus/bus/match.hpp>
-#include "occ_status.hpp"
-#include "config.h"
namespace open_power
{
@@ -24,7 +26,7 @@ namespace sdbusRule = sdbusplus::bus::match::rules;
class PowerCap
{
-public:
+ public:
/** @brief PowerCap object to inform occ of changes to cap
*
* This object will monitor for changes to the power cap setting and
@@ -34,22 +36,19 @@ public:
* @param[in] bus - The Dbus bus object
* @param[in] occStatus - The occ status object
*/
- PowerCap(sdbusplus::bus::bus &bus,
- Status &occStatus,
+ PowerCap(sdbusplus::bus::bus& bus, Status& occStatus,
const std::string& occMasterName = OCC_MASTER_NAME) :
bus(bus),
- occMasterName(occMasterName),
- occStatus(occStatus),
+ occMasterName(occMasterName), occStatus(occStatus),
pcapMatch(
- bus,
- sdbusRule::member("PropertiesChanged") +
+ bus,
+ sdbusRule::member("PropertiesChanged") +
sdbusRule::path(
"/xyz/openbmc_project/control/host0/power_cap") +
sdbusRule::argN(0, "xyz.openbmc_project.Control.Power.Cap") +
sdbusRule::interface("org.freedesktop.DBus.Properties"),
- std::bind(std::mem_fn(&PowerCap::pcapChanged),
- this, std::placeholders::_1))
- {};
+ std::bind(std::mem_fn(&PowerCap::pcapChanged), this,
+ std::placeholders::_1)){};
/** @brief Return the appropriate value to write to the OCC
*
@@ -60,8 +59,7 @@ public:
*/
uint32_t getOccInput(uint32_t pcap, bool pcapEnabled);
-private:
-
+ private:
/** @brief Callback for pcap setting changes
*
* Process change and inform OCC
@@ -78,8 +76,7 @@ private:
*
* @return Distinct service name for input path/interface
*/
- std::string getService(std::string path,
- std::string interface);
+ std::string getService(std::string path, std::string interface);
/** @brief Get the power cap property
*
@@ -106,15 +103,14 @@ private:
std::string occMasterName;
/* @brief OCC Status object */
- Status &occStatus;
+ Status& occStatus;
/** @brief Used to subscribe to dbus pcap property changes **/
sdbusplus::bus::match_t pcapMatch;
+};
- };
-
-} // namespace open_power
+} // namespace powercap
} // namespace occ
-}// namespace powercap
+} // namespace open_power
diff --git a/test/TestI2cOcc.cpp b/test/TestI2cOcc.cpp
index bf976d7..92028fd 100644
--- a/test/TestI2cOcc.cpp
+++ b/test/TestI2cOcc.cpp
@@ -1,9 +1,10 @@
+#include "i2c_occ.hpp"
+
#include <experimental/filesystem>
#include <fstream>
-#include <gtest/gtest.h>
#include <string>
-#include "i2c_occ.hpp"
+#include <gtest/gtest.h>
#ifdef I2C_OCC
namespace i2c_occ
@@ -33,10 +34,9 @@ const auto P8_OCC_HWMON = "p8-occ-hwmon";
const auto OTHER_STRING = "SomeOtherString123"s;
-
class TestUtilGetOccHwmonDevices : public testing::Test
{
-public:
+ public:
TestUtilGetOccHwmonDevices()
{
// Prepare env for test case
@@ -171,4 +171,3 @@ TEST(TestI2cDbusNames, getI2cDeviceName)
} // namespace i2c_occ
#endif // I2C_OCC
-
diff --git a/test/utest.cpp b/test/utest.cpp
index dc80cc2..eb9ca0b 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -1,43 +1,45 @@
-#include <gtest/gtest.h>
+#include "powercap.hpp"
+
#include <occ_events.hpp>
#include <occ_manager.hpp>
-#include "powercap.hpp"
+
+#include <gtest/gtest.h>
using namespace open_power::occ;
class VerifyOccInput : public ::testing::Test
{
- public:
- VerifyOccInput() :
- bus(sdbusplus::bus::new_default()),
- rc(sd_event_default(&event)),
- eventP(event),
- manager(bus, eventP),
- occStatus(bus, eventP, "/test/path/occ1", manager),
- pcap(bus,occStatus)
- {
- EXPECT_GE(rc, 0);
- event = nullptr;
- }
- ~VerifyOccInput()
- {}
-
- sdbusplus::bus::bus bus;
- sd_event* event;
- int rc;
- open_power::occ::EventPtr eventP;
-
- Manager manager;
- Status occStatus;
- powercap::PowerCap pcap;
+ public:
+ VerifyOccInput() :
+ bus(sdbusplus::bus::new_default()), rc(sd_event_default(&event)),
+ eventP(event), manager(bus, eventP),
+ occStatus(bus, eventP, "/test/path/occ1", manager), pcap(bus, occStatus)
+ {
+ EXPECT_GE(rc, 0);
+ event = nullptr;
+ }
+ ~VerifyOccInput()
+ {
+ }
+
+ sdbusplus::bus::bus bus;
+ sd_event* event;
+ int rc;
+ open_power::occ::EventPtr eventP;
+
+ Manager manager;
+ Status occStatus;
+ powercap::PowerCap pcap;
};
-TEST_F(VerifyOccInput, PcapDisabled) {
- uint32_t occInput = pcap.getOccInput(100,false);
+TEST_F(VerifyOccInput, PcapDisabled)
+{
+ uint32_t occInput = pcap.getOccInput(100, false);
EXPECT_EQ(occInput, 0);
}
-TEST_F(VerifyOccInput, PcapEnabled) {
- uint32_t occInput = pcap.getOccInput(100,true);
+TEST_F(VerifyOccInput, PcapEnabled)
+{
+ uint32_t occInput = pcap.getOccInput(100, true);
EXPECT_EQ(occInput, 90);
}
diff --git a/utils.cpp b/utils.cpp
index d9a98ee..c68913d 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -1,6 +1,6 @@
-#include <string>
-#include <sdbusplus/bus.hpp>
#include <phosphor-logging/elog-errors.hpp>
+#include <sdbusplus/bus.hpp>
+#include <string>
#include <xyz/openbmc_project/Common/error.hpp>
namespace open_power
{
@@ -9,17 +9,16 @@ namespace occ
// For throwing exceptions
using namespace phosphor::logging;
-using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
- Error::InternalFailure;
+using InternalFailure =
+ sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
-std::string getService(sdbusplus::bus::bus& bus,
- const std::string& path,
+std::string getService(sdbusplus::bus::bus& bus, const std::string& path,
const std::string& intf)
{
- auto mapperCall = bus.new_method_call("xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper",
- "GetObject");
+ auto mapperCall =
+ bus.new_method_call("xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetObject");
mapperCall.append(path);
mapperCall.append(std::vector<std::string>({intf}));
@@ -29,8 +28,8 @@ std::string getService(sdbusplus::bus::bus& bus,
if (mapperResponseMsg.is_method_error())
{
log<level::ERR>("ERROR in getting service",
- entry("PATH=%s",path.c_str()),
- entry("INTERFACE=%s",intf.c_str()));
+ entry("PATH=%s", path.c_str()),
+ entry("INTERFACE=%s", intf.c_str()));
elog<InternalFailure>();
}
@@ -41,8 +40,8 @@ std::string getService(sdbusplus::bus::bus& bus,
if (mapperResponse.begin() == mapperResponse.end())
{
log<level::ERR>("ERROR reading mapper response",
- entry("PATH=%s",path.c_str()),
- entry("INTERFACE=%s",intf.c_str()));
+ entry("PATH=%s", path.c_str()),
+ entry("INTERFACE=%s", intf.c_str()));
elog<InternalFailure>();
}
diff --git a/utils.hpp b/utils.hpp
index 33088df..7c8b871 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -16,8 +16,7 @@ namespace occ
* @return Service name
* @error InternalFailure exception thrown
*/
-std::string getService(sdbusplus::bus::bus& bus,
- const std::string& path,
+std::string getService(sdbusplus::bus::bus& bus, const std::string& path,
const std::string& intf);
} // namespace occ
} // namespace open_power
OpenPOWER on IntegriCloud