Start using .clang-format
Used the one from docs/style/cpp.
Change-Id: I3bdc2b353bf18a437266b362d8205b8463a9ce2b
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
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/argument.hpp b/argument.hpp
index cae4a64..b6681d9 100644
--- a/argument.hpp
+++ b/argument.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <getopt.h>
+
#include <map>
#include <string>
@@ -14,52 +15,52 @@
*/
class ArgumentParser
{
- public:
- ArgumentParser() = delete;
- ~ArgumentParser() = default;
- ArgumentParser(const ArgumentParser&) = delete;
- ArgumentParser& operator=(const ArgumentParser&) = delete;
- ArgumentParser(ArgumentParser&&) = default;
- ArgumentParser& operator=(ArgumentParser&&) = default;
+ public:
+ ArgumentParser() = delete;
+ ~ArgumentParser() = default;
+ ArgumentParser(const ArgumentParser&) = delete;
+ ArgumentParser& operator=(const ArgumentParser&) = delete;
+ ArgumentParser(ArgumentParser&&) = default;
+ ArgumentParser& operator=(ArgumentParser&&) = default;
- /** @brief Constructs Argument object
- *
- * @param[in] argc - the main function's argc passed as is
- * @param[in] argv - the main function's argv passed as is
- * @return Object constructed
- */
- ArgumentParser(int argc, char** argv);
+ /** @brief Constructs Argument object
+ *
+ * @param[in] argc - the main function's argc passed as is
+ * @param[in] argv - the main function's argv passed as is
+ * @return Object constructed
+ */
+ ArgumentParser(int argc, char** argv);
- /** @brief Given an option, returns its argument(optarg)
- *
- * @param[in] opt - command line option string
- *
- * @return argument which is a standard optarg
- */
- const std::string& operator[](const std::string& opt);
+ /** @brief Given an option, returns its argument(optarg)
+ *
+ * @param[in] opt - command line option string
+ *
+ * @return argument which is a standard optarg
+ */
+ const std::string& operator[](const std::string& opt);
- /** @brief Displays usage
- *
- * @param[in] argv - the main function's argv passed as is
- */
- static void usage(char** argv);
+ /** @brief Displays usage
+ *
+ * @param[in] argv - the main function's argv passed as is
+ */
+ static void usage(char** argv);
- /** @brief Set to 'true' when an option is passed */
- static const std::string trueString;
+ /** @brief Set to 'true' when an option is passed */
+ static const std::string trueString;
- /** @brief Set to '' when an option is not passed */
- static const std::string emptyString;
+ /** @brief Set to '' when an option is not passed */
+ static const std::string emptyString;
- private:
- /** @brief Option to argument mapping */
- std::map<const std::string, std::string> arguments;
+ private:
+ /** @brief Option to argument mapping */
+ std::map<const std::string, std::string> arguments;
- /** @brief Array of struct options as needed by getopt_long */
- static const option options[];
+ /** @brief Array of struct options as needed by getopt_long */
+ static const option options[];
- /** @brief optstring as needed by getopt_long */
- static const char* optionStr;
+ /** @brief optstring as needed by getopt_long */
+ static const char* optionStr;
};
-}
-}
+} // namespace power
+} // namespace witherspoon
diff --git a/device.hpp b/device.hpp
index 59cb914..2513506 100644
--- a/device.hpp
+++ b/device.hpp
@@ -16,74 +16,70 @@
*/
class Device
{
- public:
+ public:
+ Device() = delete;
+ virtual ~Device() = default;
+ Device(const Device&) = delete;
+ Device& operator=(const Device&) = delete;
+ Device(Device&&) = default;
+ Device& operator=(Device&&) = default;
- Device() = delete;
- virtual ~Device() = default;
- Device(const Device&) = delete;
- Device& operator=(const Device&) = delete;
- Device(Device&&) = default;
- Device& operator=(Device&&) = default;
+ /**
+ * Constructor
+ *
+ * @param name - the device name
+ * @param inst - the device instance
+ */
+ Device(const std::string& name, size_t inst) : name(name), instance(inst)
+ {
+ }
- /**
- * Constructor
- *
- * @param name - the device name
- * @param inst - the device instance
- */
- Device(const std::string& name, size_t inst) :
- name(name),
- instance(inst)
- {
- }
+ /**
+ * Returns the instance number
+ */
+ inline auto getInstance() const
+ {
+ return instance;
+ }
- /**
- * Returns the instance number
- */
- inline auto getInstance() const
- {
- return instance;
- }
+ /**
+ * Returns the name
+ */
+ inline auto getName() const
+ {
+ return name;
+ }
- /**
- * Returns the name
- */
- inline auto getName() const
- {
- return name;
- }
+ /**
+ * Pure virtual function to analyze an error
+ */
+ virtual void analyze() = 0;
- /**
- * Pure virtual function to analyze an error
- */
- virtual void analyze() = 0;
+ /**
+ * Stubbed virtual function to call when it's known
+ * the chip is in error state. Override if functionality
+ * is required
+ */
+ virtual void onFailure()
+ {
+ }
- /**
- * Stubbed virtual function to call when it's known
- * the chip is in error state. Override if functionality
- * is required
- */
- virtual void onFailure()
- {
- }
+ /**
+ * Pure virtual function to clear faults on the device
+ */
+ virtual void clearFaults() = 0;
- /**
- * Pure virtual function to clear faults on the device
- */
- virtual void clearFaults() = 0;
+ private:
+ /**
+ * the device name
+ */
+ const std::string name;
- private:
-
- /**
- * the device name
- */
- const std::string name;
-
- /**
- * the device instance number
- */
- const size_t instance;
+ /**
+ * the device instance number
+ */
+ const size_t instance;
};
-}
-}
+} // namespace power
+} // namespace witherspoon
diff --git a/device_monitor.hpp b/device_monitor.hpp
index 3bde1b5..191c2bc 100644
--- a/device_monitor.hpp
+++ b/device_monitor.hpp
@@ -1,11 +1,12 @@
#pragma once
+#include "device.hpp"
+
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server.hpp>
#include <sdeventplus/clock.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/utility/timer.hpp>
-#include "device.hpp"
namespace witherspoon
{
@@ -23,62 +24,59 @@
*/
class DeviceMonitor
{
- public:
+ public:
+ DeviceMonitor() = delete;
+ ~DeviceMonitor() = default;
+ DeviceMonitor(const DeviceMonitor&) = delete;
+ DeviceMonitor& operator=(const DeviceMonitor&) = delete;
+ DeviceMonitor(DeviceMonitor&&) = delete;
+ DeviceMonitor& operator=(DeviceMonitor&&) = delete;
- DeviceMonitor() = delete;
- ~DeviceMonitor() = default;
- DeviceMonitor(const DeviceMonitor&) = delete;
- DeviceMonitor& operator=(const DeviceMonitor&) = delete;
- DeviceMonitor(DeviceMonitor&&) = delete;
- DeviceMonitor& operator=(DeviceMonitor&&) = delete;
+ /**
+ * Constructor
+ *
+ * @param[in] d - device to monitor
+ * @param[in] e - event object
+ * @param[in] i - polling interval in ms
+ */
+ DeviceMonitor(std::unique_ptr<Device>&& d, const sdeventplus::Event& e,
+ std::chrono::milliseconds i) :
+ device(std::move(d)),
+ timer(e, std::bind(&DeviceMonitor::analyze, this), i)
+ {
+ }
- /**
- * Constructor
- *
- * @param[in] d - device to monitor
- * @param[in] e - event object
- * @param[in] i - polling interval in ms
- */
- DeviceMonitor(std::unique_ptr<Device>&& d,
- const sdeventplus::Event& e,
- std::chrono::milliseconds i) :
- device(std::move(d)),
- timer(e, std::bind(&DeviceMonitor::analyze, this), i)
- {
- }
+ /**
+ * Starts the timer to monitor the device on an interval.
+ */
+ virtual int run()
+ {
+ return timer.get_event().loop();
+ }
- /**
- * Starts the timer to monitor the device on an interval.
- */
- virtual int run()
- {
- return timer.get_event().loop();
- }
+ protected:
+ /**
+ * Analyzes the device for faults
+ *
+ * Runs in the timer callback
+ *
+ * Override if desired
+ */
+ virtual void analyze()
+ {
+ device->analyze();
+ }
- protected:
+ /**
+ * The device to run the analysis on
+ */
+ std::unique_ptr<Device> device;
- /**
- * Analyzes the device for faults
- *
- * Runs in the timer callback
- *
- * Override if desired
- */
- virtual void analyze()
- {
- device->analyze();
- }
-
- /**
- * The device to run the analysis on
- */
- std::unique_ptr<Device> device;
-
- /**
- * The timer that runs fault check polls.
- */
- sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> timer;
+ /**
+ * The timer that runs fault check polls.
+ */
+ sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> timer;
};
-}
-}
+} // namespace power
+} // namespace witherspoon
diff --git a/elog-errors.hpp b/elog-errors.hpp
index 150875a..f4d45f8 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
{
@@ -21,7 +21,7 @@
{
namespace Error
{
- struct PowerSequencerPGOODFault;
+struct PowerSequencerPGOODFault;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -41,7 +41,7 @@
{
namespace Error
{
- struct GPIO;
+struct GPIO;
} // namespace Error
} // namespace Callout
} // namespace Common
@@ -61,7 +61,7 @@
{
namespace Error
{
- struct PowerOnFailure;
+struct PowerOnFailure;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -81,7 +81,7 @@
{
namespace Error
{
- struct PowerSupplyInputFault;
+struct PowerSupplyInputFault;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -101,7 +101,7 @@
{
namespace Error
{
- struct IIC;
+struct IIC;
} // namespace Error
} // namespace Callout
} // namespace Common
@@ -121,7 +121,7 @@
{
namespace Error
{
- struct GPUPowerFault;
+struct GPUPowerFault;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -141,7 +141,7 @@
{
namespace Error
{
- struct Shutdown;
+struct Shutdown;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -161,7 +161,7 @@
{
namespace Error
{
- struct Inventory;
+struct Inventory;
} // namespace Error
} // namespace Callout
} // namespace Common
@@ -181,7 +181,7 @@
{
namespace Error
{
- struct Device;
+struct Device;
} // namespace Error
} // namespace Callout
} // namespace Common
@@ -201,7 +201,7 @@
{
namespace Error
{
- struct PowerSequencerFault;
+struct PowerSequencerFault;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -221,7 +221,7 @@
{
namespace Error
{
- struct PowerSupplyOutputOvercurrent;
+struct PowerSupplyOutputOvercurrent;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -241,7 +241,7 @@
{
namespace Error
{
- struct PowerSupplyOutputOvervoltage;
+struct PowerSupplyOutputOvervoltage;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -261,7 +261,7 @@
{
namespace Error
{
- struct PowerSupplyFanFault;
+struct PowerSupplyFanFault;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -281,7 +281,7 @@
{
namespace Error
{
- struct PowerSequencerVoltageFault;
+struct PowerSequencerVoltageFault;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -301,7 +301,7 @@
{
namespace Error
{
- struct IPMISensor;
+struct IPMISensor;
} // namespace Error
} // namespace Callout
} // namespace Common
@@ -321,7 +321,7 @@
{
namespace Error
{
- struct PowerSupplyTemperatureFault;
+struct PowerSupplyTemperatureFault;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -341,7 +341,7 @@
{
namespace Error
{
- struct PowerSupplyShouldBeOn;
+struct PowerSupplyShouldBeOn;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -361,7 +361,7 @@
{
namespace Error
{
- struct GPUOverTemp;
+struct GPUOverTemp;
} // namespace Error
} // namespace Fault
} // namespace Witherspoon
@@ -369,7 +369,6 @@
} // namespace org
} // namespace sdbusplus
-
namespace phosphor
{
@@ -391,20 +390,21 @@
{
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
{
@@ -412,7 +412,6 @@
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
@@ -420,17 +419,17 @@
} // 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
{
@@ -447,21 +446,23 @@
{
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
@@ -469,17 +470,17 @@
} // 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
{
@@ -496,30 +497,32 @@
{
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
@@ -527,17 +530,17 @@
} // 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
{
@@ -554,19 +557,19 @@
{
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
@@ -574,17 +577,17 @@
} // 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
{
@@ -601,19 +604,19 @@
{
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
@@ -621,17 +624,17 @@
} // 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 org
{
@@ -648,20 +651,20 @@
{
static constexpr auto str = "RAW_STATUS=%s";
static constexpr auto str_short = "RAW_STATUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _PowerSupplyInputFault
+} // namespace _PowerSupplyInputFault
struct PowerSupplyInputFault
{
static constexpr auto L = level::ERR;
using RAW_STATUS = _PowerSupplyInputFault::RAW_STATUS;
- using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::Inventory::CALLOUT_INVENTORY_PATH;
+ using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::
+ Inventory::CALLOUT_INVENTORY_PATH;
using metadata_types = std::tuple<RAW_STATUS, CALLOUT_INVENTORY_PATH>;
-
};
} // namespace Fault
@@ -669,17 +672,17 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerSupplyInputFault>
+struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::
+ Error::PowerSupplyInputFault>
{
using type = org::open_power::Witherspoon::Fault::PowerSupplyInputFault;
};
-}
+} // namespace details
namespace org
{
@@ -696,20 +699,20 @@
{
static constexpr auto str = "RAW_STATUS=%s";
static constexpr auto str_short = "RAW_STATUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _PowerSupplyShouldBeOn
+} // namespace _PowerSupplyShouldBeOn
struct PowerSupplyShouldBeOn
{
static constexpr auto L = level::ERR;
using RAW_STATUS = _PowerSupplyShouldBeOn::RAW_STATUS;
- using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::Inventory::CALLOUT_INVENTORY_PATH;
+ using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::
+ Inventory::CALLOUT_INVENTORY_PATH;
using metadata_types = std::tuple<RAW_STATUS, CALLOUT_INVENTORY_PATH>;
-
};
} // namespace Fault
@@ -717,17 +720,17 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerSupplyShouldBeOn>
+struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::
+ Error::PowerSupplyShouldBeOn>
{
using type = org::open_power::Witherspoon::Fault::PowerSupplyShouldBeOn;
};
-}
+} // namespace details
namespace org
{
@@ -744,20 +747,20 @@
{
static constexpr auto str = "RAW_STATUS=%s";
static constexpr auto str_short = "RAW_STATUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _PowerSupplyOutputOvercurrent
+} // namespace _PowerSupplyOutputOvercurrent
struct PowerSupplyOutputOvercurrent
{
static constexpr auto L = level::ERR;
using RAW_STATUS = _PowerSupplyOutputOvercurrent::RAW_STATUS;
- using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::Inventory::CALLOUT_INVENTORY_PATH;
+ using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::
+ Inventory::CALLOUT_INVENTORY_PATH;
using metadata_types = std::tuple<RAW_STATUS, CALLOUT_INVENTORY_PATH>;
-
};
} // namespace Fault
@@ -765,17 +768,18 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerSupplyOutputOvercurrent>
+struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::
+ Error::PowerSupplyOutputOvercurrent>
{
- using type = org::open_power::Witherspoon::Fault::PowerSupplyOutputOvercurrent;
+ using type =
+ org::open_power::Witherspoon::Fault::PowerSupplyOutputOvercurrent;
};
-}
+} // namespace details
namespace org
{
@@ -792,20 +796,20 @@
{
static constexpr auto str = "RAW_STATUS=%s";
static constexpr auto str_short = "RAW_STATUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _PowerSupplyOutputOvervoltage
+} // namespace _PowerSupplyOutputOvervoltage
struct PowerSupplyOutputOvervoltage
{
static constexpr auto L = level::ERR;
using RAW_STATUS = _PowerSupplyOutputOvervoltage::RAW_STATUS;
- using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::Inventory::CALLOUT_INVENTORY_PATH;
+ using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::
+ Inventory::CALLOUT_INVENTORY_PATH;
using metadata_types = std::tuple<RAW_STATUS, CALLOUT_INVENTORY_PATH>;
-
};
} // namespace Fault
@@ -813,17 +817,18 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerSupplyOutputOvervoltage>
+struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::
+ Error::PowerSupplyOutputOvervoltage>
{
- using type = org::open_power::Witherspoon::Fault::PowerSupplyOutputOvervoltage;
+ using type =
+ org::open_power::Witherspoon::Fault::PowerSupplyOutputOvervoltage;
};
-}
+} // namespace details
namespace org
{
@@ -840,20 +845,20 @@
{
static constexpr auto str = "RAW_STATUS=%s";
static constexpr auto str_short = "RAW_STATUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _PowerSupplyFanFault
+} // namespace _PowerSupplyFanFault
struct PowerSupplyFanFault
{
static constexpr auto L = level::ERR;
using RAW_STATUS = _PowerSupplyFanFault::RAW_STATUS;
- using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::Inventory::CALLOUT_INVENTORY_PATH;
+ using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::
+ Inventory::CALLOUT_INVENTORY_PATH;
using metadata_types = std::tuple<RAW_STATUS, CALLOUT_INVENTORY_PATH>;
-
};
} // namespace Fault
@@ -861,17 +866,17 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerSupplyFanFault>
+struct map_exception_type<
+ sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerSupplyFanFault>
{
using type = org::open_power::Witherspoon::Fault::PowerSupplyFanFault;
};
-}
+} // namespace details
namespace org
{
@@ -888,20 +893,20 @@
{
static constexpr auto str = "RAW_STATUS=%s";
static constexpr auto str_short = "RAW_STATUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _PowerSupplyTemperatureFault
+} // namespace _PowerSupplyTemperatureFault
struct PowerSupplyTemperatureFault
{
static constexpr auto L = level::ERR;
using RAW_STATUS = _PowerSupplyTemperatureFault::RAW_STATUS;
- using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::Inventory::CALLOUT_INVENTORY_PATH;
+ using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::
+ Inventory::CALLOUT_INVENTORY_PATH;
using metadata_types = std::tuple<RAW_STATUS, CALLOUT_INVENTORY_PATH>;
-
};
} // namespace Fault
@@ -909,17 +914,18 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerSupplyTemperatureFault>
+struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::
+ Error::PowerSupplyTemperatureFault>
{
- using type = org::open_power::Witherspoon::Fault::PowerSupplyTemperatureFault;
+ using type =
+ org::open_power::Witherspoon::Fault::PowerSupplyTemperatureFault;
};
-}
+} // namespace details
namespace org
{
@@ -932,14 +938,12 @@
namespace _Shutdown
{
-
-} // namespace _Shutdown
+} // namespace _Shutdown
struct Shutdown
{
static constexpr auto L = level::ERR;
using metadata_types = std::tuple<>;
-
};
} // namespace Fault
@@ -947,17 +951,17 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::Shutdown>
+struct map_exception_type<
+ sdbusplus::org::open_power::Witherspoon::Fault::Error::Shutdown>
{
using type = org::open_power::Witherspoon::Fault::Shutdown;
};
-}
+} // namespace details
namespace org
{
@@ -970,14 +974,12 @@
namespace _PowerOnFailure
{
-
-} // namespace _PowerOnFailure
+} // namespace _PowerOnFailure
struct PowerOnFailure
{
static constexpr auto L = level::ERR;
using metadata_types = std::tuple<>;
-
};
} // namespace Fault
@@ -985,17 +987,17 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerOnFailure>
+struct map_exception_type<
+ sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerOnFailure>
{
using type = org::open_power::Witherspoon::Fault::PowerOnFailure;
};
-}
+} // namespace details
namespace org
{
@@ -1012,28 +1014,28 @@
{
static constexpr auto str = "RAIL=%d";
static constexpr auto str_short = "RAIL";
- using type = std::tuple<std::decay_t<decltype(str)>,uint16_t>;
- explicit constexpr RAIL(uint16_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, uint16_t>;
+ explicit constexpr RAIL(uint16_t a) : _entry(entry(str, a)){};
type _entry;
};
struct RAIL_NAME
{
static constexpr auto str = "RAIL_NAME=%s";
static constexpr auto str_short = "RAIL_NAME";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr RAIL_NAME(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr RAIL_NAME(const char* a) : _entry(entry(str, a)){};
type _entry;
};
struct RAW_STATUS
{
static constexpr auto str = "RAW_STATUS=%s";
static constexpr auto str_short = "RAW_STATUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _PowerSequencerVoltageFault
+} // namespace _PowerSequencerVoltageFault
struct PowerSequencerVoltageFault
{
@@ -1042,7 +1044,6 @@
using RAIL_NAME = _PowerSequencerVoltageFault::RAIL_NAME;
using RAW_STATUS = _PowerSequencerVoltageFault::RAW_STATUS;
using metadata_types = std::tuple<RAIL, RAIL_NAME, RAW_STATUS>;
-
};
} // namespace Fault
@@ -1050,17 +1051,18 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerSequencerVoltageFault>
+struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::
+ Error::PowerSequencerVoltageFault>
{
- using type = org::open_power::Witherspoon::Fault::PowerSequencerVoltageFault;
+ using type =
+ org::open_power::Witherspoon::Fault::PowerSequencerVoltageFault;
};
-}
+} // namespace details
namespace org
{
@@ -1077,28 +1079,28 @@
{
static constexpr auto str = "INPUT_NUM=%d";
static constexpr auto str_short = "INPUT_NUM";
- using type = std::tuple<std::decay_t<decltype(str)>,uint16_t>;
- explicit constexpr INPUT_NUM(uint16_t a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, uint16_t>;
+ explicit constexpr INPUT_NUM(uint16_t a) : _entry(entry(str, a)){};
type _entry;
};
struct INPUT_NAME
{
static constexpr auto str = "INPUT_NAME=%s";
static constexpr auto str_short = "INPUT_NAME";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr INPUT_NAME(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr INPUT_NAME(const char* a) : _entry(entry(str, a)){};
type _entry;
};
struct RAW_STATUS
{
static constexpr auto str = "RAW_STATUS=%s";
static constexpr auto str_short = "RAW_STATUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _PowerSequencerPGOODFault
+} // namespace _PowerSequencerPGOODFault
struct PowerSequencerPGOODFault
{
@@ -1107,7 +1109,6 @@
using INPUT_NAME = _PowerSequencerPGOODFault::INPUT_NAME;
using RAW_STATUS = _PowerSequencerPGOODFault::RAW_STATUS;
using metadata_types = std::tuple<INPUT_NUM, INPUT_NAME, RAW_STATUS>;
-
};
} // namespace Fault
@@ -1115,17 +1116,17 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerSequencerPGOODFault>
+struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::
+ Error::PowerSequencerPGOODFault>
{
using type = org::open_power::Witherspoon::Fault::PowerSequencerPGOODFault;
};
-}
+} // namespace details
namespace org
{
@@ -1142,19 +1143,18 @@
{
static constexpr auto str = "RAW_STATUS=%s";
static constexpr auto str_short = "RAW_STATUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _PowerSequencerFault
+} // namespace _PowerSequencerFault
struct PowerSequencerFault
{
static constexpr auto L = level::ERR;
using RAW_STATUS = _PowerSequencerFault::RAW_STATUS;
using metadata_types = std::tuple<RAW_STATUS>;
-
};
} // namespace Fault
@@ -1162,17 +1162,17 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerSequencerFault>
+struct map_exception_type<
+ sdbusplus::org::open_power::Witherspoon::Fault::Error::PowerSequencerFault>
{
using type = org::open_power::Witherspoon::Fault::PowerSequencerFault;
};
-}
+} // namespace details
namespace org
{
@@ -1189,20 +1189,20 @@
{
static constexpr auto str = "RAW_STATUS=%s";
static constexpr auto str_short = "RAW_STATUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _GPUPowerFault
+} // namespace _GPUPowerFault
struct GPUPowerFault
{
static constexpr auto L = level::ERR;
using RAW_STATUS = _GPUPowerFault::RAW_STATUS;
- using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::Inventory::CALLOUT_INVENTORY_PATH;
+ using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::
+ Inventory::CALLOUT_INVENTORY_PATH;
using metadata_types = std::tuple<RAW_STATUS, CALLOUT_INVENTORY_PATH>;
-
};
} // namespace Fault
@@ -1210,17 +1210,17 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::GPUPowerFault>
+struct map_exception_type<
+ sdbusplus::org::open_power::Witherspoon::Fault::Error::GPUPowerFault>
{
using type = org::open_power::Witherspoon::Fault::GPUPowerFault;
};
-}
+} // namespace details
namespace org
{
@@ -1237,20 +1237,20 @@
{
static constexpr auto str = "RAW_STATUS=%s";
static constexpr auto str_short = "RAW_STATUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
+ using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
+ explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)){};
type _entry;
};
-} // namespace _GPUOverTemp
+} // namespace _GPUOverTemp
struct GPUOverTemp
{
static constexpr auto L = level::ERR;
using RAW_STATUS = _GPUOverTemp::RAW_STATUS;
- using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::Inventory::CALLOUT_INVENTORY_PATH;
+ using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::
+ Inventory::CALLOUT_INVENTORY_PATH;
using metadata_types = std::tuple<RAW_STATUS, CALLOUT_INVENTORY_PATH>;
-
};
} // namespace Fault
@@ -1258,18 +1258,17 @@
} // namespace open_power
} // namespace org
-
namespace details
{
template <>
-struct map_exception_type<sdbusplus::org::open_power::Witherspoon::Fault::Error::GPUOverTemp>
+struct map_exception_type<
+ sdbusplus::org::open_power::Witherspoon::Fault::Error::GPUOverTemp>
{
using type = org::open_power::Witherspoon::Fault::GPUOverTemp;
};
-}
-
+} // namespace details
} // namespace logging
diff --git a/file.hpp b/file.hpp
index 5be4c4b..d762012 100644
--- a/file.hpp
+++ b/file.hpp
@@ -15,59 +15,57 @@
*/
class FileDescriptor
{
- public:
+ public:
+ FileDescriptor() = default;
+ FileDescriptor(const FileDescriptor&) = delete;
+ FileDescriptor& operator=(const FileDescriptor&) = delete;
+ FileDescriptor(FileDescriptor&&) = delete;
+ FileDescriptor& operator=(FileDescriptor&&) = delete;
- FileDescriptor() = default;
- FileDescriptor(const FileDescriptor&) = delete;
- FileDescriptor& operator=(const FileDescriptor&) = delete;
- FileDescriptor(FileDescriptor&&) = delete;
- FileDescriptor& operator=(FileDescriptor&&) = delete;
+ /**
+ * Constructor
+ *
+ * @param[in] fd - File descriptor
+ */
+ FileDescriptor(int fd) : fd(fd)
+ {
+ }
- /**
- * Constructor
- *
- * @param[in] fd - File descriptor
- */
- FileDescriptor(int fd) : fd(fd)
+ ~FileDescriptor()
+ {
+ if (fd >= 0)
{
+ close(fd);
+ }
+ }
+
+ int operator()()
+ {
+ return fd;
+ }
+
+ operator bool() const
+ {
+ return fd != -1;
+ }
+
+ void set(int descriptor)
+ {
+ if (fd >= 0)
+ {
+ close(fd);
}
- ~FileDescriptor()
- {
- if (fd >= 0)
- {
- close(fd);
- }
- }
+ fd = descriptor;
+ }
- int operator()()
- {
- return fd;
- }
-
- operator bool() const
- {
- return fd != -1;
- }
-
- void set(int descriptor)
- {
- if (fd >= 0)
- {
- close(fd);
- }
-
- fd = descriptor;
- }
-
- private:
-
- /**
- * File descriptor
- */
- int fd = -1;
+ private:
+ /**
+ * File descriptor
+ */
+ int fd = -1;
};
-}
-}
-}
+} // namespace util
+} // namespace power
+} // namespace witherspoon
diff --git a/gpio.cpp b/gpio.cpp
index a2f1f3e..2dad86d 100644
--- a/gpio.cpp
+++ b/gpio.cpp
@@ -13,15 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <cassert>
-#include <fcntl.h>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
-#include <sys/ioctl.h>
-#include <xyz/openbmc_project/Common/error.hpp>
#include "gpio.hpp"
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+#include <cassert>
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/log.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
namespace witherspoon
{
namespace gpio
@@ -29,8 +31,8 @@
using namespace phosphor::logging;
-using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
- Error::InternalFailure;
+using InternalFailure =
+ sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
Value GPIO::read()
{
@@ -40,15 +42,12 @@
gpiohandle_data data{};
- auto rc = ioctl(lineFD(),
- GPIOHANDLE_GET_LINE_VALUES_IOCTL,
- &data);
+ auto rc = ioctl(lineFD(), GPIOHANDLE_GET_LINE_VALUES_IOCTL, &data);
if (rc < 0)
{
auto e = errno;
- log<level::ERR>("Failed GET_LINE_VALUES ioctl",
- entry("ERRNO=%d", e));
+ log<level::ERR>("Failed GET_LINE_VALUES ioctl", entry("ERRNO=%d", e));
elog<InternalFailure>();
}
@@ -68,15 +67,14 @@
if (rc == -1)
{
auto e = errno;
- log<level::ERR>("Failed SET_LINE_VALUES ioctl",
- entry("ERRNO=%d", e));
+ log<level::ERR>("Failed SET_LINE_VALUES ioctl", entry("ERRNO=%d", e));
elog<InternalFailure>();
}
}
void GPIO::requestLine(Value defaultValue)
{
- //Only need to do this once
+ // Only need to do this once
if (lineFD)
{
return;
@@ -92,15 +90,14 @@
elog<InternalFailure>();
}
- //Make an ioctl call to request the GPIO line, which will
- //return the descriptor to use to access it.
+ // Make an ioctl call to request the GPIO line, which will
+ // return the descriptor to use to access it.
gpiohandle_request request{};
- strncpy(request.consumer_label,
- "witherspoon-pfault-analysis",
+ strncpy(request.consumer_label, "witherspoon-pfault-analysis",
sizeof(request.consumer_label));
- request.flags = (direction == Direction::input) ?
- GPIOHANDLE_REQUEST_INPUT : GPIOHANDLE_REQUEST_OUTPUT;
+ request.flags = (direction == Direction::input) ? GPIOHANDLE_REQUEST_INPUT
+ : GPIOHANDLE_REQUEST_OUTPUT;
request.lineoffsets[0] = gpio;
request.lines = 1;
@@ -114,8 +111,7 @@
if (rc == -1)
{
auto e = errno;
- log<level::ERR>("Failed GET_LINEHANDLE ioctl",
- entry("GPIO=%d", gpio),
+ log<level::ERR>("Failed GET_LINEHANDLE ioctl", entry("GPIO=%d", gpio),
entry("ERRNO=%d", e));
elog<InternalFailure>();
}
@@ -123,5 +119,5 @@
lineFD.set(request.fd);
}
-}
-}
+} // namespace gpio
+} // namespace witherspoon
diff --git a/gpio.hpp b/gpio.hpp
index 04100da..2742d4f 100644
--- a/gpio.hpp
+++ b/gpio.hpp
@@ -1,18 +1,22 @@
#pragma once
-#include <linux/gpio.h>
#include "file.hpp"
+#include <linux/gpio.h>
+
+#include <string>
+#include <type_traits>
+
namespace witherspoon
{
namespace gpio
{
typedef std::remove_reference<decltype(
- gpiohandle_request::lineoffsets[0])>::type gpioNum_t;
+ gpiohandle_request::lineoffsets[0])>::type gpioNum_t;
-typedef std::remove_reference<decltype(
- gpiohandle_data::values[0])>::type gpioValue_t;
+typedef std::remove_reference<decltype(gpiohandle_data::values[0])>::type
+ gpioValue_t;
/**
* If the GPIO is an input or output
@@ -41,79 +45,73 @@
*/
class GPIO
{
- public:
+ public:
+ GPIO() = delete;
+ GPIO(const GPIO&) = delete;
+ GPIO(GPIO&&) = default;
+ GPIO& operator=(const GPIO&) = delete;
+ GPIO& operator=(GPIO&&) = default;
+ ~GPIO() = default;
- GPIO() = delete;
- GPIO(const GPIO&) = delete;
- GPIO(GPIO&&) = default;
- GPIO& operator=(const GPIO&) = delete;
- GPIO& operator=(GPIO&&) = default;
- ~GPIO() = default;
+ /**
+ * Constructor
+ *
+ * @param[in] device - the GPIO device file
+ * @param[in] gpio - the GPIO number
+ * @param[in] direction - the GPIO direction
+ */
+ GPIO(const std::string& device, gpioNum_t gpio, Direction direction) :
+ device(device), gpio(gpio), direction(direction)
+ {
+ }
- /**
- * Constructor
- *
- * @param[in] device - the GPIO device file
- * @param[in] gpio - the GPIO number
- * @param[in] direction - the GPIO direction
- */
- GPIO(const std::string& device,
- gpioNum_t gpio,
- Direction direction) :
- device(device),
- gpio(gpio),
- direction(direction)
- {
- }
+ /**
+ * Reads the GPIO value
+ *
+ * Requests the GPIO line if it hasn't been done already.
+ *
+ * @return Value - the GPIO value
+ */
+ Value read();
- /**
- * Reads the GPIO value
- *
- * Requests the GPIO line if it hasn't been done already.
- *
- * @return Value - the GPIO value
- */
- Value read();
+ /**
+ * Sets the GPIO value to low or high
+ *
+ * Requests the GPIO line if it hasn't been done already.
+ *
+ * @param[in] Value - the value to set
+ */
+ void set(Value value);
- /**
- * Sets the GPIO value to low or high
- *
- * Requests the GPIO line if it hasn't been done already.
- *
- * @param[in] Value - the value to set
- */
- void set(Value value);
+ private:
+ /**
+ * Requests a GPIO line from the GPIO device
+ *
+ * @param[in] defaultValue - The default value, required for
+ * output GPIOs only.
+ */
+ void requestLine(Value defaultValue = Value::high);
- private:
+ /**
+ * The GPIO device name, like /dev/gpiochip0
+ */
+ const std::string device;
- /**
- * Requests a GPIO line from the GPIO device
- *
- * @param[in] defaultValue - The default value, required for
- * output GPIOs only.
- */
- void requestLine(Value defaultValue = Value::high);
+ /**
+ * The GPIO number
+ */
+ const gpioNum_t gpio;
- /**
- * The GPIO device name, like /dev/gpiochip0
- */
- const std::string device;
+ /**
+ * The GPIO direction
+ */
+ const Direction direction;
- /**
- * The GPIO number
- */
- const gpioNum_t gpio;
-
- /**
- * The GPIO direction
- */
- const Direction direction;
-
- /**
- * File descriptor for the GPIO line
- */
- power::util::FileDescriptor lineFD;
+ /**
+ * File descriptor for the GPIO line
+ */
+ power::util::FileDescriptor lineFD;
};
-}
-}
+} // namespace gpio
+} // namespace witherspoon
diff --git a/names_values.hpp b/names_values.hpp
index 1e03d51..c33c507 100644
--- a/names_values.hpp
+++ b/names_values.hpp
@@ -33,80 +33,78 @@
*/
class NamesValues
{
- public:
+ public:
+ NamesValues() = default;
+ NamesValues(const NamesValues&) = default;
+ NamesValues& operator=(const NamesValues&) = default;
+ NamesValues(NamesValues&&) = default;
+ NamesValues& operator=(NamesValues&&) = default;
- NamesValues() = default;
- NamesValues(const NamesValues&) = default;
- NamesValues& operator=(const NamesValues&) = default;
- NamesValues(NamesValues&&) = default;
- NamesValues& operator=(NamesValues&&) = default;
+ /**
+ * Adds a name/value pair to the object
+ *
+ * @param name - the name to add
+ * @param value - the value to add
+ */
+ void add(const std::string& name, uint64_t value)
+ {
+ addDivider();
+ addName(name);
+ addValue(value);
+ }
- /**
- * Adds a name/value pair to the object
- *
- * @param name - the name to add
- * @param value - the value to add
- */
- void add(const std::string& name, uint64_t value)
+ /**
+ * Returns a formatted concatenation of all of the names and
+ * their values.
+ *
+ * @return string - "<name1>=<value1>|<name2>=<value2>..etc"
+ */
+ const std::string& get() const
+ {
+ return all;
+ }
+
+ private:
+ /**
+ * Adds a name to the object
+ *
+ * @param name - the name to add
+ */
+ void addName(const std::string& name)
+ {
+ all += name + '=';
+ }
+
+ /**
+ * Adds a value to the object
+ *
+ * @param value - the value to add
+ */
+ void addValue(uint64_t value)
+ {
+ std::ostringstream stream;
+ stream << "0x" << std::hex << value;
+ all += stream.str();
+ }
+
+ /**
+ * Adds a divider to the summary string to
+ * break up the name/value pairs
+ */
+ void addDivider()
+ {
+ if (!all.empty())
{
- addDivider();
- addName(name);
- addValue(value);
+ all += '|';
}
+ }
- /**
- * Returns a formatted concatenation of all of the names and
- * their values.
- *
- * @return string - "<name1>=<value1>|<name2>=<value2>..etc"
- */
- const std::string& get() const
- {
- return all;
- }
-
- private:
-
- /**
- * Adds a name to the object
- *
- * @param name - the name to add
- */
- void addName(const std::string& name)
- {
- all += name + '=';
- }
-
- /**
- * Adds a value to the object
- *
- * @param value - the value to add
- */
- void addValue(uint64_t value)
- {
- std::ostringstream stream;
- stream << "0x" << std::hex << value;
- all += stream.str();
- }
-
- /**
- * Adds a divider to the summary string to
- * break up the name/value pairs
- */
- void addDivider()
- {
- if (!all.empty())
- {
- all += '|';
- }
- }
-
- /**
- * The string containing all name/value pairs
- */
- std::string all;
+ /**
+ * The string containing all name/value pairs
+ */
+ std::string all;
};
-}
-}
-}
+} // namespace util
+} // namespace power
+} // namespace witherspoon
diff --git a/pmbus.cpp b/pmbus.cpp
index 76ab39c..9d991a6 100644
--- a/pmbus.cpp
+++ b/pmbus.cpp
@@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "pmbus.hpp"
+
#include <experimental/filesystem>
#include <fstream>
-#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/elog-errors.hpp>
-#include <xyz/openbmc_project/Common/error.hpp>
+#include <phosphor-logging/elog.hpp>
#include <xyz/openbmc_project/Common/Device/error.hpp>
-#include "pmbus.hpp"
+#include <xyz/openbmc_project/Common/error.hpp>
namespace witherspoon
{
@@ -42,12 +43,11 @@
}
};
-std::string PMBus::insertPageNum(const std::string& templateName,
- size_t page)
+std::string PMBus::insertPageNum(const std::string& templateName, size_t page)
{
auto name = templateName;
- //insert the page where the P was
+ // insert the page where the P was
auto pos = name.find('P');
if (pos != std::string::npos)
{
@@ -90,8 +90,7 @@
std::ifstream file;
auto path = basePath / "name";
- file.exceptions(std::ifstream::failbit |
- std::ifstream::badbit |
+ file.exceptions(std::ifstream::failbit | std::ifstream::badbit |
std::ifstream::eofbit);
try
{
@@ -107,9 +106,7 @@
return name;
}
-bool PMBus::readBitInPage(const std::string& name,
- size_t page,
- Type type)
+bool PMBus::readBitInPage(const std::string& name, size_t page, Type type)
{
auto pagedBit = insertPageNum(name, page);
return readBit(pagedBit, type);
@@ -123,8 +120,7 @@
path /= name;
- file.exceptions(std::ifstream::failbit |
- std::ifstream::badbit |
+ file.exceptions(std::ifstream::failbit | std::ifstream::badbit |
std::ifstream::eofbit);
try
@@ -143,7 +139,7 @@
entry("FILE=%s", path.c_str()),
entry("CONTENTS=%s", val.c_str()));
- //Catch below and handle as a read failure
+ // Catch below and handle as a read failure
elog<InternalFailure>();
}
}
@@ -156,9 +152,9 @@
using metadata = xyz::openbmc_project::Common::Device::ReadFailure;
- elog<ReadFailure>(metadata::CALLOUT_ERRNO(rc),
- metadata::CALLOUT_DEVICE_PATH(
- fs::canonical(basePath).c_str()));
+ elog<ReadFailure>(
+ metadata::CALLOUT_ERRNO(rc),
+ metadata::CALLOUT_DEVICE_PATH(fs::canonical(basePath).c_str()));
}
return value != 0;
@@ -178,8 +174,7 @@
auto path = getPath(type);
path /= name;
- file.exceptions(std::ifstream::failbit |
- std::ifstream::badbit |
+ file.exceptions(std::ifstream::failbit | std::ifstream::badbit |
std::ifstream::eofbit);
try
@@ -195,9 +190,9 @@
using metadata = xyz::openbmc_project::Common::Device::ReadFailure;
- elog<ReadFailure>(metadata::CALLOUT_ERRNO(rc),
- metadata::CALLOUT_DEVICE_PATH(
- fs::canonical(basePath).c_str()));
+ elog<ReadFailure>(
+ metadata::CALLOUT_ERRNO(rc),
+ metadata::CALLOUT_DEVICE_PATH(fs::canonical(basePath).c_str()));
}
return data;
@@ -210,8 +205,7 @@
auto path = getPath(type);
path /= name;
- file.exceptions(std::ifstream::failbit |
- std::ifstream::badbit |
+ file.exceptions(std::ifstream::failbit | std::ifstream::badbit |
std::ifstream::eofbit);
try
@@ -227,39 +221,36 @@
using metadata = xyz::openbmc_project::Common::Device::ReadFailure;
- elog<ReadFailure>(metadata::CALLOUT_ERRNO(rc),
- metadata::CALLOUT_DEVICE_PATH(
- fs::canonical(basePath).c_str()));
+ elog<ReadFailure>(
+ metadata::CALLOUT_ERRNO(rc),
+ metadata::CALLOUT_DEVICE_PATH(fs::canonical(basePath).c_str()));
}
return data;
}
-std::vector<uint8_t> PMBus::readBinary(const std::string& name,
- Type type,
+std::vector<uint8_t> PMBus::readBinary(const std::string& name, Type type,
size_t length)
{
auto path = getPath(type) / name;
- //Use C style IO because it's easier to handle telling the difference
- //between hitting EOF or getting an actual error.
+ // Use C style IO because it's easier to handle telling the difference
+ // between hitting EOF or getting an actual error.
std::unique_ptr<FILE, FileCloser> file{fopen(path.c_str(), "rb")};
if (file)
{
std::vector<uint8_t> data(length, 0);
- auto bytes = fread(data.data(),
- sizeof(decltype(data[0])),
- length,
- file.get());
+ auto bytes =
+ fread(data.data(), sizeof(decltype(data[0])), length, file.get());
if (bytes != length)
{
- //If hit EOF, just return the amount of data that was read.
+ // If hit EOF, just return the amount of data that was read.
if (feof(file.get()))
{
- data.erase(data.begin() + bytes, data.end());
+ data.erase(data.begin() + bytes, data.end());
}
else if (ferror(file.get()))
{
@@ -267,12 +258,12 @@
log<level::ERR>("Failed to read sysfs file",
entry("FILENAME=%s", path.c_str()));
- using metadata = xyz::openbmc_project::Common::
- Device::ReadFailure;
+ using metadata =
+ xyz::openbmc_project::Common::Device::ReadFailure;
elog<ReadFailure>(metadata::CALLOUT_ERRNO(rc),
metadata::CALLOUT_DEVICE_PATH(
- fs::canonical(basePath).c_str()));
+ fs::canonical(basePath).c_str()));
}
}
return data;
@@ -288,8 +279,7 @@
path /= name;
- file.exceptions(std::ofstream::failbit |
- std::ofstream::badbit |
+ file.exceptions(std::ofstream::failbit | std::ofstream::badbit |
std::ofstream::eofbit);
try
@@ -306,9 +296,9 @@
using metadata = xyz::openbmc_project::Common::Device::WriteFailure;
- elog<WriteFailure>(metadata::CALLOUT_ERRNO(rc),
- metadata::CALLOUT_DEVICE_PATH(
- fs::canonical(basePath).c_str()));
+ elog<WriteFailure>(
+ metadata::CALLOUT_ERRNO(rc),
+ metadata::CALLOUT_DEVICE_PATH(fs::canonical(basePath).c_str()));
}
}
@@ -322,7 +312,7 @@
// hwmon directory is not there, resulting in a program termination.
if (fs::is_directory(path))
{
- //look for <basePath>/hwmon/hwmonN/
+ // look for <basePath>/hwmon/hwmonN/
for (auto& f : fs::directory_iterator(path))
{
if ((f.path().filename().string().find("hwmon") !=
@@ -335,16 +325,15 @@
}
}
- //Don't really want to crash here, just log it
- //and let accesses fail later
+ // Don't really want to crash here, just log it
+ // and let accesses fail later
if (hwmonDir.empty())
{
log<level::INFO>("Unable to find hwmon directory "
"in device base path",
entry("DEVICE_PATH=%s", basePath.c_str()));
}
-
}
-}
-}
+} // namespace pmbus
+} // namespace witherspoon
diff --git a/pmbus.hpp b/pmbus.hpp
index b6a01f6..22452cf 100644
--- a/pmbus.hpp
+++ b/pmbus.hpp
@@ -27,7 +27,7 @@
{
// Mask of bits that are only warnings
constexpr auto WARNING_MASK = 0x6A;
-}
+} // namespace status_vout
// Current output status bits.
constexpr auto STATUS_IOUT = "status0_iout";
@@ -79,24 +79,24 @@
// STATUS_WORD. Bit 2 of the low byte (STATUS_BYTE).
constexpr auto TEMPERATURE_FAULT_WARN = 0x0004;
-}
+} // namespace status_word
namespace status_temperature
{
// Overtemperature Fault
constexpr auto OT_FAULT = 0x80;
-}
+} // namespace status_temperature
/**
* Where the access should be done
*/
enum class Type
{
- Base, // base device directory
- Hwmon, // hwmon directory
- Debug, // pmbus debug directory
- DeviceDebug, // device debug directory
- HwmonDeviceDebug // hwmon device debug directory
+ Base, // base device directory
+ Hwmon, // hwmon directory
+ Debug, // pmbus debug directory
+ DeviceDebug, // device debug directory
+ HwmonDeviceDebug // hwmon device debug directory
};
/**
@@ -111,209 +111,200 @@
*/
class PMBus
{
- public:
+ public:
+ PMBus() = delete;
+ ~PMBus() = default;
+ PMBus(const PMBus&) = default;
+ PMBus& operator=(const PMBus&) = default;
+ PMBus(PMBus&&) = default;
+ PMBus& operator=(PMBus&&) = default;
- PMBus() = delete;
- ~PMBus() = default;
- PMBus(const PMBus&) = default;
- PMBus& operator=(const PMBus&) = default;
- PMBus(PMBus&&) = default;
- PMBus& operator=(PMBus&&) = default;
+ /**
+ * Constructor
+ *
+ * @param[in] path - path to the sysfs directory
+ */
+ PMBus(const std::string& path) : basePath(path)
+ {
+ findHwmonDir();
+ }
- /**
- * Constructor
- *
- * @param[in] path - path to the sysfs directory
- */
- PMBus(const std::string& path) :
- basePath(path)
- {
- findHwmonDir();
- }
+ /**
+ * Constructor
+ *
+ * This version is required when DeviceDebug
+ * access will be used.
+ *
+ * @param[in] path - path to the sysfs directory
+ * @param[in] driverName - the device driver name
+ * @param[in] instance - chip instance number
+ */
+ PMBus(const std::string& path, const std::string& driverName,
+ size_t instance) :
+ basePath(path),
+ driverName(driverName), instance(instance)
+ {
+ findHwmonDir();
+ }
- /**
- * Constructor
- *
- * This version is required when DeviceDebug
- * access will be used.
- *
- * @param[in] path - path to the sysfs directory
- * @param[in] driverName - the device driver name
- * @param[in] instance - chip instance number
- */
- PMBus(const std::string& path,
- const std::string& driverName,
- size_t instance) :
- basePath(path),
- driverName(driverName),
- instance(instance)
- {
- findHwmonDir();
- }
+ /**
+ * Reads a file in sysfs that represents a single bit,
+ * therefore doing a PMBus read.
+ *
+ * @param[in] name - path concatenated to
+ * basePath to read
+ * @param[in] type - Path type
+ *
+ * @return bool - false if result was 0, else true
+ */
+ bool readBit(const std::string& name, Type type);
- /**
- * Reads a file in sysfs that represents a single bit,
- * therefore doing a PMBus read.
- *
- * @param[in] name - path concatenated to
- * basePath to read
- * @param[in] type - Path type
- *
- * @return bool - false if result was 0, else true
- */
- bool readBit(const std::string& name, Type type);
+ /**
+ * Reads a file in sysfs that represents a single bit,
+ * where the page number passed in is substituted
+ * into the name in place of the 'P' character in it.
+ *
+ * @param[in] name - path concatenated to
+ * basePath to read
+ * @param[in] page - page number
+ * @param[in] type - Path type
+ *
+ * @return bool - false if result was 0, else true
+ */
+ bool readBitInPage(const std::string& name, size_t page, Type type);
+ /**
+ * Checks if the file for the given name and type exists.
+ *
+ * @param[in] name - path concatenated to basePath to read
+ * @param[in] type - Path type
+ *
+ * @return bool - True if file exists, false if it does not.
+ */
+ bool exists(const std::string& name, Type type);
- /**
- * Reads a file in sysfs that represents a single bit,
- * where the page number passed in is substituted
- * into the name in place of the 'P' character in it.
- *
- * @param[in] name - path concatenated to
- * basePath to read
- * @param[in] page - page number
- * @param[in] type - Path type
- *
- * @return bool - false if result was 0, else true
- */
- bool readBitInPage(const std::string& name,
- size_t page,
- Type type);
- /**
- * Checks if the file for the given name and type exists.
- *
- * @param[in] name - path concatenated to basePath to read
- * @param[in] type - Path type
- *
- * @return bool - True if file exists, false if it does not.
- */
- bool exists(const std::string& name, Type type);
+ /**
+ * Read byte(s) from file in sysfs.
+ *
+ * @param[in] name - path concatenated to basePath to read
+ * @param[in] type - Path type
+ *
+ * @return uint64_t - Up to 8 bytes of data read from file.
+ */
+ uint64_t read(const std::string& name, Type type);
- /**
- * Read byte(s) from file in sysfs.
- *
- * @param[in] name - path concatenated to basePath to read
- * @param[in] type - Path type
- *
- * @return uint64_t - Up to 8 bytes of data read from file.
- */
- uint64_t read(const std::string& name, Type type);
+ /**
+ * Read a string from file in sysfs.
+ *
+ * @param[in] name - path concatenated to basePath to read
+ * @param[in] type - Path type
+ *
+ * @return string - The data read from the file.
+ */
+ std::string readString(const std::string& name, Type type);
- /**
- * Read a string from file in sysfs.
- *
- * @param[in] name - path concatenated to basePath to read
- * @param[in] type - Path type
- *
- * @return string - The data read from the file.
- */
- std::string readString(const std::string& name, Type type);
+ /**
+ * Read data from a binary file in sysfs.
+ *
+ * @param[in] name - path concatenated to basePath to read
+ * @param[in] type - Path type
+ * @param[in] length - length of data to read, in bytes
+ *
+ * @return vector<uint8_t> - The data read from the file.
+ */
+ std::vector<uint8_t> readBinary(const std::string& name, Type type,
+ size_t length);
- /**
- * Read data from a binary file in sysfs.
- *
- * @param[in] name - path concatenated to basePath to read
- * @param[in] type - Path type
- * @param[in] length - length of data to read, in bytes
- *
- * @return vector<uint8_t> - The data read from the file.
- */
- std::vector<uint8_t> readBinary(const std::string& name,
- Type type,
- size_t length);
+ /**
+ * Writes an integer value to the file, therefore doing
+ * a PMBus write.
+ *
+ * @param[in] name - path concatenated to
+ * basePath to write
+ * @param[in] value - the value to write
+ * @param[in] type - Path type
+ */
+ void write(const std::string& name, int value, Type type);
- /**
- * Writes an integer value to the file, therefore doing
- * a PMBus write.
- *
- * @param[in] name - path concatenated to
- * basePath to write
- * @param[in] value - the value to write
- * @param[in] type - Path type
- */
- void write(const std::string& name, int value, Type type);
+ /**
+ * Returns the sysfs base path of this device
+ */
+ inline const auto& path() const
+ {
+ return basePath;
+ }
- /**
- * Returns the sysfs base path of this device
- */
- inline const auto& path() const
- {
- return basePath;
- }
+ /**
+ * Replaces the 'P' in the string passed in with
+ * the page number passed in.
+ *
+ * For example:
+ * insertPageNum("inP_enable", 42)
+ * returns "in42_enable"
+ *
+ * @param[in] templateName - the name string, with a 'P' in it
+ * @param[in] page - the page number to insert where the P was
+ *
+ * @return string - the new string with the page number in it
+ */
+ static std::string insertPageNum(const std::string& templateName,
+ size_t page);
- /**
- * Replaces the 'P' in the string passed in with
- * the page number passed in.
- *
- * For example:
- * insertPageNum("inP_enable", 42)
- * returns "in42_enable"
- *
- * @param[in] templateName - the name string, with a 'P' in it
- * @param[in] page - the page number to insert where the P was
- *
- * @return string - the new string with the page number in it
- */
- static std::string insertPageNum(const std::string& templateName,
- size_t page);
+ /**
+ * Finds the path relative to basePath to the hwmon directory
+ * for the device and stores it in hwmonRelPath.
+ */
+ void findHwmonDir();
- /**
- * Finds the path relative to basePath to the hwmon directory
- * for the device and stores it in hwmonRelPath.
- */
- void findHwmonDir();
+ /**
+ * Returns the path to use for the passed in type.
+ *
+ * @param[in] type - Path type
+ *
+ * @return fs::path - the full path
+ */
+ fs::path getPath(Type type);
- /**
- * Returns the path to use for the passed in type.
- *
- * @param[in] type - Path type
- *
- * @return fs::path - the full path
- */
- fs::path getPath(Type type);
+ private:
+ /**
+ * Returns the device name
+ *
+ * This is found in the 'name' file in basePath.
+ *
+ * @return string - the device name
+ */
+ std::string getDeviceName();
- private:
+ /**
+ * The sysfs device path
+ */
+ fs::path basePath;
- /**
- * Returns the device name
- *
- * This is found in the 'name' file in basePath.
- *
- * @return string - the device name
- */
- std::string getDeviceName();
+ /**
+ * The directory name under the basePath hwmon directory
+ */
+ fs::path hwmonDir;
- /**
- * The sysfs device path
- */
- fs::path basePath;
+ /**
+ * The device driver name. Used for finding the device
+ * debug directory. Not required if that directory
+ * isn't used.
+ */
+ std::string driverName;
- /**
- * The directory name under the basePath hwmon directory
- */
- fs::path hwmonDir;
+ /**
+ * The device instance number.
+ *
+ * Used in conjunction with the driver name for finding
+ * the debug directory. Not required if that directory
+ * isn't used.
+ */
+ size_t instance = 0;
- /**
- * The device driver name. Used for finding the device
- * debug directory. Not required if that directory
- * isn't used.
- */
- std::string driverName;
-
- /**
- * The device instance number.
- *
- * Used in conjunction with the driver name for finding
- * the debug directory. Not required if that directory
- * isn't used.
- */
- size_t instance = 0;
-
- /**
- * The pmbus debug path with status files
- */
- const fs::path debugPath = "/sys/kernel/debug/";
-
+ /**
+ * The pmbus debug path with status files
+ */
+ const fs::path debugPath = "/sys/kernel/debug/";
};
-}
-}
+} // namespace pmbus
+} // namespace witherspoon
diff --git a/power-sequencer/argument.cpp b/power-sequencer/argument.cpp
index 4e80c53..5325256 100644
--- a/power-sequencer/argument.cpp
+++ b/power-sequencer/argument.cpp
@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "argument.hpp"
+
+#include <algorithm>
#include <iostream>
#include <iterator>
-#include <algorithm>
-#include "argument.hpp"
namespace witherspoon
{
@@ -37,11 +38,10 @@
std::cerr << std::flush;
}
-const option ArgumentParser::options[] =
-{
- {"action", required_argument, NULL, 'a'},
+const option ArgumentParser::options[] = {
+ {"action", required_argument, NULL, 'a'},
{"interval", required_argument, NULL, 'i'},
- {"help", no_argument, NULL, 'h'},
+ {"help", no_argument, NULL, 'h'},
{0, 0, 0, 0},
};
@@ -86,5 +86,5 @@
const std::string ArgumentParser::trueString = "true";
const std::string ArgumentParser::emptyString = "";
-}
-}
+} // namespace power
+} // namespace witherspoon
diff --git a/power-sequencer/main.cpp b/power-sequencer/main.cpp
index e383fc1..3e1ca52 100644
--- a/power-sequencer/main.cpp
+++ b/power-sequencer/main.cpp
@@ -13,15 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <chrono>
-#include <iostream>
-#include <phosphor-logging/log.hpp>
-#include <sdeventplus/event.hpp>
#include "argument.hpp"
#include "pgood_monitor.hpp"
#include "runtime_monitor.hpp"
#include "ucd90160.hpp"
+#include <chrono>
+#include <iostream>
+#include <phosphor-logging/log.hpp>
+#include <sdeventplus/event.hpp>
+
using namespace witherspoon::power;
using namespace phosphor::logging;
@@ -46,7 +47,7 @@
std::chrono::milliseconds interval{i};
- auto event = sdeventplus::Event::get_default();
+ auto event = sdeventplus::Event::get_default();
auto bus = sdbusplus::bus::new_default();
bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
@@ -56,17 +57,17 @@
if (action == "pgood-monitor")
{
- //If PGOOD doesn't turn on within a certain
- //time, analyze the device for errors
- monitor = std::make_unique<PGOODMonitor>(
- std::move(device), bus, event, interval);
+ // If PGOOD doesn't turn on within a certain
+ // time, analyze the device for errors
+ monitor = std::make_unique<PGOODMonitor>(std::move(device), bus, event,
+ interval);
}
- else //runtime-monitor
+ else // runtime-monitor
{
- //Continuously monitor this device both by polling
- //and on 'power lost' signals.
- monitor = std::make_unique<RuntimeMonitor>(
- std::move(device), bus, event, interval);
+ // Continuously monitor this device both by polling
+ // and on 'power lost' signals.
+ monitor = std::make_unique<RuntimeMonitor>(std::move(device), bus,
+ event, interval);
}
return monitor->run();
diff --git a/power-sequencer/pgood_monitor.cpp b/power-sequencer/pgood_monitor.cpp
index 29382c9..98c3faa 100644
--- a/power-sequencer/pgood_monitor.cpp
+++ b/power-sequencer/pgood_monitor.cpp
@@ -13,13 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <phosphor-logging/log.hpp>
-#include <org/open_power/Witherspoon/Fault/error.hpp>
#include "config.h"
-#include "elog-errors.hpp"
+
#include "pgood_monitor.hpp"
+
+#include "elog-errors.hpp"
#include "utility.hpp"
+#include <org/open_power/Witherspoon/Fault/error.hpp>
+#include <phosphor-logging/log.hpp>
+
namespace witherspoon
{
namespace power
@@ -37,26 +40,16 @@
int32_t state = 0;
int32_t pgood = 0;
- auto service = util::getService(POWER_OBJ_PATH,
- POWER_INTERFACE,
- bus);
+ auto service = util::getService(POWER_OBJ_PATH, POWER_INTERFACE, bus);
- util::getProperty<int32_t>(POWER_INTERFACE,
- "pgood",
- POWER_OBJ_PATH,
- service,
- bus,
- pgood);
+ util::getProperty<int32_t>(POWER_INTERFACE, "pgood", POWER_OBJ_PATH,
+ service, bus, pgood);
- //When state = 1, system was switched on
- util::getProperty<int32_t>(POWER_INTERFACE,
- "state",
- POWER_OBJ_PATH,
- service,
- bus,
- state);
+ // When state = 1, system was switched on
+ util::getProperty<int32_t>(POWER_INTERFACE, "state", POWER_OBJ_PATH,
+ service, bus, state);
- //On but no PGOOD
+ // On but no PGOOD
if (state && !pgood)
{
pending = true;
@@ -65,13 +58,12 @@
return pending;
}
-
void PGOODMonitor::analyze()
{
- //Timer callback.
- //The timer expired before it was stopped.
- //If PGOOD is still pending (it should be),
- //then there is a real failure.
+ // Timer callback.
+ // The timer expired before it was stopped.
+ // If PGOOD is still pending (it should be),
+ // then there is a real failure.
if (pgoodPending())
{
@@ -81,18 +73,18 @@
report<PowerOnFailure>();
}
- //The pgood-wait service (with a longer timeout)
- //will handle powering off the system.
+ // The pgood-wait service (with a longer timeout)
+ // will handle powering off the system.
timer.get_event().exit(EXIT_SUCCESS);
}
void PGOODMonitor::propertyChanged()
{
- //Multiple properties could have changed here.
- //Keep things simple and just recheck the important ones.
+ // Multiple properties could have changed here.
+ // Keep things simple and just recheck the important ones.
if (!pgoodPending())
{
- //PGOOD is on, or system is off, so we are done.
+ // PGOOD is on, or system is off, so we are done.
timer.get_event().exit(EXIT_SUCCESS);
}
}
@@ -100,11 +92,10 @@
void PGOODMonitor::startListening()
{
match = std::make_unique<sdbusplus::bus::match_t>(
- bus,
- sdbusplus::bus::match::rules::propertiesChanged(
- POWER_OBJ_PATH,
- POWER_INTERFACE),
- [this](auto& msg){this->propertyChanged();});
+ bus,
+ sdbusplus::bus::match::rules::propertiesChanged(POWER_OBJ_PATH,
+ POWER_INTERFACE),
+ [this](auto& msg) { this->propertyChanged(); });
}
int PGOODMonitor::run()
@@ -113,9 +104,9 @@
{
startListening();
- //If PGOOD came up before we got here, we're done.
- //Otherwise if PGOOD doesn't get asserted before
- //the timer expires, it's a failure.
+ // If PGOOD came up before we got here, we're done.
+ // Otherwise if PGOOD doesn't get asserted before
+ // the timer expires, it's a failure.
if (!pgoodPending())
{
return EXIT_SUCCESS;
@@ -129,10 +120,9 @@
log<level::ERR>("Unexpected failure prevented PGOOD checking");
}
- //Letting the service fail won't help anything, so don't do it.
+ // Letting the service fail won't help anything, so don't do it.
return EXIT_SUCCESS;
}
-
-}
-}
+} // namespace power
+} // namespace witherspoon
diff --git a/power-sequencer/pgood_monitor.hpp b/power-sequencer/pgood_monitor.hpp
index ec8e05e..7dbabf9 100644
--- a/power-sequencer/pgood_monitor.hpp
+++ b/power-sequencer/pgood_monitor.hpp
@@ -1,10 +1,11 @@
#pragma once
+#include "device.hpp"
+#include "device_monitor.hpp"
+
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server.hpp>
#include <sdeventplus/event.hpp>
-#include "device.hpp"
-#include "device_monitor.hpp"
namespace witherspoon
{
@@ -25,88 +26,85 @@
*/
class PGOODMonitor : public DeviceMonitor
{
- public:
+ public:
+ PGOODMonitor() = delete;
+ ~PGOODMonitor() = default;
+ PGOODMonitor(const PGOODMonitor&) = delete;
+ PGOODMonitor& operator=(const PGOODMonitor&) = delete;
+ PGOODMonitor(PGOODMonitor&&) = delete;
+ PGOODMonitor& operator=(PGOODMonitor&&) = delete;
- PGOODMonitor() = delete;
- ~PGOODMonitor() = default;
- PGOODMonitor(const PGOODMonitor&) = delete;
- PGOODMonitor& operator=(const PGOODMonitor&) = delete;
- PGOODMonitor(PGOODMonitor&&) = delete;
- PGOODMonitor& operator=(PGOODMonitor&&) = delete;
+ /**
+ * Constructor
+ *
+ * @param[in] d - the device to monitor
+ * @param[in] b - D-Bus bus object
+ * @param[in] e - event object
+ * @param[in] t - time to allow PGOOD to come up
+ */
+ PGOODMonitor(std::unique_ptr<witherspoon::power::Device>&& d,
+ sdbusplus::bus::bus& b, const sdeventplus::Event& e,
+ std::chrono::milliseconds& t) :
+ DeviceMonitor(std::move(d), e, t),
+ bus(b)
+ {
+ }
- /**
- * Constructor
- *
- * @param[in] d - the device to monitor
- * @param[in] b - D-Bus bus object
- * @param[in] e - event object
- * @param[in] t - time to allow PGOOD to come up
- */
- PGOODMonitor(std::unique_ptr<witherspoon::power::Device>&& d,
- sdbusplus::bus::bus& b,
- const sdeventplus::Event& e,
- std::chrono::milliseconds& t) :
- DeviceMonitor(std::move(d), e, t),
- bus(b)
- {
- }
+ /**
+ * Analyzes the power sequencer for fails and then
+ * notifies the event loop that it can exit.
+ *
+ * The timer callback.
+ */
+ void analyze() override;
- /**
- * Analyzes the power sequencer for fails and then
- * notifies the event loop that it can exit.
- *
- * The timer callback.
- */
- void analyze() override;
+ /**
+ * Waits a specified amount of time for PGOOD to
+ * come on, and if it fails to come on in that time
+ * it will analyze the power sequencer for faults.
+ *
+ * It will exit after either PGOOD is asserted or
+ * the device is analyzed for faults.
+ *
+ * @return - the return value from sd_event_loop()
+ */
+ int run() override;
- /**
- * Waits a specified amount of time for PGOOD to
- * come on, and if it fails to come on in that time
- * it will analyze the power sequencer for faults.
- *
- * It will exit after either PGOOD is asserted or
- * the device is analyzed for faults.
- *
- * @return - the return value from sd_event_loop()
- */
- int run() override;
+ private:
+ /**
+ * Enables the properties changed signal callback
+ * on the power object so we can tell when PGOOD
+ * comes on.
+ */
+ void startListening();
- private:
+ /**
+ * The callback function for the properties changed
+ * signal.
+ */
+ void propertyChanged();
- /**
- * Enables the properties changed signal callback
- * on the power object so we can tell when PGOOD
- * comes on.
- */
- void startListening();
+ /**
+ * Returns true if the system has been turned on
+ * but PGOOD isn't up yet.
+ */
+ bool pgoodPending();
- /**
- * The callback function for the properties changed
- * signal.
- */
- void propertyChanged();
+ /**
+ * Used to break out of the event loop in run()
+ */
+ void exitEventLoop();
- /**
- * Returns true if the system has been turned on
- * but PGOOD isn't up yet.
- */
- bool pgoodPending();
+ /**
+ * The D-Bus object
+ */
+ sdbusplus::bus::bus& bus;
- /**
- * Used to break out of the event loop in run()
- */
- void exitEventLoop();
-
- /**
- * The D-Bus object
- */
- sdbusplus::bus::bus& bus;
-
- /**
- * The match object for the properties changed signal
- */
- std::unique_ptr<sdbusplus::bus::match_t> match;
+ /**
+ * The match object for the properties changed signal
+ */
+ std::unique_ptr<sdbusplus::bus::match_t> match;
};
-}
-}
+} // namespace power
+} // namespace witherspoon
diff --git a/power-sequencer/runtime_monitor.cpp b/power-sequencer/runtime_monitor.cpp
index 514ba8f..5d17eb9 100644
--- a/power-sequencer/runtime_monitor.cpp
+++ b/power-sequencer/runtime_monitor.cpp
@@ -13,12 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "config.h"
+
+#include "runtime_monitor.hpp"
+
+#include "elog-errors.hpp"
+#include "utility.hpp"
+
#include <org/open_power/Witherspoon/Fault/error.hpp>
#include <phosphor-logging/log.hpp>
-#include "config.h"
-#include "elog-errors.hpp"
-#include "runtime_monitor.hpp"
-#include "utility.hpp"
namespace witherspoon
{
@@ -48,18 +51,18 @@
#ifdef UCD90160_DEVICE_ACCESS
device->onFailure();
#endif
- //Note: This application only runs when the system has
- //power, so it will be killed by systemd sometime shortly
- //after this power off is issued.
+ // Note: This application only runs when the system has
+ // power, so it will be killed by systemd sometime shortly
+ // after this power off is issued.
util::powerOff<Shutdown>(bus);
}
catch (std::exception& e)
{
- //No need to crash
+ // No need to crash
log<level::ERR>(e.what());
}
}
-}
-}
+} // namespace power
+} // namespace witherspoon
diff --git a/power-sequencer/runtime_monitor.hpp b/power-sequencer/runtime_monitor.hpp
index fb3dcb1..934aef1 100644
--- a/power-sequencer/runtime_monitor.hpp
+++ b/power-sequencer/runtime_monitor.hpp
@@ -1,10 +1,11 @@
#pragma once
+#include "device.hpp"
+#include "device_monitor.hpp"
+
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server.hpp>
#include <sdeventplus/event.hpp>
-#include "device.hpp"
-#include "device_monitor.hpp"
namespace witherspoon
{
@@ -31,83 +32,76 @@
*/
class RuntimeMonitor : public DeviceMonitor
{
- public:
+ public:
+ RuntimeMonitor() = delete;
+ ~RuntimeMonitor() = default;
+ RuntimeMonitor(const RuntimeMonitor&) = delete;
+ RuntimeMonitor& operator=(const RuntimeMonitor&) = delete;
+ RuntimeMonitor(RuntimeMonitor&&) = delete;
+ RuntimeMonitor& operator=(RuntimeMonitor&&) = delete;
- RuntimeMonitor() = delete;
- ~RuntimeMonitor() = default;
- RuntimeMonitor(const RuntimeMonitor&) = delete;
- RuntimeMonitor& operator=(const RuntimeMonitor&) = delete;
- RuntimeMonitor(RuntimeMonitor&&) = delete;
- RuntimeMonitor& operator=(RuntimeMonitor&&) = delete;
+ /**
+ * Constructor
+ *
+ * @param[in] d - the device to monitor
+ * @param[in] b - D-Bus bus object
+ * @param[in] e - event object
+ * @param[in] i - poll interval
+ */
+ RuntimeMonitor(std::unique_ptr<witherspoon::power::Device>&& d,
+ sdbusplus::bus::bus& b, const sdeventplus::Event& e,
+ std::chrono::milliseconds& i) :
+ DeviceMonitor(std::move(d), e, i),
+ bus(b), match(bus, getMatchString(),
+ std::bind(std::mem_fn(&RuntimeMonitor::onPowerLost), this,
+ std::placeholders::_1))
+ {
+ }
- /**
- * Constructor
- *
- * @param[in] d - the device to monitor
- * @param[in] b - D-Bus bus object
- * @param[in] e - event object
- * @param[in] i - poll interval
- */
- RuntimeMonitor(std::unique_ptr<witherspoon::power::Device>&& d,
- sdbusplus::bus::bus& b,
- const sdeventplus::Event& e,
- std::chrono::milliseconds& i) :
- DeviceMonitor(std::move(d), e, i),
- bus(b),
- match(bus,
- getMatchString(),
- std::bind(std::mem_fn(&RuntimeMonitor::onPowerLost),
- this, std::placeholders::_1))
- {
- }
+ /**
+ * Clears faults and then runs DeviceMonitor::run to
+ * call Device::analyze() on an ongoing interval.
+ *
+ * @return the return value from sd_event_loop()
+ */
+ int run() override;
- /**
- * Clears faults and then runs DeviceMonitor::run to
- * call Device::analyze() on an ongoing interval.
- *
- * @return the return value from sd_event_loop()
- */
- int run() override;
+ private:
+ /**
+ * The PowerLost signal handler.
+ *
+ * After doing an analysis, will issue a power off
+ * as some device has a power fault and needs to be
+ * properly shut down.
+ *
+ * @param[in] msg - D-Bus message for callback
+ */
+ void onPowerLost(sdbusplus::message::message& msg);
- private:
+ /**
+ * Returns the match string for the PowerLost signal
+ */
+ std::string getMatchString()
+ {
+ using namespace sdbusplus::bus::match::rules;
- /**
- * The PowerLost signal handler.
- *
- * After doing an analysis, will issue a power off
- * as some device has a power fault and needs to be
- * properly shut down.
- *
- * @param[in] msg - D-Bus message for callback
- */
- void onPowerLost(sdbusplus::message::message& msg);
+ std::string s = type::signal() + path("/org/openbmc/control/power0") +
+ interface("org.openbmc.control.Power") +
+ member("PowerLost");
- /**
- * Returns the match string for the PowerLost signal
- */
- std::string getMatchString()
- {
- using namespace sdbusplus::bus::match::rules;
+ return s;
+ }
- std::string s =
- type::signal() +
- path("/org/openbmc/control/power0") +
- interface("org.openbmc.control.Power") +
- member("PowerLost");
+ /**
+ * The D-Bus object
+ */
+ sdbusplus::bus::bus& bus;
- return s;
- }
-
- /**
- * The D-Bus object
- */
- sdbusplus::bus::bus& bus;
-
- /**
- * Match object for PowerLost signals
- */
- sdbusplus::bus::match_t match;
+ /**
+ * Match object for PowerLost signals
+ */
+ sdbusplus::bus::match_t match;
};
-}
-}
+} // namespace power
+} // namespace witherspoon
diff --git a/power-sequencer/types.hpp b/power-sequencer/types.hpp
index c473828..fcb30e3 100644
--- a/power-sequencer/types.hpp
+++ b/power-sequencer/types.hpp
@@ -34,8 +34,8 @@
*/
enum class optionFlags
{
- none = 0,
- shutdownOnFault = 1
+ none = 0,
+ shutdownOnFault = 1
};
constexpr auto gpioNumField = 0;
@@ -51,8 +51,8 @@
using ErrorFunction = std::function<void(UCD90160&, const std::string&)>;
-using GPIOGroup = std::tuple<
- std::string, gpio::Value, ErrorFunction, optionFlags, GPIODefinitions>;
+using GPIOGroup = std::tuple<std::string, gpio::Value, ErrorFunction,
+ optionFlags, GPIODefinitions>;
using GPIOAnalysis = std::map<extraAnalysisType, GPIOGroup>;
@@ -62,8 +62,8 @@
constexpr auto pollField = 3;
constexpr auto extraAnalysisField = 4;
-using GPIConfig = std::tuple<
- size_t, size_t, std::string, bool, extraAnalysisType>;
+using GPIConfig =
+ std::tuple<size_t, size_t, std::string, bool, extraAnalysisType>;
using GPIConfigs = std::vector<GPIConfig>;
@@ -74,12 +74,12 @@
constexpr auto gpiConfigField = 2;
constexpr auto gpioAnalysisField = 3;
-using DeviceDefinition = std::tuple<
- std::string, RailNames, GPIConfigs, GPIOAnalysis>;
+using DeviceDefinition =
+ std::tuple<std::string, RailNames, GPIConfigs, GPIOAnalysis>;
-//Maps a device instance to its definition
+// Maps a device instance to its definition
using DeviceMap = std::map<size_t, DeviceDefinition>;
-}
-}
-}
+} // namespace ucd90160
+} // namespace power
+} // namespace witherspoon
diff --git a/power-sequencer/ucd90160.cpp b/power-sequencer/ucd90160.cpp
index bc1177c..08b8a7d 100644
--- a/power-sequencer/ucd90160.cpp
+++ b/power-sequencer/ucd90160.cpp
@@ -13,16 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "ucd90160.hpp"
+
+#include "names_values.hpp"
+#include "utility.hpp"
+
+#include <elog-errors.hpp>
#include <map>
#include <memory>
+#include <org/open_power/Witherspoon/Fault/error.hpp>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
-#include <elog-errors.hpp>
-#include <org/open_power/Witherspoon/Fault/error.hpp>
#include <xyz/openbmc_project/Common/Device/error.hpp>
-#include "names_values.hpp"
-#include "ucd90160.hpp"
-#include "utility.hpp"
namespace witherspoon
{
@@ -44,19 +46,14 @@
using namespace pmbus;
using namespace phosphor::logging;
-namespace device_error = sdbusplus::xyz::openbmc_project::
- Common::Device::Error;
-namespace power_error = sdbusplus::org::open_power::
- Witherspoon::Fault::Error;
+namespace device_error = sdbusplus::xyz::openbmc_project::Common::Device::Error;
+namespace power_error = sdbusplus::org::open_power::Witherspoon::Fault::Error;
UCD90160::UCD90160(size_t instance, sdbusplus::bus::bus& bus) :
- Device(DEVICE_NAME, instance),
- interface(std::get<ucd90160::pathField>(
- deviceMap.find(instance)->second),
- DRIVER_NAME,
- instance),
- gpioDevice(findGPIODevice(interface.path())),
- bus(bus)
+ Device(DEVICE_NAME, instance),
+ interface(std::get<ucd90160::pathField>(deviceMap.find(instance)->second),
+ DRIVER_NAME, instance),
+ gpioDevice(findGPIODevice(interface.path())), bus(bus)
{
}
@@ -68,8 +65,8 @@
auto pgoodError = checkPGOODFaults(false);
- //Not a voltage or PGOOD fault, but we know something
- //failed so still create an error log.
+ // Not a voltage or PGOOD fault, but we know something
+ // failed so still create an error log.
if (!voutError && !pgoodError)
{
createPowerFaultLog();
@@ -89,8 +86,8 @@
{
try
{
- //Note: Voltage faults are always fatal, so they just
- //need to be analyzed in onFailure().
+ // Note: Voltage faults are always fatal, so they just
+ // need to be analyzed in onFailure().
checkPGOODFaults(true);
}
@@ -119,8 +116,8 @@
bool errorCreated = false;
auto statusWord = readStatusWord();
- //The status_word register has a summary bit to tell us
- //if each page even needs to be checked
+ // The status_word register has a summary bit to tell us
+ // if each page even needs to be checked
if (!(statusWord & status_word::VOUT_FAULT))
{
return errorCreated;
@@ -136,20 +133,20 @@
auto statusVout = interface.insertPageNum(STATUS_VOUT, page);
uint8_t vout = interface.read(statusVout, Type::Debug);
- //If any bits are on log them, though some are just
- //warnings so they won't cause errors
+ // If any bits are on log them, though some are just
+ // warnings so they won't cause errors
if (vout)
{
log<level::INFO>("A voltage rail has bits on in STATUS_VOUT",
- entry("STATUS_VOUT=0x%X", vout),
- entry("PAGE=%d", page));
+ entry("STATUS_VOUT=0x%X", vout),
+ entry("PAGE=%d", page));
}
- //Log errors if any non-warning bits on
+ // Log errors if any non-warning bits on
if (vout & ~status_vout::WARNING_MASK)
{
auto& railNames = std::get<ucd90160::railNamesField>(
- deviceMap.find(getInstance())->second);
+ deviceMap.find(getInstance())->second);
auto railName = railNames.at(page);
util::NamesValues nv;
@@ -165,13 +162,12 @@
commit<device_error::ReadFailure>();
}
- using metadata = org::open_power::Witherspoon::Fault::
- PowerSequencerVoltageFault;
+ using metadata =
+ org::open_power::Witherspoon::Fault::PowerSequencerVoltageFault;
report<power_error::PowerSequencerVoltageFault>(
- metadata::RAIL(page),
- metadata::RAIL_NAME(railName.c_str()),
- metadata::RAW_STATUS(nv.get().c_str()));
+ metadata::RAIL(page), metadata::RAIL_NAME(railName.c_str()),
+ metadata::RAW_STATUS(nv.get().c_str()));
setVoutFaultLogged(page);
errorCreated = true;
@@ -185,43 +181,41 @@
{
bool errorCreated = false;
- //While PGOOD faults could show up in MFR_STATUS (and we could then
- //check the summary bit in STATUS_WORD first), they are edge triggered,
- //and as the device driver sends a clear faults command every time we
- //do a read, we will never see them. So, we'll have to just read the
- //real time GPI status GPIO.
+ // While PGOOD faults could show up in MFR_STATUS (and we could then
+ // check the summary bit in STATUS_WORD first), they are edge triggered,
+ // and as the device driver sends a clear faults command every time we
+ // do a read, we will never see them. So, we'll have to just read the
+ // real time GPI status GPIO.
- //Check only the GPIs configured on this system.
+ // Check only the GPIs configured on this system.
auto& gpiConfigs = std::get<ucd90160::gpiConfigField>(
- deviceMap.find(getInstance())->second);
+ deviceMap.find(getInstance())->second);
for (const auto& gpiConfig : gpiConfigs)
{
auto gpiNum = std::get<ucd90160::gpiNumField>(gpiConfig);
auto doPoll = std::get<ucd90160::pollField>(gpiConfig);
- //Can skip this one if there is already an error on this input,
- //or we are polling and these inputs don't need to be polled
+ // Can skip this one if there is already an error on this input,
+ // or we are polling and these inputs don't need to be polled
//(because errors on them are fatal).
if (isPGOODFaultLogged(gpiNum) || (polling && !doPoll))
{
continue;
}
- //The real time status is read via the pin ID
+ // The real time status is read via the pin ID
auto pinID = std::get<ucd90160::pinIDField>(gpiConfig);
auto gpio = gpios.find(pinID);
Value gpiStatus;
try
{
- //The first time through, create the GPIO objects
+ // The first time through, create the GPIO objects
if (gpio == gpios.end())
{
- gpios.emplace(
- pinID,
- std::make_unique<GPIO>(
- gpioDevice, pinID, Direction::input));
+ gpios.emplace(pinID, std::make_unique<GPIO>(gpioDevice, pinID,
+ Direction::input));
gpio = gpios.find(pinID);
}
@@ -239,9 +233,9 @@
if (gpiStatus == Value::low)
{
- //There may be some extra analysis we can do to narrow the
- //error down further. Note that finding an error here won't
- //prevent us from checking this GPI again.
+ // There may be some extra analysis we can do to narrow the
+ // error down further. Note that finding an error here won't
+ // prevent us from checking this GPI again.
errorCreated = doExtraAnalysis(gpiConfig);
if (errorCreated)
@@ -266,13 +260,13 @@
commit<device_error::ReadFailure>();
}
- using metadata = org::open_power::Witherspoon::Fault::
- PowerSequencerPGOODFault;
+ using metadata =
+ org::open_power::Witherspoon::Fault::PowerSequencerPGOODFault;
report<power_error::PowerSequencerPGOODFault>(
- metadata::INPUT_NUM(gpiNum),
- metadata::INPUT_NAME(gpiName.c_str()),
- metadata::RAW_STATUS(nv.get().c_str()));
+ metadata::INPUT_NUM(gpiNum),
+ metadata::INPUT_NAME(gpiName.c_str()),
+ metadata::RAW_STATUS(nv.get().c_str()));
setPGOODFaultLogged(gpiNum);
errorCreated = true;
@@ -297,26 +291,25 @@
commit<device_error::ReadFailure>();
}
- using metadata = org::open_power::Witherspoon::Fault::
- PowerSequencerFault;
+ using metadata = org::open_power::Witherspoon::Fault::PowerSequencerFault;
report<power_error::PowerSequencerFault>(
- metadata::RAW_STATUS(nv.get().c_str()));
+ metadata::RAW_STATUS(nv.get().c_str()));
}
fs::path UCD90160::findGPIODevice(const fs::path& path)
{
fs::path gpioDevicePath;
- //In the driver directory, look for a subdirectory
- //named gpiochipX, where X is some number. Then
- //we'll access the GPIO at /dev/gpiochipX.
+ // In the driver directory, look for a subdirectory
+ // named gpiochipX, where X is some number. Then
+ // we'll access the GPIO at /dev/gpiochipX.
if (fs::is_directory(path))
{
for (auto& f : fs::directory_iterator(path))
{
if (f.path().filename().string().find("gpiochip") !=
- std::string::npos)
+ std::string::npos)
{
gpioDevicePath = "/dev" / f.path().filename();
break;
@@ -327,7 +320,7 @@
if (gpioDevicePath.empty())
{
log<level::ERR>("Could not find GPIO device path",
- entry("BASE_PATH=%s", path.c_str()));
+ entry("BASE_PATH=%s", path.c_str()));
}
return gpioDevicePath;
@@ -342,7 +335,7 @@
return false;
}
- //Currently the only extra analysis to do is to check other GPIOs.
+ // Currently the only extra analysis to do is to check other GPIOs.
return doGPIOAnalysis(type);
}
@@ -352,7 +345,7 @@
bool shutdown = false;
const auto& analysisConfig = std::get<ucd90160::gpioAnalysisField>(
- deviceMap.find(getInstance())->second);
+ deviceMap.find(getInstance())->second);
auto gpioConfig = analysisConfig.find(type);
if (gpioConfig == analysisConfig.end())
@@ -360,19 +353,16 @@
return errorFound;
}
- auto path = std::get<ucd90160::gpioDevicePathField>(
- gpioConfig->second);
+ auto path = std::get<ucd90160::gpioDevicePathField>(gpioConfig->second);
- //The /dev/gpiochipX device
+ // The /dev/gpiochipX device
auto device = findGPIODevice(path);
- //The GPIO value of the fault condition
- auto polarity = std::get<ucd90160::gpioPolarityField>(
- gpioConfig->second);
+ // The GPIO value of the fault condition
+ auto polarity = std::get<ucd90160::gpioPolarityField>(gpioConfig->second);
- //The GPIOs to check
- auto& gpios = std::get<ucd90160::gpioDefinitionField>(
- gpioConfig->second);
+ // The GPIOs to check
+ auto& gpios = std::get<ucd90160::gpioDefinitionField>(gpioConfig->second);
for (const auto& gpio : gpios)
{
@@ -380,8 +370,7 @@
try
{
- GPIO g{device,
- std::get<ucd90160::gpioNumField>(gpio),
+ GPIO g{device, std::get<ucd90160::gpioNumField>(gpio),
Direction::input};
value = g.read();
@@ -390,10 +379,10 @@
{
if (!gpioAccessError)
{
- //GPIO only throws InternalErrors - not worth committing.
+ // GPIO only throws InternalErrors - not worth committing.
log<level::ERR>(
- "GPIO read failed while analyzing a power fault",
- entry("CHIP_PATH=%s", path.c_str()));
+ "GPIO read failed while analyzing a power fault",
+ entry("CHIP_PATH=%s", path.c_str()));
gpioAccessError = true;
}
@@ -413,21 +402,21 @@
continue;
}
- //Look up and call the error creation function
- auto logError = std::get<ucd90160::errorFunctionField>(
- gpioConfig->second);
+ // Look up and call the error creation function
+ auto logError =
+ std::get<ucd90160::errorFunctionField>(gpioConfig->second);
logError(*this, part);
- //Save the part callout so we don't call it out again
+ // Save the part callout so we don't call it out again
setPartCallout(callout);
- //Some errors (like overtemps) require a shutdown
+ // Some errors (like overtemps) require a shutdown
auto actions = static_cast<uint32_t>(
- std::get<ucd90160::optionFlagsField>(gpioConfig->second));
+ std::get<ucd90160::optionFlagsField>(gpioConfig->second));
if (actions & static_cast<decltype(actions)>(
- ucd90160::optionFlags::shutdownOnFault))
+ ucd90160::optionFlags::shutdownOnFault))
{
shutdown = true;
}
@@ -436,7 +425,7 @@
if (shutdown)
{
- //Will be replaced with a GPU specific error in a future commit
+ // Will be replaced with a GPU specific error in a future commit
util::powerOff<power_error::Shutdown>(bus);
}
@@ -461,8 +450,8 @@
using metadata = org::open_power::Witherspoon::Fault::GPUPowerFault;
report<power_error::GPUPowerFault>(
- metadata::RAW_STATUS(nv.get().c_str()),
- metadata::CALLOUT_INVENTORY_PATH(callout.c_str()));
+ metadata::RAW_STATUS(nv.get().c_str()),
+ metadata::CALLOUT_INVENTORY_PATH(callout.c_str()));
}
void UCD90160::gpuOverTempError(const std::string& callout)
@@ -483,9 +472,9 @@
using metadata = org::open_power::Witherspoon::Fault::GPUOverTemp;
report<power_error::GPUOverTemp>(
- metadata::RAW_STATUS(nv.get().c_str()),
- metadata::CALLOUT_INVENTORY_PATH(callout.c_str()));
+ metadata::RAW_STATUS(nv.get().c_str()),
+ metadata::CALLOUT_INVENTORY_PATH(callout.c_str()));
}
-}
-}
+} // namespace power
+} // namespace witherspoon
diff --git a/power-sequencer/ucd90160.hpp b/power-sequencer/ucd90160.hpp
index f14a99e..6213c26 100644
--- a/power-sequencer/ucd90160.hpp
+++ b/power-sequencer/ucd90160.hpp
@@ -1,23 +1,23 @@
#pragma once
+#include "device.hpp"
+#include "gpio.hpp"
+#include "pmbus.hpp"
+#include "types.hpp"
+
#include <algorithm>
#include <experimental/filesystem>
#include <map>
#include <sdbusplus/bus.hpp>
#include <vector>
-#include "device.hpp"
-#include "gpio.hpp"
-#include "pmbus.hpp"
-#include "types.hpp"
namespace witherspoon
{
namespace power
{
-//Error type, callout
-using PartCallout =
- std::tuple<ucd90160::extraAnalysisType, std::string>;
+// Error type, callout
+using PartCallout = std::tuple<ucd90160::extraAnalysisType, std::string>;
/**
* @class UCD90160
@@ -28,284 +28,279 @@
*/
class UCD90160 : public Device
{
- public:
+ public:
+ UCD90160() = delete;
+ ~UCD90160() = default;
+ UCD90160(const UCD90160&) = delete;
+ UCD90160& operator=(const UCD90160&) = delete;
+ UCD90160(UCD90160&&) = default;
+ UCD90160& operator=(UCD90160&&) = default;
- UCD90160() = delete;
- ~UCD90160() = default;
- UCD90160(const UCD90160&) = delete;
- UCD90160& operator=(const UCD90160&) = delete;
- UCD90160(UCD90160&&) = default;
- UCD90160& operator=(UCD90160&&) = default;
+ /**
+ * Constructor
+ *
+ * @param[in] instance - the device instance number
+ * @param[in] bus - D-Bus bus object
+ */
+ UCD90160(size_t instance, sdbusplus::bus::bus& bus);
- /**
- * Constructor
- *
- * @param[in] instance - the device instance number
- * @param[in] bus - D-Bus bus object
- */
- UCD90160(size_t instance, sdbusplus::bus::bus& bus);
+ /**
+ * Analyzes the device for errors when the device is
+ * known to be in an error state. A log will be created.
+ */
+ void onFailure() override;
- /**
- * Analyzes the device for errors when the device is
- * known to be in an error state. A log will be created.
- */
- void onFailure() override;
+ /**
+ * Checks the device for errors and only creates a log
+ * if one is found.
+ */
+ void analyze() override;
- /**
- * Checks the device for errors and only creates a log
- * if one is found.
- */
- void analyze() override;
+ /**
+ * Clears faults in the device
+ */
+ void clearFaults() override
+ {
+ }
- /**
- * Clears faults in the device
- */
- void clearFaults() override
- {
- }
+ private:
+ /**
+ * Reports an error for a GPU PGOOD failure
+ *
+ * @param[in] callout - the GPU callout string
+ */
+ void gpuPGOODError(const std::string& callout);
- private:
+ /**
+ * Reports an error for a GPU OverTemp failure
+ *
+ * @param[in] callout - the GPU callout string
+ */
+ void gpuOverTempError(const std::string& callout);
- /**
- * Reports an error for a GPU PGOOD failure
- *
- * @param[in] callout - the GPU callout string
- */
- void gpuPGOODError(const std::string& callout);
+ /**
+ * Given the device path for a chip, find its gpiochip
+ * path
+ *
+ * @param[in] path - device path, like
+ * /sys/devices/.../i2c-11/11-0064
+ *
+ * @return fs::path - The gpiochip path, like
+ * /dev/gpiochip1
+ */
+ static std::experimental::filesystem::path
+ findGPIODevice(const std::experimental::filesystem::path& path);
- /**
- * Reports an error for a GPU OverTemp failure
- *
- * @param[in] callout - the GPU callout string
- */
- void gpuOverTempError(const std::string& callout);
+ /**
+ * Checks for VOUT faults on the device.
+ *
+ * This device can monitor voltages of its dependent
+ * devices, and VOUT faults are voltage faults
+ * on these devices.
+ *
+ * @return bool - true if an error log was created
+ */
+ bool checkVOUTFaults();
- /**
- * Given the device path for a chip, find its gpiochip
- * path
- *
- * @param[in] path - device path, like
- * /sys/devices/.../i2c-11/11-0064
- *
- * @return fs::path - The gpiochip path, like
- * /dev/gpiochip1
- */
- static std::experimental::filesystem::path findGPIODevice(
- const std::experimental::filesystem::path& path);
+ /**
+ * Checks for PGOOD faults on the device.
+ *
+ * This device can monitor the PGOOD signals of its dependent
+ * devices, and this check will look for faults of
+ * those PGOODs.
+ *
+ * @param[in] polling - If this is running while polling for errors,
+ * as opposing to analyzing a fail condition.
+ *
+ * @return bool - true if an error log was created
+ */
+ bool checkPGOODFaults(bool polling);
- /**
- * Checks for VOUT faults on the device.
- *
- * This device can monitor voltages of its dependent
- * devices, and VOUT faults are voltage faults
- * on these devices.
- *
- * @return bool - true if an error log was created
- */
- bool checkVOUTFaults();
+ /**
+ * Creates an error log when the device has an error
+ * but it isn't a PGOOD or voltage failure.
+ */
+ void createPowerFaultLog();
- /**
- * Checks for PGOOD faults on the device.
- *
- * This device can monitor the PGOOD signals of its dependent
- * devices, and this check will look for faults of
- * those PGOODs.
- *
- * @param[in] polling - If this is running while polling for errors,
- * as opposing to analyzing a fail condition.
- *
- * @return bool - true if an error log was created
- */
- bool checkPGOODFaults(bool polling);
+ /**
+ * Reads the status_word register
+ *
+ * @return uint16_t - the register contents
+ */
+ uint16_t readStatusWord();
- /**
- * Creates an error log when the device has an error
- * but it isn't a PGOOD or voltage failure.
- */
- void createPowerFaultLog();
+ /**
+ * Reads the mfr_status register
+ *
+ * @return uint32_t - the register contents
+ */
+ uint32_t readMFRStatus();
- /**
- * Reads the status_word register
- *
- * @return uint16_t - the register contents
- */
- uint16_t readStatusWord();
+ /**
+ * Does any additional fault analysis based on the
+ * value of the extraAnalysisType field in the GPIOConfig
+ * entry.
+ *
+ * Used to get better callouts.
+ *
+ * @param[in] config - the GPIOConfig entry to use
+ *
+ * @return bool - true if a HW error was found, false else
+ */
+ bool doExtraAnalysis(const ucd90160::GPIConfig& config);
- /**
- * Reads the mfr_status register
- *
- * @return uint32_t - the register contents
- */
- uint32_t readMFRStatus();
+ /**
+ * Does additional fault analysis using GPIOs to
+ * specifically identify the failing part.
+ *
+ * Used when there are too many PGOOD inputs for
+ * the UCD90160 to handle, so just a summary bit
+ * is wired into the chip, and then the specific
+ * fault GPIOs are off of a different GPIO device,
+ * like an IO expander.
+ *
+ * @param[in] type - the type of analysis to do
+ *
+ * @return bool - true if a HW error was found, false else
+ */
+ bool doGPIOAnalysis(ucd90160::extraAnalysisType type);
- /**
- * Does any additional fault analysis based on the
- * value of the extraAnalysisType field in the GPIOConfig
- * entry.
- *
- * Used to get better callouts.
- *
- * @param[in] config - the GPIOConfig entry to use
- *
- * @return bool - true if a HW error was found, false else
- */
- bool doExtraAnalysis(const ucd90160::GPIConfig& config);
+ /**
+ * Says if we've already logged a Vout fault
+ *
+ * The policy is only 1 of the same error will
+ * be logged for the duration of a class instance.
+ *
+ * @param[in] page - the page to check
+ *
+ * @return bool - if we've already logged a fault against
+ * this page
+ */
+ inline bool isVoutFaultLogged(uint32_t page) const
+ {
+ return std::find(voutErrors.begin(), voutErrors.end(), page) !=
+ voutErrors.end();
+ }
- /**
- * Does additional fault analysis using GPIOs to
- * specifically identify the failing part.
- *
- * Used when there are too many PGOOD inputs for
- * the UCD90160 to handle, so just a summary bit
- * is wired into the chip, and then the specific
- * fault GPIOs are off of a different GPIO device,
- * like an IO expander.
- *
- * @param[in] type - the type of analysis to do
- *
- * @return bool - true if a HW error was found, false else
- */
- bool doGPIOAnalysis(ucd90160::extraAnalysisType type);
+ /**
+ * Saves that a Vout fault has been logged
+ *
+ * @param[in] page - the page the error was logged against
+ */
+ inline void setVoutFaultLogged(uint32_t page)
+ {
+ voutErrors.push_back(page);
+ }
- /**
- * Says if we've already logged a Vout fault
- *
- * The policy is only 1 of the same error will
- * be logged for the duration of a class instance.
- *
- * @param[in] page - the page to check
- *
- * @return bool - if we've already logged a fault against
- * this page
- */
- inline bool isVoutFaultLogged(uint32_t page) const
- {
- return std::find(voutErrors.begin(),
- voutErrors.end(),
- page) != voutErrors.end();
- }
+ /**
+ * Says if we've already logged a PGOOD fault
+ *
+ * The policy is only 1 of the same errors will
+ * be logged for the duration of a class instance.
+ *
+ * @param[in] input - the input to check
+ *
+ * @return bool - if we've already logged a fault against
+ * this input
+ */
+ inline bool isPGOODFaultLogged(uint32_t input) const
+ {
+ return std::find(pgoodErrors.begin(), pgoodErrors.end(), input) !=
+ pgoodErrors.end();
+ }
- /**
- * Saves that a Vout fault has been logged
- *
- * @param[in] page - the page the error was logged against
- */
- inline void setVoutFaultLogged(uint32_t page)
- {
- voutErrors.push_back(page);
- }
+ /**
+ * Says if we've already logged a specific fault
+ * against a specific part
+ *
+ * @param[in] callout - error type and name tuple
+ *
+ * @return bool - if we've already logged this fault
+ * against this part
+ */
+ inline bool isPartCalledOut(const PartCallout& callout) const
+ {
+ return std::find(callouts.begin(), callouts.end(), callout) !=
+ callouts.end();
+ }
- /**
- * Says if we've already logged a PGOOD fault
- *
- * The policy is only 1 of the same errors will
- * be logged for the duration of a class instance.
- *
- * @param[in] input - the input to check
- *
- * @return bool - if we've already logged a fault against
- * this input
- */
- inline bool isPGOODFaultLogged(uint32_t input) const
- {
- return std::find(pgoodErrors.begin(),
- pgoodErrors.end(),
- input) != pgoodErrors.end();
- }
+ /**
+ * Saves that a PGOOD fault has been logged
+ *
+ * @param[in] input - the input the error was logged against
+ */
+ inline void setPGOODFaultLogged(uint32_t input)
+ {
+ pgoodErrors.push_back(input);
+ }
- /**
- * Says if we've already logged a specific fault
- * against a specific part
- *
- * @param[in] callout - error type and name tuple
- *
- * @return bool - if we've already logged this fault
- * against this part
- */
- inline bool isPartCalledOut(const PartCallout& callout) const
- {
- return std::find(callouts.begin(),
- callouts.end(),
- callout) != callouts.end();
- }
+ /**
+ * Saves that a specific fault on a specific part has been done
+ *
+ * @param[in] callout - error type and name tuple
+ */
+ inline void setPartCallout(const PartCallout& callout)
+ {
+ callouts.push_back(callout);
+ }
- /**
- * Saves that a PGOOD fault has been logged
- *
- * @param[in] input - the input the error was logged against
- */
- inline void setPGOODFaultLogged(uint32_t input)
- {
- pgoodErrors.push_back(input);
- }
+ /**
+ * List of pages that Vout errors have
+ * already been logged against
+ */
+ std::vector<uint32_t> voutErrors;
- /**
- * Saves that a specific fault on a specific part has been done
- *
- * @param[in] callout - error type and name tuple
- */
- inline void setPartCallout(const PartCallout& callout)
- {
- callouts.push_back(callout);
- }
+ /**
+ * List of inputs that PGOOD errors have
+ * already been logged against
+ */
+ std::vector<uint32_t> pgoodErrors;
- /**
- * List of pages that Vout errors have
- * already been logged against
- */
- std::vector<uint32_t> voutErrors;
+ /**
+ * List of callouts that already been done
+ */
+ std::vector<PartCallout> callouts;
- /**
- * List of inputs that PGOOD errors have
- * already been logged against
- */
- std::vector<uint32_t> pgoodErrors;
+ /**
+ * The read/write interface to this hardware
+ */
+ pmbus::PMBus interface;
- /**
- * List of callouts that already been done
- */
- std::vector<PartCallout> callouts;
+ /**
+ * A map of GPI pin IDs to the GPIO object
+ * used to access them
+ */
+ std::map<size_t, std::unique_ptr<gpio::GPIO>> gpios;
- /**
- * The read/write interface to this hardware
- */
- pmbus::PMBus interface;
+ /**
+ * Keeps track of device access errors to avoid repeatedly
+ * logging errors for bad hardware
+ */
+ bool accessError = false;
- /**
- * A map of GPI pin IDs to the GPIO object
- * used to access them
- */
- std::map<size_t, std::unique_ptr<gpio::GPIO>> gpios;
+ /**
+ * Keeps track of GPIO access errors when doing the in depth
+ * PGOOD fault analysis to avoid repeatedly logging errors
+ * for bad hardware
+ */
+ bool gpioAccessError = false;
- /**
- * Keeps track of device access errors to avoid repeatedly
- * logging errors for bad hardware
- */
- bool accessError = false;
+ /**
+ * The path to the GPIO device used to read
+ * the GPI (PGOOD) status
+ */
+ std::experimental::filesystem::path gpioDevice;
- /**
- * Keeps track of GPIO access errors when doing the in depth
- * PGOOD fault analysis to avoid repeatedly logging errors
- * for bad hardware
- */
- bool gpioAccessError = false;
+ /**
+ * The D-Bus bus object
+ */
+ sdbusplus::bus::bus& bus;
- /**
- * The path to the GPIO device used to read
- * the GPI (PGOOD) status
- */
- std::experimental::filesystem::path gpioDevice;
-
- /**
- * The D-Bus bus object
- */
- sdbusplus::bus::bus& bus;
-
- /**
- * Map of device instance to the instance specific data
- */
- static const ucd90160::DeviceMap deviceMap;
+ /**
+ * Map of device instance to the instance specific data
+ */
+ static const ucd90160::DeviceMap deviceMap;
};
-}
-}
+} // namespace power
+} // namespace witherspoon
diff --git a/power-sequencer/ucd90160_defs.cpp b/power-sequencer/ucd90160_defs.cpp
index 5696061..d271f4b 100644
--- a/power-sequencer/ucd90160_defs.cpp
+++ b/power-sequencer/ucd90160_defs.cpp
@@ -15,7 +15,7 @@
*/
#include "ucd90160.hpp"
-//Separated out to facilitate possible future generation of file.
+// Separated out to facilitate possible future generation of file.
namespace witherspoon
{
@@ -25,96 +25,71 @@
using namespace ucd90160;
using namespace std::string_literals;
-const DeviceMap UCD90160::deviceMap
-{
- {0, DeviceDefinition{
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/"
- "1e78a400.i2c-bus/i2c-11/11-0064",
+const DeviceMap UCD90160::deviceMap{
+ {0,
+ DeviceDefinition{
+ "/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/"
+ "1e78a400.i2c-bus/i2c-11/11-0064",
- RailNames{
- "5.0VCS"s,
- "12.0V"s,
- "3.3V"s,
- "1.8V"s,
- "1.1V"s,
- "1.0V"s,
- "0.9V"s,
- "VDN-A"s,
- "VDN-B"s,
- "AVDD"s,
- "VIO-A"s,
- "VIO-B"s,
- "VDD-A"s,
- "VDD-B"s,
- "VCS-A"s,
- "VCS-B"s
- },
+ RailNames{"5.0VCS"s, "12.0V"s, "3.3V"s, "1.8V"s, "1.1V"s, "1.0V"s,
+ "0.9V"s, "VDN-A"s, "VDN-B"s, "AVDD"s, "VIO-A"s, "VIO-B"s,
+ "VDD-A"s, "VDD-B"s, "VCS-A"s, "VCS-B"s},
- GPIConfigs{
- GPIConfig{1, 8, "PGOOD_5P0V"s, false,
- extraAnalysisType::none},
- GPIConfig{2, 9, "MEM_GOOD0"s, false,
- extraAnalysisType::none},
- GPIConfig{3, 10, "MEM_GOOD1"s, false,
- extraAnalysisType::none},
- GPIConfig{4, 14, "GPU_PGOOD"s, false,
- extraAnalysisType::gpuPGOOD},
- GPIConfig{5, 17, "GPU_TH_OVERT"s, true,
- extraAnalysisType::gpuOverTemp},
- GPIConfig{6, 11, "SOFTWARE_PGOOD"s, false,
- extraAnalysisType::none}
- },
+ GPIConfigs{
+ GPIConfig{1, 8, "PGOOD_5P0V"s, false, extraAnalysisType::none},
+ GPIConfig{2, 9, "MEM_GOOD0"s, false, extraAnalysisType::none},
+ GPIConfig{3, 10, "MEM_GOOD1"s, false, extraAnalysisType::none},
+ GPIConfig{4, 14, "GPU_PGOOD"s, false, extraAnalysisType::gpuPGOOD},
+ GPIConfig{5, 17, "GPU_TH_OVERT"s, true,
+ extraAnalysisType::gpuOverTemp},
+ GPIConfig{6, 11, "SOFTWARE_PGOOD"s, false,
+ extraAnalysisType::none}},
- GPIOAnalysis{
- {extraAnalysisType::gpuPGOOD,
- GPIOGroup{
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@"
- "1e78a000/1e78a400.i2c-bus/i2c-11/11-0060",
- gpio::Value::low,
- [](auto& ucd, const auto& callout)
- { ucd.gpuPGOODError(callout); },
- optionFlags::none,
- GPIODefinitions{
- GPIODefinition{8,
- "/system/chassis/motherboard/gv100card0"s},
- GPIODefinition{9,
- "/system/chassis/motherboard/gv100card1"s},
- GPIODefinition{10,
- "/system/chassis/motherboard/gv100card2"s},
- GPIODefinition{11,
- "/system/chassis/motherboard/gv100card3"s},
- GPIODefinition{12,
- "/system/chassis/motherboard/gv100card4"s},
- GPIODefinition{13,
- "/system/chassis/motherboard/gv100card5"s}}
- }},
+ GPIOAnalysis{
+ {extraAnalysisType::gpuPGOOD,
+ GPIOGroup{
+ "/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@"
+ "1e78a000/1e78a400.i2c-bus/i2c-11/11-0060",
+ gpio::Value::low,
+ [](auto& ucd, const auto& callout) {
+ ucd.gpuPGOODError(callout);
+ },
+ optionFlags::none,
+ GPIODefinitions{
+ GPIODefinition{8,
+ "/system/chassis/motherboard/gv100card0"s},
+ GPIODefinition{9,
+ "/system/chassis/motherboard/gv100card1"s},
+ GPIODefinition{10,
+ "/system/chassis/motherboard/gv100card2"s},
+ GPIODefinition{11,
+ "/system/chassis/motherboard/gv100card3"s},
+ GPIODefinition{12,
+ "/system/chassis/motherboard/gv100card4"s},
+ GPIODefinition{
+ 13, "/system/chassis/motherboard/gv100card5"s}}}},
- {extraAnalysisType::gpuOverTemp,
- GPIOGroup{
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@"
- "1e78a000/1e78a400.i2c-bus/i2c-11/11-0060",
- gpio::Value::low,
- [](auto& ucd, const auto& callout)
- { ucd.gpuOverTempError(callout); },
- optionFlags::shutdownOnFault,
- GPIODefinitions{
- GPIODefinition{2,
- "/system/chassis/motherboard/gv100card0"s},
- GPIODefinition{3,
- "/system/chassis/motherboard/gv100card1"s},
- GPIODefinition{4,
- "/system/chassis/motherboard/gv100card2"s},
- GPIODefinition{5,
- "/system/chassis/motherboard/gv100card3"s},
- GPIODefinition{6,
- "/system/chassis/motherboard/gv100card4"s},
- GPIODefinition{7,
- "/system/chassis/motherboard/gv100card5"s}}
- }}
- }
- }
- }
-};
+ {extraAnalysisType::gpuOverTemp,
+ GPIOGroup{
+ "/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@"
+ "1e78a000/1e78a400.i2c-bus/i2c-11/11-0060",
+ gpio::Value::low,
+ [](auto& ucd,
+ const auto& callout) { ucd.gpuOverTempError(callout); },
+ optionFlags::shutdownOnFault,
+ GPIODefinitions{
+ GPIODefinition{2,
+ "/system/chassis/motherboard/gv100card0"s},
+ GPIODefinition{3,
+ "/system/chassis/motherboard/gv100card1"s},
+ GPIODefinition{4,
+ "/system/chassis/motherboard/gv100card2"s},
+ GPIODefinition{5,
+ "/system/chassis/motherboard/gv100card3"s},
+ GPIODefinition{6,
+ "/system/chassis/motherboard/gv100card4"s},
+ GPIODefinition{
+ 7, "/system/chassis/motherboard/gv100card5"s}}}}}}}};
-}
-}
+} // namespace power
+} // namespace witherspoon
diff --git a/power-supply/argument.cpp b/power-supply/argument.cpp
index a275c6a..342515c 100644
--- a/power-supply/argument.cpp
+++ b/power-supply/argument.cpp
@@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <iostream>
-#include <iterator>
+#include "argument.hpp"
+
#include <algorithm>
#include <cassert>
-#include "argument.hpp"
+#include <iostream>
+#include <iterator>
namespace witherspoon
{
@@ -81,16 +82,15 @@
std::cerr << std::flush;
}
-const option ArgumentParser::options[] =
-{
- { "path", required_argument, NULL, 'p' },
- { "instance", required_argument, NULL, 'n' },
- { "inventory", required_argument, NULL, 'i' },
- { "num-history-records", required_argument, NULL, 'r' },
- { "sync-gpio-path", required_argument, NULL, 'a' },
- { "sync-gpio-num", required_argument, NULL, 'u' },
- { "help", no_argument, NULL, 'h' },
- { 0, 0, 0, 0},
+const option ArgumentParser::options[] = {
+ {"path", required_argument, NULL, 'p'},
+ {"instance", required_argument, NULL, 'n'},
+ {"inventory", required_argument, NULL, 'i'},
+ {"num-history-records", required_argument, NULL, 'r'},
+ {"sync-gpio-path", required_argument, NULL, 'a'},
+ {"sync-gpio-num", required_argument, NULL, 'u'},
+ {"help", no_argument, NULL, 'h'},
+ {0, 0, 0, 0},
};
const char* ArgumentParser::optionStr = "p:n:i:r:a:u:h";
@@ -98,5 +98,5 @@
const std::string ArgumentParser::trueString = "true";
const std::string ArgumentParser::emptyString = "";
-}
-}
+} // namespace power
+} // namespace witherspoon
diff --git a/power-supply/average.hpp b/power-supply/average.hpp
index 817f0bf..a61a436 100644
--- a/power-supply/average.hpp
+++ b/power-supply/average.hpp
@@ -12,8 +12,8 @@
template <typename T>
using ServerObject = typename sdbusplus::server::object::object<T>;
-using AverageInterface = sdbusplus::org::open_power::
- Sensor::Aggregation::History::server::Average;
+using AverageInterface =
+ sdbusplus::org::open_power::Sensor::Aggregation::History::server::Average;
/**
* @class Average
@@ -25,33 +25,30 @@
*/
class Average : public ServerObject<AverageInterface>
{
- public:
+ public:
+ static constexpr auto name = "average";
- static constexpr auto name = "average";
+ Average() = delete;
+ Average(const Average&) = delete;
+ Average& operator=(const Average&) = delete;
+ Average(Average&&) = delete;
+ Average& operator=(Average&&) = delete;
+ ~Average() = default;
- Average() = delete;
- Average(const Average&) = delete;
- Average& operator=(const Average&) = delete;
- Average(Average&&) = delete;
- Average& operator=(Average&&) = delete;
- ~Average() = default;
-
- /**
- * @brief Constructor
- *
- * @param[in] bus - D-Bus object
- * @param[in] objectPath - the D-Bus object path
- */
- Average(sdbusplus::bus::bus& bus,
- const std::string& objectPath) :
- ServerObject<AverageInterface>(bus, objectPath.c_str())
- {
- unit(Average::Unit::Watts);
- scale(0);
- }
+ /**
+ * @brief Constructor
+ *
+ * @param[in] bus - D-Bus object
+ * @param[in] objectPath - the D-Bus object path
+ */
+ Average(sdbusplus::bus::bus& bus, const std::string& objectPath) :
+ ServerObject<AverageInterface>(bus, objectPath.c_str())
+ {
+ unit(Average::Unit::Watts);
+ scale(0);
+ }
};
-
-}
-}
-}
+} // namespace history
+} // namespace power
+} // namespace witherspoon
diff --git a/power-supply/main.cpp b/power-supply/main.cpp
index 62249c5..93b4b77 100644
--- a/power-supply/main.cpp
+++ b/power-supply/main.cpp
@@ -13,13 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "config.h"
+
+#include "argument.hpp"
+#include "device_monitor.hpp"
+#include "power_supply.hpp"
+
#include <iostream>
#include <phosphor-logging/log.hpp>
#include <sdeventplus/event.hpp>
-#include "argument.hpp"
-#include "config.h"
-#include "power_supply.hpp"
-#include "device_monitor.hpp"
using namespace witherspoon::power;
using namespace phosphor::logging;
@@ -78,14 +80,9 @@
// Timer to delay setting internal presence tracking. Allows for servicing
// the power supply.
std::chrono::seconds presentDelay(2);
- auto psuDevice = std::make_unique<psu::PowerSupply>(objname,
- std::move(instance),
- std::move(objpath),
- std::move(invpath),
- bus,
- event,
- powerOnDelay,
- presentDelay);
+ auto psuDevice = std::make_unique<psu::PowerSupply>(
+ objname, std::move(instance), std::move(objpath), std::move(invpath),
+ bus, event, powerOnDelay, presentDelay);
// Get the number of input power history records to keep in D-Bus.
long int numRecords = 0;
@@ -108,9 +105,9 @@
auto syncGPIONum = (options)["sync-gpio-num"];
if (((syncGPIOPath == ArgumentParser::emptyString) &&
- (syncGPIONum != ArgumentParser::emptyString)) ||
+ (syncGPIONum != ArgumentParser::emptyString)) ||
((syncGPIOPath != ArgumentParser::emptyString) &&
- (syncGPIONum == ArgumentParser::emptyString)))
+ (syncGPIONum == ArgumentParser::emptyString)))
{
std::cerr << "Invalid sync GPIO number or path\n";
return -7;
@@ -126,16 +123,13 @@
std::string basePath =
std::string{INPUT_HISTORY_SENSOR_ROOT} + '/' + name;
- psuDevice->enableHistory(basePath,
- numRecords,
- syncGPIOPath,
- gpioNum);
+ psuDevice->enableHistory(basePath, numRecords, syncGPIOPath, gpioNum);
// Systemd object manager
sdbusplus::server::manager::manager objManager{bus, basePath.c_str()};
std::string busName =
- std::string{INPUT_HISTORY_BUSNAME_ROOT} + '.' + name;
+ std::string{INPUT_HISTORY_BUSNAME_ROOT} + '.' + name;
bus.request_name(busName.c_str());
}
diff --git a/power-supply/maximum.hpp b/power-supply/maximum.hpp
index e1fbffc..d952d2b 100644
--- a/power-supply/maximum.hpp
+++ b/power-supply/maximum.hpp
@@ -12,8 +12,8 @@
template <typename T>
using ServerObject = typename sdbusplus::server::object::object<T>;
-using MaximumInterface = sdbusplus::org::open_power::
- Sensor::Aggregation::History::server::Maximum;
+using MaximumInterface =
+ sdbusplus::org::open_power::Sensor::Aggregation::History::server::Maximum;
/**
* @class Maximum
@@ -25,33 +25,30 @@
*/
class Maximum : public ServerObject<MaximumInterface>
{
- public:
+ public:
+ static constexpr auto name = "maximum";
- static constexpr auto name = "maximum";
+ Maximum() = delete;
+ Maximum(const Maximum&) = delete;
+ Maximum& operator=(const Maximum&) = delete;
+ Maximum(Maximum&&) = delete;
+ Maximum& operator=(Maximum&&) = delete;
+ ~Maximum() = default;
- Maximum() = delete;
- Maximum(const Maximum&) = delete;
- Maximum& operator=(const Maximum&) = delete;
- Maximum(Maximum&&) = delete;
- Maximum& operator=(Maximum&&) = delete;
- ~Maximum() = default;
-
- /**
- * @brief Constructor
- *
- * @param[in] bus - D-Bus object
- * @param[in] objectPath - the D-Bus object path
- */
- Maximum(sdbusplus::bus::bus& bus,
- const std::string& objectPath) :
- ServerObject<MaximumInterface>(bus, objectPath.c_str())
- {
- unit(Maximum::Unit::Watts);
- scale(0);
- }
+ /**
+ * @brief Constructor
+ *
+ * @param[in] bus - D-Bus object
+ * @param[in] objectPath - the D-Bus object path
+ */
+ Maximum(sdbusplus::bus::bus& bus, const std::string& objectPath) :
+ ServerObject<MaximumInterface>(bus, objectPath.c_str())
+ {
+ unit(Maximum::Unit::Watts);
+ scale(0);
+ }
};
-
-}
-}
-}
+} // namespace history
+} // namespace power
+} // namespace witherspoon
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index ff98457..5988ea9 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -13,19 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <functional>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <org/open_power/Witherspoon/Fault/error.hpp>
-#include <xyz/openbmc_project/Common/Device/error.hpp>
-#include <xyz/openbmc_project/Software/Version/server.hpp>
+#include "power_supply.hpp"
+
#include "elog-errors.hpp"
#include "gpio.hpp"
#include "names_values.hpp"
-#include "power_supply.hpp"
#include "pmbus.hpp"
#include "utility.hpp"
+#include <functional>
+#include <org/open_power/Witherspoon/Fault/error.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/log.hpp>
+#include <xyz/openbmc_project/Common/Device/error.hpp>
+#include <xyz/openbmc_project/Software/Version/server.hpp>
+
namespace witherspoon
{
namespace power
@@ -66,42 +68,30 @@
constexpr auto INPUT_HISTORY = "input_history";
PowerSupply::PowerSupply(const std::string& name, size_t inst,
- const std::string& objpath,
- const std::string& invpath,
- sdbusplus::bus::bus& bus,
- const sdeventplus::Event& e,
- std::chrono::seconds& t,
- std::chrono::seconds& p)
- : Device(name, inst), monitorPath(objpath), pmbusIntf(objpath),
- inventoryPath(INVENTORY_OBJ_PATH + invpath), bus(bus),
- presentInterval(p),
- presentTimer(e, std::bind([this]()
- {
- // The hwmon path may have changed.
- pmbusIntf.findHwmonDir();
- this->present = true;
+ const std::string& objpath, const std::string& invpath,
+ sdbusplus::bus::bus& bus, const sdeventplus::Event& e,
+ std::chrono::seconds& t, std::chrono::seconds& p) :
+ Device(name, inst),
+ monitorPath(objpath), pmbusIntf(objpath),
+ inventoryPath(INVENTORY_OBJ_PATH + invpath), bus(bus), presentInterval(p),
+ presentTimer(e, std::bind([this]() {
+ // The hwmon path may have changed.
+ pmbusIntf.findHwmonDir();
+ this->present = true;
- // Sync the INPUT_HISTORY data for all PSs
- syncHistory();
+ // Sync the INPUT_HISTORY data for all PSs
+ syncHistory();
- // Update the inventory for the new device
- updateInventory();
- })),
- powerOnInterval(t),
- powerOnTimer(e, std::bind([this]()
- {
- this->powerOn = true;
- }))
+ // Update the inventory for the new device
+ updateInventory();
+ })),
+ powerOnInterval(t),
+ powerOnTimer(e, std::bind([this]() { this->powerOn = true; }))
{
using namespace sdbusplus::bus;
- presentMatch = std::make_unique<match_t>(bus,
- match::rules::propertiesChanged(
- inventoryPath,
- INVENTORY_IFACE),
- [this](auto& msg)
- {
- this->inventoryChanged(msg);
- });
+ presentMatch = std::make_unique<match_t>(
+ bus, match::rules::propertiesChanged(inventoryPath, INVENTORY_IFACE),
+ [this](auto& msg) { this->inventoryChanged(msg); });
// Get initial presence state.
updatePresence();
@@ -109,14 +99,9 @@
updateInventory();
// Subscribe to power state changes
- powerOnMatch = std::make_unique<match_t>(bus,
- match::rules::propertiesChanged(
- POWER_OBJ_PATH,
- POWER_IFACE),
- [this](auto& msg)
- {
- this->powerStateChanged(msg);
- });
+ powerOnMatch = std::make_unique<match_t>(
+ bus, match::rules::propertiesChanged(POWER_OBJ_PATH, POWER_IFACE),
+ [this](auto& msg) { this->powerStateChanged(msg); });
// Get initial power state.
updatePowerState();
}
@@ -204,7 +189,7 @@
present = false;
presentTimer.setEnabled(false);
- //Clear out the now outdated inventory properties
+ // Clear out the now outdated inventory properties
updateInventory();
}
}
@@ -216,8 +201,8 @@
{
// Use getProperty utility function to get presence status.
std::string service = "xyz.openbmc_project.Inventory.Manager";
- util::getProperty(INVENTORY_IFACE, PRESENT_PROP, inventoryPath,
- service, bus, this->present);
+ util::getProperty(INVENTORY_IFACE, PRESENT_PROP, inventoryPath, service,
+ bus, this->present);
}
void PowerSupply::powerStateChanged(sdbusplus::message::message& msg)
@@ -225,14 +210,15 @@
int32_t state = 0;
std::string msgSensor;
std::map<std::string, sdbusplus::message::variant<int32_t, int32_t>>
- msgData;
+ msgData;
msg.read(msgSensor, msgData);
// Check if it was the Present property that changed.
auto valPropMap = msgData.find("state");
if (valPropMap != msgData.end())
{
- state = sdbusplus::message::variant_ns::get<int32_t>(valPropMap->second);
+ state =
+ sdbusplus::message::variant_ns::get<int32_t>(valPropMap->second);
// Power is on when state=1. Set the fault logged variables to false
// and start the power on timer when the state changes to 1.
@@ -247,7 +233,6 @@
powerOn = false;
}
}
-
}
void PowerSupply::updatePowerState()
@@ -257,17 +242,11 @@
try
{
- auto service = util::getService(POWER_OBJ_PATH,
- POWER_IFACE,
- bus);
+ auto service = util::getService(POWER_OBJ_PATH, POWER_IFACE, bus);
// Use getProperty utility function to get power state.
- util::getProperty<int32_t>(POWER_IFACE,
- "state",
- POWER_OBJ_PATH,
- service,
- bus,
- state);
+ util::getProperty<int32_t>(POWER_IFACE, "state", POWER_OBJ_PATH,
+ service, bus, state);
if (state)
{
@@ -283,7 +262,6 @@
log<level::INFO>("Failed to get power state. Assuming it is off.");
powerOn = false;
}
-
}
void PowerSupply::checkInputFault(const uint16_t statusWord)
@@ -304,8 +282,7 @@
}
else
{
- if ((inputFault > 0) &&
- !(statusWord & status_word::INPUT_FAULT_WARN) &&
+ if ((inputFault > 0) && !(statusWord & status_word::INPUT_FAULT_WARN) &&
!(statusWord & status_word::VIN_UV_FAULT))
{
inputFault = 0;
@@ -344,17 +321,16 @@
nv.add("STATUS_WORD", statusWord);
captureCmd(nv, STATUS_INPUT, Type::Debug);
- using metadata = org::open_power::Witherspoon::Fault::
- PowerSupplyInputFault;
+ using metadata =
+ org::open_power::Witherspoon::Fault::PowerSupplyInputFault;
report<PowerSupplyInputFault>(
- metadata::RAW_STATUS(nv.get().c_str()),
- metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
+ metadata::RAW_STATUS(nv.get().c_str()),
+ metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
faultFound = true;
}
}
-
}
void PowerSupply::checkPGOrUnitOffFault(const uint16_t statusWord)
@@ -392,17 +368,15 @@
captureCmd(nv, STATUS_IOUT, Type::Debug);
captureCmd(nv, STATUS_MFR, Type::Debug);
- using metadata = org::open_power::Witherspoon::Fault::
- PowerSupplyShouldBeOn;
+ using metadata =
+ org::open_power::Witherspoon::Fault::PowerSupplyShouldBeOn;
// A power supply is OFF (or pgood low) but should be on.
report<PowerSupplyShouldBeOn>(
- metadata::RAW_STATUS(nv.get().c_str()),
- metadata::CALLOUT_INVENTORY_PATH(
- inventoryPath.c_str()));
+ metadata::RAW_STATUS(nv.get().c_str()),
+ metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
}
}
-
}
void PowerSupply::checkCurrentOutOverCurrentFault(const uint16_t statusWord)
@@ -435,11 +409,11 @@
captureCmd(nv, STATUS_MFR, Type::Debug);
using metadata = org::open_power::Witherspoon::Fault::
- PowerSupplyOutputOvercurrent;
+ PowerSupplyOutputOvercurrent;
report<PowerSupplyOutputOvercurrent>(
- metadata::RAW_STATUS(nv.get().c_str()),
- metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
+ metadata::RAW_STATUS(nv.get().c_str()),
+ metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
faultFound = true;
}
@@ -476,11 +450,11 @@
captureCmd(nv, STATUS_MFR, Type::Debug);
using metadata = org::open_power::Witherspoon::Fault::
- PowerSupplyOutputOvervoltage;
+ PowerSupplyOutputOvervoltage;
report<PowerSupplyOutputOvervoltage>(
- metadata::RAW_STATUS(nv.get().c_str()),
- metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
+ metadata::RAW_STATUS(nv.get().c_str()),
+ metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
faultFound = true;
}
@@ -514,12 +488,12 @@
captureCmd(nv, STATUS_TEMPERATURE, Type::Debug);
captureCmd(nv, STATUS_FANS_1_2, Type::Debug);
- using metadata = org::open_power::Witherspoon::Fault::
- PowerSupplyFanFault;
+ using metadata =
+ org::open_power::Witherspoon::Fault::PowerSupplyFanFault;
report<PowerSupplyFanFault>(
- metadata::RAW_STATUS(nv.get().c_str()),
- metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
+ metadata::RAW_STATUS(nv.get().c_str()),
+ metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
faultFound = true;
}
@@ -570,11 +544,11 @@
captureCmd(nv, STATUS_FANS_1_2, Type::Debug);
using metadata = org::open_power::Witherspoon::Fault::
- PowerSupplyTemperatureFault;
+ PowerSupplyTemperatureFault;
report<PowerSupplyTemperatureFault>(
- metadata::RAW_STATUS(nv.get().c_str()),
- metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
+ metadata::RAW_STATUS(nv.get().c_str()),
+ metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
faultFound = true;
}
@@ -605,14 +579,12 @@
{
auto path = callout + "/fault";
// Get the service name from the mapper for the fault callout
- auto service = util::getService(path,
- ASSOCIATION_IFACE,
- bus);
+ auto service = util::getService(path, ASSOCIATION_IFACE, bus);
// Use getProperty utility function to get log entries (endpoints)
EndpointList logEntries;
- util::getProperty(ASSOCIATION_IFACE, ENDPOINTS_PROP, path, service,
- bus, logEntries);
+ util::getProperty(ASSOCIATION_IFACE, ENDPOINTS_PROP, path, service, bus,
+ logEntries);
// It is possible that all such entries for this callout have since
// been deleted.
@@ -621,8 +593,8 @@
return;
}
- auto logEntryService = util::getService(logEntries[0], LOGGING_IFACE,
- bus);
+ auto logEntryService =
+ util::getService(logEntries[0], LOGGING_IFACE, bus);
if (logEntryService.empty())
{
return;
@@ -643,9 +615,7 @@
util::setProperty(LOGGING_IFACE, RESOLVED_PROP, logEntry,
logEntryService, bus, resolved);
}
-
}
-
}
catch (std::exception& e)
{
@@ -653,7 +623,6 @@
entry("CALLOUT=%s", callout.c_str()),
entry("ERROR=%s", message.c_str()));
}
-
}
void PowerSupply::updateInventory()
@@ -678,25 +647,33 @@
{
sn = pmbusIntf.readString(SERIAL_NUMBER, Type::HwmonDeviceDebug);
}
- catch (ReadFailure& e) { }
+ catch (ReadFailure& e)
+ {
+ }
try
{
pn = pmbusIntf.readString(PART_NUMBER, Type::HwmonDeviceDebug);
}
- catch (ReadFailure& e) { }
+ catch (ReadFailure& e)
+ {
+ }
try
{
ccin = pmbusIntf.readString(CCIN, Type::HwmonDeviceDebug);
}
- catch (ReadFailure& e) { }
+ catch (ReadFailure& e)
+ {
+ }
try
{
version = pmbusIntf.readString(FW_VERSION, Type::HwmonDeviceDebug);
}
- catch (ReadFailure& e) { }
+ catch (ReadFailure& e)
+ {
+ }
}
// Build the object map and send it to the inventory
@@ -716,18 +693,16 @@
versionProps.emplace(VERSION_PROP, version);
interfaces.emplace(VERSION_IFACE, std::move(versionProps));
- //For Notify(), just send the relative path of the inventory
- //object so remove the INVENTORY_OBJ_PATH prefix
+ // For Notify(), just send the relative path of the inventory
+ // object so remove the INVENTORY_OBJ_PATH prefix
auto path = inventoryPath.substr(strlen(INVENTORY_OBJ_PATH));
object.emplace(path, std::move(interfaces));
try
{
- auto service = util::getService(
- INVENTORY_OBJ_PATH,
- INVENTORY_MGR_IFACE,
- bus);
+ auto service =
+ util::getService(INVENTORY_OBJ_PATH, INVENTORY_MGR_IFACE, bus);
if (service.empty())
{
@@ -735,11 +710,8 @@
return;
}
- auto method = bus.new_method_call(
- service.c_str(),
- INVENTORY_OBJ_PATH,
- INVENTORY_MGR_IFACE,
- "Notify");
+ auto method = bus.new_method_call(service.c_str(), INVENTORY_OBJ_PATH,
+ INVENTORY_MGR_IFACE, "Notify");
method.append(std::move(object));
@@ -747,30 +719,23 @@
if (reply.is_method_error())
{
log<level::ERR>(
- "Unable to update power supply inventory properties",
- entry("PATH=%s", path.c_str()));
+ "Unable to update power supply inventory properties",
+ entry("PATH=%s", path.c_str()));
}
// TODO: openbmc/openbmc#2756
// Calling Notify() with an enumerated property crashes inventory
// manager, so let it default to Unknown and now set it to the
// right value.
- auto purpose = version::convertForMessage(
- version::Version::VersionPurpose::Other);
+ auto purpose =
+ version::convertForMessage(version::Version::VersionPurpose::Other);
- util::setProperty(
- VERSION_IFACE,
- VERSION_PURPOSE_PROP,
- inventoryPath,
- service,
- bus,
- purpose);
+ util::setProperty(VERSION_IFACE, VERSION_PURPOSE_PROP, inventoryPath,
+ service, bus, purpose);
}
catch (std::exception& e)
{
- log<level::ERR>(
- e.what(),
- entry("PATH=%s", inventoryPath.c_str()));
+ log<level::ERR>(e.what(), entry("PATH=%s", inventoryPath.c_str()));
}
}
@@ -780,12 +745,11 @@
if (syncGPIODevPath.empty())
{
- //Sync not implemented
+ // Sync not implemented
return;
}
- GPIO gpio{syncGPIODevPath,
- static_cast<gpioNum_t>(syncGPIONumber),
+ GPIO gpio{syncGPIODevPath, static_cast<gpioNum_t>(syncGPIONumber),
Direction::output};
try
@@ -800,7 +764,7 @@
}
catch (std::exception& e)
{
- //Do nothing. There would already be a journal entry.
+ // Do nothing. There would already be a journal entry.
}
}
@@ -827,17 +791,16 @@
{
if (!recordManager)
{
- //Not enabled
+ // Not enabled
return;
}
- //Read just the most recent average/max record
- auto data = pmbusIntf.readBinary(
- INPUT_HISTORY,
- pmbus::Type::HwmonDeviceDebug,
- history::RecordManager::RAW_RECORD_SIZE);
+ // Read just the most recent average/max record
+ auto data =
+ pmbusIntf.readBinary(INPUT_HISTORY, pmbus::Type::HwmonDeviceDebug,
+ history::RecordManager::RAW_RECORD_SIZE);
- //Update D-Bus only if something changed (a new record ID, or cleared out)
+ // Update D-Bus only if something changed (a new record ID, or cleared out)
auto changed = recordManager->add(data);
if (changed)
{
@@ -846,6 +809,6 @@
}
}
-}
-}
-}
+} // namespace psu
+} // namespace power
+} // namespace witherspoon
diff --git a/power-supply/power_supply.hpp b/power-supply/power_supply.hpp
index a56e2e2..d997423 100644
--- a/power-supply/power_supply.hpp
+++ b/power-supply/power_supply.hpp
@@ -1,8 +1,4 @@
#pragma once
-#include <sdbusplus/bus/match.hpp>
-#include <sdeventplus/clock.hpp>
-#include <sdeventplus/event.hpp>
-#include <sdeventplus/utility/timer.hpp>
#include "average.hpp"
#include "device.hpp"
#include "maximum.hpp"
@@ -10,6 +6,11 @@
#include "pmbus.hpp"
#include "record_manager.hpp"
+#include <sdbusplus/bus/match.hpp>
+#include <sdeventplus/clock.hpp>
+#include <sdeventplus/event.hpp>
+#include <sdeventplus/utility/timer.hpp>
+
namespace witherspoon
{
namespace power
@@ -27,395 +28,389 @@
*/
class PowerSupply : public Device
{
- public:
- PowerSupply() = delete;
- PowerSupply(const PowerSupply&) = delete;
- PowerSupply(PowerSupply&&) = default;
- PowerSupply& operator=(const PowerSupply&) = default;
- PowerSupply& operator=(PowerSupply&&) = default;
- ~PowerSupply() = default;
+ public:
+ PowerSupply() = delete;
+ PowerSupply(const PowerSupply&) = delete;
+ PowerSupply(PowerSupply&&) = default;
+ PowerSupply& operator=(const PowerSupply&) = default;
+ PowerSupply& operator=(PowerSupply&&) = default;
+ ~PowerSupply() = default;
- /**
- * Constructor
- *
- * @param[in] name - the device name
- * @param[in] inst - the device instance
- * @param[in] objpath - the path to monitor
- * @param[in] invpath - the inventory path to use
- * @param[in] bus - D-Bus bus object
- * @param[in] e - event object
- * @param[in] t - time to allow power supply to assert PG#
- * @param[in] p - time to allow power supply presence state to
- * settle/deglitch and allow for application of power
- * prior to fault checking
- */
- PowerSupply(const std::string& name, size_t inst,
- const std::string& objpath,
- const std::string& invpath,
- sdbusplus::bus::bus& bus,
- const sdeventplus::Event& e,
- std::chrono::seconds& t,
- std::chrono::seconds& p);
+ /**
+ * Constructor
+ *
+ * @param[in] name - the device name
+ * @param[in] inst - the device instance
+ * @param[in] objpath - the path to monitor
+ * @param[in] invpath - the inventory path to use
+ * @param[in] bus - D-Bus bus object
+ * @param[in] e - event object
+ * @param[in] t - time to allow power supply to assert PG#
+ * @param[in] p - time to allow power supply presence state to
+ * settle/deglitch and allow for application of power
+ * prior to fault checking
+ */
+ PowerSupply(const std::string& name, size_t inst,
+ const std::string& objpath, const std::string& invpath,
+ sdbusplus::bus::bus& bus, const sdeventplus::Event& e,
+ std::chrono::seconds& t, std::chrono::seconds& p);
- /**
- * Power supply specific function to analyze for faults/errors.
- *
- * Various PMBus status bits will be checked for fault conditions.
- * If a certain fault bits are on, the appropriate error will be
- * committed.
- */
- void analyze() override;
+ /**
+ * Power supply specific function to analyze for faults/errors.
+ *
+ * Various PMBus status bits will be checked for fault conditions.
+ * If a certain fault bits are on, the appropriate error will be
+ * committed.
+ */
+ void analyze() override;
- /**
- * Write PMBus CLEAR_FAULTS
- *
- * This function will be called in various situations in order to clear
- * any fault status bits that may have been set, in order to start over
- * with a clean state. Presence changes and power state changes will
- * want to clear any faults logged.
- */
- void clearFaults() override;
+ /**
+ * Write PMBus CLEAR_FAULTS
+ *
+ * This function will be called in various situations in order to clear
+ * any fault status bits that may have been set, in order to start over
+ * with a clean state. Presence changes and power state changes will
+ * want to clear any faults logged.
+ */
+ void clearFaults() override;
- /**
- * Mark error for specified callout and message as resolved.
- *
- * @param[in] callout - The callout to be resolved (inventory path)
- * @parma[in] message - The message for the fault to be resolved
- */
- void resolveError(const std::string& callout,
- const std::string& message);
+ /**
+ * Mark error for specified callout and message as resolved.
+ *
+ * @param[in] callout - The callout to be resolved (inventory path)
+ * @parma[in] message - The message for the fault to be resolved
+ */
+ void resolveError(const std::string& callout, const std::string& message);
- /**
- * Enables making the input power history available on D-Bus
- *
- * @param[in] objectPath - the D-Bus object path to use
- * @param[in] maxRecords - the number of history records to keep
- * @param[in] syncGPIOPath - The gpiochip device path to use for
- * sending the sync command
- * @paramp[in] syncGPIONum - the GPIO number for the sync command
- */
- void enableHistory(const std::string& objectPath,
- size_t numRecords,
- const std::string& syncGPIOPath,
- size_t syncGPIONum);
+ /**
+ * Enables making the input power history available on D-Bus
+ *
+ * @param[in] objectPath - the D-Bus object path to use
+ * @param[in] maxRecords - the number of history records to keep
+ * @param[in] syncGPIOPath - The gpiochip device path to use for
+ * sending the sync command
+ * @paramp[in] syncGPIONum - the GPIO number for the sync command
+ */
+ void enableHistory(const std::string& objectPath, size_t numRecords,
+ const std::string& syncGPIOPath, size_t syncGPIONum);
- private:
- /**
- * The path to use for reading various PMBus bits/words.
- */
- std::string monitorPath;
+ private:
+ /**
+ * The path to use for reading various PMBus bits/words.
+ */
+ std::string monitorPath;
- /**
- * @brief Pointer to the PMBus interface
- *
- * Used to read out of or write to the /sysfs tree(s) containing files
- * that a device driver monitors the PMBus interface to the power
- * supplies.
- */
- witherspoon::pmbus::PMBus pmbusIntf;
+ /**
+ * @brief Pointer to the PMBus interface
+ *
+ * Used to read out of or write to the /sysfs tree(s) containing files
+ * that a device driver monitors the PMBus interface to the power
+ * supplies.
+ */
+ witherspoon::pmbus::PMBus pmbusIntf;
- /**
- * @brief D-Bus path to use for this power supply's inventory status.
- */
- std::string inventoryPath;
+ /**
+ * @brief D-Bus path to use for this power supply's inventory status.
+ */
+ std::string inventoryPath;
- /** @brief Connection for sdbusplus bus */
- sdbusplus::bus::bus& bus;
+ /** @brief Connection for sdbusplus bus */
+ sdbusplus::bus::bus& bus;
- /** @brief True if the power supply is present. */
- bool present = false;
+ /** @brief True if the power supply is present. */
+ bool present = false;
- /** @brief Used to subscribe to D-Bus property changes for Present */
- std::unique_ptr<sdbusplus::bus::match_t> presentMatch;
+ /** @brief Used to subscribe to D-Bus property changes for Present */
+ std::unique_ptr<sdbusplus::bus::match_t> presentMatch;
- /**
- * @brief Interval for setting present to true.
- *
- * The amount of time to wait from not present to present change before
- * updating the internal present indicator. Allows person servicing
- * the power supply some time to plug in the cable.
- */
- std::chrono::seconds presentInterval;
+ /**
+ * @brief Interval for setting present to true.
+ *
+ * The amount of time to wait from not present to present change before
+ * updating the internal present indicator. Allows person servicing
+ * the power supply some time to plug in the cable.
+ */
+ std::chrono::seconds presentInterval;
- /**
- * @brief Timer used to delay setting the internal present state.
- *
- * The timer used to do the callback after the present property has
- * changed.
- */
- sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> presentTimer;
+ /**
+ * @brief Timer used to delay setting the internal present state.
+ *
+ * The timer used to do the callback after the present property has
+ * changed.
+ */
+ sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> presentTimer;
- /** @brief True if a fault has already been found and not cleared */
- bool faultFound = false;
+ /** @brief True if a fault has already been found and not cleared */
+ bool faultFound = false;
- /** @brief True if the power is on. */
- bool powerOn = false;
+ /** @brief True if the power is on. */
+ bool powerOn = false;
- /**
- * @brief Equal to FAULT_COUNT if power on fault has been
- * detected.
- */
- size_t powerOnFault = 0;
+ /**
+ * @brief Equal to FAULT_COUNT if power on fault has been
+ * detected.
+ */
+ size_t powerOnFault = 0;
- /**
- * @brief Interval to setting powerOn to true.
- *
- * The amount of time to wait from power state on to setting the
- * internal powerOn state to true. The amount of time the power supply
- * is allowed to delay setting DGood/PG#.
- */
- std::chrono::seconds powerOnInterval;
+ /**
+ * @brief Interval to setting powerOn to true.
+ *
+ * The amount of time to wait from power state on to setting the
+ * internal powerOn state to true. The amount of time the power supply
+ * is allowed to delay setting DGood/PG#.
+ */
+ std::chrono::seconds powerOnInterval;
- /**
- * @brief Timer used to delay setting the internal powerOn state.
- *
- * The timer used to do the callback after the power state has been on
- * long enough.
- */
- sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> powerOnTimer;
+ /**
+ * @brief Timer used to delay setting the internal powerOn state.
+ *
+ * The timer used to do the callback after the power state has been on
+ * long enough.
+ */
+ sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> powerOnTimer;
- /** @brief Used to subscribe to D-Bus power on state changes */
- std::unique_ptr<sdbusplus::bus::match_t> powerOnMatch;
+ /** @brief Used to subscribe to D-Bus power on state changes */
+ std::unique_ptr<sdbusplus::bus::match_t> powerOnMatch;
- /** @brief Indicates that a read failure has occurred.
- *
- * @details This will be incremented each time a read failure is
- * encountered. If it is incremented to FAULT_COUNT, an error
- * will be logged.
- */
- size_t readFail = 0;
+ /** @brief Indicates that a read failure has occurred.
+ *
+ * @details This will be incremented each time a read failure is
+ * encountered. If it is incremented to FAULT_COUNT, an error
+ * will be logged.
+ */
+ size_t readFail = 0;
- /** @brief Has a PMBus read failure already been logged? */
- bool readFailLogged = false;
+ /** @brief Has a PMBus read failure already been logged? */
+ bool readFailLogged = false;
- /**
- * @brief Indicates an input fault or warning if equal to FAULT_COUNT.
- *
- * @details This is the "INPUT FAULT OR WARNING" bit in the high byte,
- * or the VIN_UV_FAULT bit in the low byte in the STATUS_WORD
- * command response. If either of those bits are on, this will
- * be incremented.
- */
- size_t inputFault = 0;
+ /**
+ * @brief Indicates an input fault or warning if equal to FAULT_COUNT.
+ *
+ * @details This is the "INPUT FAULT OR WARNING" bit in the high byte,
+ * or the VIN_UV_FAULT bit in the low byte in the STATUS_WORD
+ * command response. If either of those bits are on, this will
+ * be incremented.
+ */
+ size_t inputFault = 0;
- /**
- * @brief Indicates output over current fault if equal to FAULT_COUNT
- *
- * @details This is incremented when the "IOUT_OC_FAULT" bit in the low
- * byte from the STATUS_WORD command response is on.
- */
- size_t outputOCFault = 0;
+ /**
+ * @brief Indicates output over current fault if equal to FAULT_COUNT
+ *
+ * @details This is incremented when the "IOUT_OC_FAULT" bit in the low
+ * byte from the STATUS_WORD command response is on.
+ */
+ size_t outputOCFault = 0;
- /**
- * @brief Indicates output overvoltage fault if equal to FAULT_COUNT.
- *
- * @details This is incremented when the "VOUT_OV_FAULT" bit in the
- * STATUS_WORD command response is on.
- */
- size_t outputOVFault = 0;
+ /**
+ * @brief Indicates output overvoltage fault if equal to FAULT_COUNT.
+ *
+ * @details This is incremented when the "VOUT_OV_FAULT" bit in the
+ * STATUS_WORD command response is on.
+ */
+ size_t outputOVFault = 0;
- /**
- * @brief Indicates a fan fault or warning condition was detected if
- * equal to FAULT_COUNT.
- *
- * @details This is incremented when the 'FAN_FAULT' bit in the
- * STATUS_WORD command response is on.
- */
- size_t fanFault = 0;
+ /**
+ * @brief Indicates a fan fault or warning condition was detected if
+ * equal to FAULT_COUNT.
+ *
+ * @details This is incremented when the 'FAN_FAULT' bit in the
+ * STATUS_WORD command response is on.
+ */
+ size_t fanFault = 0;
- /**
- * @brief Indicates a temperature fault or warn condition was detected
- * if equal to FAULT_COUNT.
- *
- * @details This is incremented when the 'TEMPERATURE_FAULT_WARN' bit
- * in the STATUS_WORD command response is on, or if the
- * 'OT_FAULT' bit in the STATUS_TEMPERATURE command response
- * is on.
- */
- size_t temperatureFault = 0;
+ /**
+ * @brief Indicates a temperature fault or warn condition was detected
+ * if equal to FAULT_COUNT.
+ *
+ * @details This is incremented when the 'TEMPERATURE_FAULT_WARN' bit
+ * in the STATUS_WORD command response is on, or if the
+ * 'OT_FAULT' bit in the STATUS_TEMPERATURE command response
+ * is on.
+ */
+ size_t temperatureFault = 0;
- /**
- * @brief Class that manages the input power history records.
- */
- std::unique_ptr<history::RecordManager> recordManager;
+ /**
+ * @brief Class that manages the input power history records.
+ */
+ std::unique_ptr<history::RecordManager> recordManager;
- /**
- * @brief The D-Bus object for the average input power history
- */
- std::unique_ptr<history::Average> average;
+ /**
+ * @brief The D-Bus object for the average input power history
+ */
+ std::unique_ptr<history::Average> average;
- /**
- * @brief The D-Bus object for the maximum input power history
- */
- std::unique_ptr<history::Maximum> maximum;
+ /**
+ * @brief The D-Bus object for the maximum input power history
+ */
+ std::unique_ptr<history::Maximum> maximum;
- /**
- * @brief The base D-Bus object path to use for the average
- * and maximum objects.
- */
- std::string historyObjectPath;
+ /**
+ * @brief The base D-Bus object path to use for the average
+ * and maximum objects.
+ */
+ std::string historyObjectPath;
- /**
- * @brief The GPIO device path to use for sending the 'sync'
- * command to the PS.
- */
- std::string syncGPIODevPath;
+ /**
+ * @brief The GPIO device path to use for sending the 'sync'
+ * command to the PS.
+ */
+ std::string syncGPIODevPath;
- /**
- * @brief The GPIO number to use for sending the 'sync'
- * command to the PS.
- */
- size_t syncGPIONumber = 0;
+ /**
+ * @brief The GPIO number to use for sending the 'sync'
+ * command to the PS.
+ */
+ size_t syncGPIONumber = 0;
- /**
- * @brief Callback for inventory property changes
- *
- * Process change of Present property for power supply.
- *
- * @param[in] msg - Data associated with Present change signal
- *
- */
- void inventoryChanged(sdbusplus::message::message& msg);
+ /**
+ * @brief Callback for inventory property changes
+ *
+ * Process change of Present property for power supply.
+ *
+ * @param[in] msg - Data associated with Present change signal
+ *
+ */
+ void inventoryChanged(sdbusplus::message::message& msg);
- /**
- * Updates the presence status by querying D-Bus
- *
- * The D-Bus inventory properties for this power supply will be read to
- * determine if the power supply is present or not and update this
- * objects present member variable to reflect current status.
- */
- void updatePresence();
+ /**
+ * Updates the presence status by querying D-Bus
+ *
+ * The D-Bus inventory properties for this power supply will be read to
+ * determine if the power supply is present or not and update this
+ * objects present member variable to reflect current status.
+ */
+ void updatePresence();
- /**
- * @brief Updates the poweredOn status by querying D-Bus
- *
- * The D-Bus property for the system power state will be read to
- * determine if the system is powered on or not.
- */
- void updatePowerState();
+ /**
+ * @brief Updates the poweredOn status by querying D-Bus
+ *
+ * The D-Bus property for the system power state will be read to
+ * determine if the system is powered on or not.
+ */
+ void updatePowerState();
- /**
- * @brief Callback for power state property changes
- *
- * Process changes to the powered on stat property for the system.
- *
- * @param[in] msg - Data associated with the power state signal
- */
- void powerStateChanged(sdbusplus::message::message& msg);
+ /**
+ * @brief Callback for power state property changes
+ *
+ * Process changes to the powered on stat property for the system.
+ *
+ * @param[in] msg - Data associated with the power state signal
+ */
+ void powerStateChanged(sdbusplus::message::message& msg);
- /**
- * @brief Wrapper for PMBus::read() and adding metadata
- *
- * @param[out] nv - NamesValues instance to store cmd string and value
- * @param[in] cmd - String for the command to read data from.
- * @param[in] type - The type of file to read the command from.
- */
- void captureCmd(util::NamesValues& nv, const std::string& cmd,
- witherspoon::pmbus::Type type);
+ /**
+ * @brief Wrapper for PMBus::read() and adding metadata
+ *
+ * @param[out] nv - NamesValues instance to store cmd string and value
+ * @param[in] cmd - String for the command to read data from.
+ * @param[in] type - The type of file to read the command from.
+ */
+ void captureCmd(util::NamesValues& nv, const std::string& cmd,
+ witherspoon::pmbus::Type type);
- /**
- * @brief Checks for input voltage faults and logs error if needed.
- *
- * Check for voltage input under voltage fault (VIN_UV_FAULT) and/or
- * input fault or warning (INPUT_FAULT), and logs appropriate error(s).
- *
- * @param[in] statusWord - 2 byte STATUS_WORD value read from sysfs
- */
- void checkInputFault(const uint16_t statusWord);
+ /**
+ * @brief Checks for input voltage faults and logs error if needed.
+ *
+ * Check for voltage input under voltage fault (VIN_UV_FAULT) and/or
+ * input fault or warning (INPUT_FAULT), and logs appropriate error(s).
+ *
+ * @param[in] statusWord - 2 byte STATUS_WORD value read from sysfs
+ */
+ void checkInputFault(const uint16_t statusWord);
- /**
- * @brief Checks for power good negated or unit is off in wrong state
- *
- * @param[in] statusWord - 2 byte STATUS_WORD value read from sysfs
- */
- void checkPGOrUnitOffFault(const uint16_t statusWord);
+ /**
+ * @brief Checks for power good negated or unit is off in wrong state
+ *
+ * @param[in] statusWord - 2 byte STATUS_WORD value read from sysfs
+ */
+ void checkPGOrUnitOffFault(const uint16_t statusWord);
- /**
- * @brief Checks for output current over current fault.
- *
- * IOUT_OC_FAULT is checked, if on, appropriate error is logged.
- *
- * @param[in] statusWord - 2 byte STATUS_WORD value read from sysfs
- */
- void checkCurrentOutOverCurrentFault(const uint16_t statusWord);
+ /**
+ * @brief Checks for output current over current fault.
+ *
+ * IOUT_OC_FAULT is checked, if on, appropriate error is logged.
+ *
+ * @param[in] statusWord - 2 byte STATUS_WORD value read from sysfs
+ */
+ void checkCurrentOutOverCurrentFault(const uint16_t statusWord);
- /**
- * @brief Checks for output overvoltage fault.
- *
- * VOUT_OV_FAULT is checked, if on, appropriate error is logged.
- *
- * @param[in] statusWord - 2 byte STATUS_WORD value read from sysfs
- */
- void checkOutputOvervoltageFault(const uint16_t statusWord);
+ /**
+ * @brief Checks for output overvoltage fault.
+ *
+ * VOUT_OV_FAULT is checked, if on, appropriate error is logged.
+ *
+ * @param[in] statusWord - 2 byte STATUS_WORD value read from sysfs
+ */
+ void checkOutputOvervoltageFault(const uint16_t statusWord);
- /**
- * @brief Checks for a fan fault or warning condition.
- *
- * The high byte of STATUS_WORD is checked to see if the "FAN FAULT OR
- * WARNING" bit is turned on. If it is on, log an error.
- *
- * @param[in] statusWord - 2 byte STATUS_WORD value read from sysfs
- */
- void checkFanFault(const uint16_t statusWord);
+ /**
+ * @brief Checks for a fan fault or warning condition.
+ *
+ * The high byte of STATUS_WORD is checked to see if the "FAN FAULT OR
+ * WARNING" bit is turned on. If it is on, log an error.
+ *
+ * @param[in] statusWord - 2 byte STATUS_WORD value read from sysfs
+ */
+ void checkFanFault(const uint16_t statusWord);
- /**
- * @brief Checks for a temperature fault or warning condition.
- *
- * The low byte of STATUS_WORD is checked to see if the "TEMPERATURE
- * FAULT OR WARNING" bit is turned on. If it is on, log an error,
- * call out the power supply indicating the fault/warning condition.
- *
- * @parma[in] statusWord - 2 byte STATUS_WORD value read from sysfs
- */
- void checkTemperatureFault(const uint16_t statusWord);
+ /**
+ * @brief Checks for a temperature fault or warning condition.
+ *
+ * The low byte of STATUS_WORD is checked to see if the "TEMPERATURE
+ * FAULT OR WARNING" bit is turned on. If it is on, log an error,
+ * call out the power supply indicating the fault/warning condition.
+ *
+ * @parma[in] statusWord - 2 byte STATUS_WORD value read from sysfs
+ */
+ void checkTemperatureFault(const uint16_t statusWord);
- /**
- * @brief Adds properties to the inventory.
- *
- * Reads the values from the device and writes them to the
- * associated power supply D-Bus inventory object.
- *
- * This needs to be done on startup, and each time the presence
- * state changes.
- *
- * Properties added:
- * - Serial Number
- * - Part Number
- * - CCIN (Customer Card Identification Number) - added as the Model
- * - Firmware version
- */
- void updateInventory();
+ /**
+ * @brief Adds properties to the inventory.
+ *
+ * Reads the values from the device and writes them to the
+ * associated power supply D-Bus inventory object.
+ *
+ * This needs to be done on startup, and each time the presence
+ * state changes.
+ *
+ * Properties added:
+ * - Serial Number
+ * - Part Number
+ * - CCIN (Customer Card Identification Number) - added as the Model
+ * - Firmware version
+ */
+ void updateInventory();
- /**
- * @brief Toggles the GPIO to sync power supply input history readings
- *
- * This GPIO is connected to all supplies. This will clear the
- * previous readings out of the supplies and restart them both at the
- * same time zero and at record ID 0. The supplies will return 0
- * bytes of data for the input history command right after this until
- * a new entry shows up.
- *
- * This will cause the code to delete all previous history data and
- * start fresh.
- */
- void syncHistory();
+ /**
+ * @brief Toggles the GPIO to sync power supply input history readings
+ *
+ * This GPIO is connected to all supplies. This will clear the
+ * previous readings out of the supplies and restart them both at the
+ * same time zero and at record ID 0. The supplies will return 0
+ * bytes of data for the input history command right after this until
+ * a new entry shows up.
+ *
+ * This will cause the code to delete all previous history data and
+ * start fresh.
+ */
+ void syncHistory();
- /**
- * @brief Reads the most recent input history record from the power
- * supply and updates the average and maximum properties in
- * D-Bus if there is a new reading available.
- *
- * This will still run every time analyze() is called so code can
- * post new data as soon as possible and the timestamp will more
- * accurately reflect the correct time.
- *
- * D-Bus is only updated if there is a change and the oldest record
- * will be pruned if the property already contains the max number of
- * records.
- */
- void updateHistory();
+ /**
+ * @brief Reads the most recent input history record from the power
+ * supply and updates the average and maximum properties in
+ * D-Bus if there is a new reading available.
+ *
+ * This will still run every time analyze() is called so code can
+ * post new data as soon as possible and the timestamp will more
+ * accurately reflect the correct time.
+ *
+ * D-Bus is only updated if there is a change and the oldest record
+ * will be pruned if the property already contains the max number of
+ * records.
+ */
+ void updateHistory();
};
-}
-}
-}
+} // namespace psu
+} // namespace power
+} // namespace witherspoon
diff --git a/power-supply/record_manager.cpp b/power-supply/record_manager.cpp
index ec6e917..b585ba0 100644
--- a/power-supply/record_manager.cpp
+++ b/power-supply/record_manager.cpp
@@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <chrono>
-#include <math.h>
-#include <phosphor-logging/log.hpp>
#include "record_manager.hpp"
+#include <math.h>
+
+#include <chrono>
+#include <phosphor-logging/log.hpp>
+
namespace witherspoon
{
namespace power
@@ -31,47 +33,46 @@
{
if (rawRecord.size() == 0)
{
- //The PS has no data - either the power supply just started up,
- //or it just got a SYNC. Clear the history.
+ // The PS has no data - either the power supply just started up,
+ // or it just got a SYNC. Clear the history.
records.clear();
return true;
}
try
{
- //Peek at the ID to see if more processing is needed.
+ // Peek at the ID to see if more processing is needed.
auto id = getRawRecordID(rawRecord);
if (!records.empty())
{
auto previousID = std::get<recIDPos>(records.front());
- //Already have this record. Done.
+ // Already have this record. Done.
if (previousID == id)
{
return false;
}
- //Check that the sequence ID is in order.
- //If not, clear out current list.
+ // Check that the sequence ID is in order.
+ // If not, clear out current list.
if ((previousID + 1) != id)
{
- //If it just rolled over from 0xFF to 0x00, then no
- //need to clear. If we see a 0 seemingly out of nowhere,
- //then it was a sync so clear the old records.
+ // If it just rolled over from 0xFF to 0x00, then no
+ // need to clear. If we see a 0 seemingly out of nowhere,
+ // then it was a sync so clear the old records.
auto rolledOver =
- (previousID == lastSequenceID) &&
- (id == FIRST_SEQUENCE_ID);
+ (previousID == lastSequenceID) && (id == FIRST_SEQUENCE_ID);
if (!rolledOver)
{
if (id != FIRST_SEQUENCE_ID)
{
log<level::INFO>(
- "Noncontiguous INPUT_HISTORY sequence ID "
- "found. Clearing old entries",
- entry("OLD_ID=%ld", previousID),
- entry("NEW_ID=%ld", id));
+ "Noncontiguous INPUT_HISTORY sequence ID "
+ "found. Clearing old entries",
+ entry("OLD_ID=%ld", previousID),
+ entry("NEW_ID=%ld", id));
}
records.clear();
}
@@ -80,7 +81,7 @@
records.push_front(std::move(createRecord(rawRecord)));
- //If no more should be stored, prune the oldest
+ // If no more should be stored, prune the oldest
if (records.size() > maxRecords)
{
records.pop_back();
@@ -100,8 +101,7 @@
for (const auto& r : records)
{
- list.emplace_back(std::get<recTimePos>(r),
- std::get<recAvgPos>(r));
+ list.emplace_back(std::get<recTimePos>(r), std::get<recAvgPos>(r));
}
return list;
@@ -113,20 +113,18 @@
for (const auto& r : records)
{
- list.emplace_back(std::get<recTimePos>(r),
- std::get<recMaxPos>(r));
+ list.emplace_back(std::get<recTimePos>(r), std::get<recMaxPos>(r));
}
return list;
}
-size_t RecordManager::getRawRecordID(
- const std::vector<uint8_t>& data) const
+size_t RecordManager::getRawRecordID(const std::vector<uint8_t>& data) const
{
if (data.size() != RAW_RECORD_SIZE)
{
log<level::ERR>("Invalid INPUT_HISTORY size",
- entry("SIZE=%d", data.size()));
+ entry("SIZE=%d", data.size()));
throw InvalidRecordException{};
}
@@ -135,7 +133,7 @@
Record RecordManager::createRecord(const std::vector<uint8_t>& data)
{
- //The raw record format is:
+ // The raw record format is:
// 0xAABBCCDDEE
//
// where:
@@ -145,7 +143,8 @@
auto id = getRawRecordID(data);
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(
- std::chrono::system_clock::now().time_since_epoch()).count();
+ std::chrono::system_clock::now().time_since_epoch())
+ .count();
auto val = static_cast<uint16_t>(data[2]) << 8 | data[1];
auto averagePower = linearToInteger(val);
@@ -158,20 +157,20 @@
int64_t RecordManager::linearToInteger(uint16_t data)
{
- //The exponent is the first 5 bits, followed by 11 bits of mantissa.
+ // The exponent is the first 5 bits, followed by 11 bits of mantissa.
int8_t exponent = (data & 0xF800) >> 11;
int16_t mantissa = (data & 0x07FF);
- //If exponent's MSB on, then it's negative.
- //Convert from two's complement.
+ // If exponent's MSB on, then it's negative.
+ // Convert from two's complement.
if (exponent & 0x10)
{
exponent = (~exponent) & 0x1F;
exponent = (exponent + 1) * -1;
}
- //If mantissa's MSB on, then it's negative.
- //Convert from two's complement.
+ // If mantissa's MSB on, then it's negative.
+ // Convert from two's complement.
if (mantissa & 0x400)
{
mantissa = (~mantissa) & 0x07FF;
@@ -182,6 +181,6 @@
return value;
}
-}
-}
-}
+} // namespace history
+} // namespace power
+} // namespace witherspoon
diff --git a/power-supply/record_manager.hpp b/power-supply/record_manager.hpp
index 53e5b9b..7ebcc3f 100644
--- a/power-supply/record_manager.hpp
+++ b/power-supply/record_manager.hpp
@@ -25,12 +25,10 @@
*/
class InvalidRecordException : public std::runtime_error
{
- public:
-
- InvalidRecordException() :
- std::runtime_error("Invalid history record")
- {
- }
+ public:
+ InvalidRecordException() : std::runtime_error("Invalid history record")
+ {
+ }
};
/**
@@ -49,157 +47,153 @@
*/
class RecordManager
{
- public:
+ public:
+ static constexpr auto RAW_RECORD_SIZE = 5;
+ static constexpr auto RAW_RECORD_ID_OFFSET = 0;
+ static constexpr auto FIRST_SEQUENCE_ID = 0;
+ static constexpr auto LAST_SEQUENCE_ID = 0xFF;
- static constexpr auto RAW_RECORD_SIZE = 5;
- static constexpr auto RAW_RECORD_ID_OFFSET = 0;
- static constexpr auto FIRST_SEQUENCE_ID = 0;
- static constexpr auto LAST_SEQUENCE_ID = 0xFF;
+ using DBusRecord = std::tuple<uint64_t, int64_t>;
+ using DBusRecordList = std::vector<DBusRecord>;
- using DBusRecord = std::tuple<uint64_t, int64_t>;
- using DBusRecordList = std::vector<DBusRecord>;
+ RecordManager() = delete;
+ ~RecordManager() = default;
+ RecordManager(const RecordManager&) = default;
+ RecordManager& operator=(const RecordManager&) = default;
+ RecordManager(RecordManager&&) = default;
+ RecordManager& operator=(RecordManager&&) = default;
- RecordManager() = delete;
- ~RecordManager() = default;
- RecordManager(const RecordManager&) = default;
- RecordManager& operator=(const RecordManager&) = default;
- RecordManager(RecordManager&&) = default;
- RecordManager& operator=(RecordManager&&) = default;
+ /**
+ * @brief Constructor
+ *
+ * @param[in] maxRec - the maximum number of history
+ * records to keep at a time
+ */
+ RecordManager(size_t maxRec) : RecordManager(maxRec, LAST_SEQUENCE_ID)
+ {
+ }
- /**
- * @brief Constructor
- *
- * @param[in] maxRec - the maximum number of history
- * records to keep at a time
- */
- RecordManager(size_t maxRec) :
- RecordManager(maxRec, LAST_SEQUENCE_ID)
- {
- }
+ /**
+ * @brief Constructor
+ *
+ * @param[in] maxRec - the maximum number of history
+ * records to keep at a time
+ * @param[in] lastSequenceID - the last sequence ID the power supply
+ * will use before starting over
+ */
+ RecordManager(size_t maxRec, size_t lastSequenceID) :
+ maxRecords(maxRec), lastSequenceID(lastSequenceID)
+ {
+ }
- /**
- * @brief Constructor
- *
- * @param[in] maxRec - the maximum number of history
- * records to keep at a time
- * @param[in] lastSequenceID - the last sequence ID the power supply
- * will use before starting over
- */
- RecordManager(size_t maxRec, size_t lastSequenceID) :
- maxRecords(maxRec),
- lastSequenceID(lastSequenceID)
- {
- }
+ /**
+ * @brief Adds a new entry to the history
+ *
+ * Also checks to see if the old history should be
+ * cleared, such as when there is an invalid record
+ * sequence ID or if there was no data from the PS.
+ *
+ * @param[in] rawRecord - the record data straight
+ * from the power supply
+ *
+ * @return bool - If there has been a change to the
+ * history records that needs to be
+ * reflected in D-Bus.
+ */
+ bool add(const std::vector<uint8_t>& rawRecord);
- /**
- * @brief Adds a new entry to the history
- *
- * Also checks to see if the old history should be
- * cleared, such as when there is an invalid record
- * sequence ID or if there was no data from the PS.
- *
- * @param[in] rawRecord - the record data straight
- * from the power supply
- *
- * @return bool - If there has been a change to the
- * history records that needs to be
- * reflected in D-Bus.
- */
- bool add(const std::vector<uint8_t>& rawRecord);
+ /**
+ * @brief Returns the history of average input power
+ * in a representation used by D-Bus.
+ *
+ * @return DBusRecordList - A list of averages with
+ * a timestamp for each entry.
+ */
+ DBusRecordList getAverageRecords();
- /**
- * @brief Returns the history of average input power
- * in a representation used by D-Bus.
- *
- * @return DBusRecordList - A list of averages with
- * a timestamp for each entry.
- */
- DBusRecordList getAverageRecords();
+ /**
+ * @brief Returns the history of maximum input power
+ * in a representation used by D-Bus.
+ *
+ * @return DBusRecordList - A list of maximums with
+ * a timestamp for each entry.
+ */
+ DBusRecordList getMaximumRecords();
- /**
- * @brief Returns the history of maximum input power
- * in a representation used by D-Bus.
- *
- * @return DBusRecordList - A list of maximums with
- * a timestamp for each entry.
- */
- DBusRecordList getMaximumRecords();
+ /**
+ * @brief Converts a Linear Format power number to an integer
+ *
+ * The PMBus spec describes a 2 byte Linear Format
+ * number that is composed of an exponent and mantissa
+ * in two's complement notation.
+ *
+ * Value = Mantissa * 2**Exponent
+ *
+ * @return int64_t the converted value
+ */
+ static int64_t linearToInteger(uint16_t data);
- /**
- * @brief Converts a Linear Format power number to an integer
- *
- * The PMBus spec describes a 2 byte Linear Format
- * number that is composed of an exponent and mantissa
- * in two's complement notation.
- *
- * Value = Mantissa * 2**Exponent
- *
- * @return int64_t the converted value
- */
- static int64_t linearToInteger(uint16_t data);
+ /**
+ * @brief Returns the number of records
+ *
+ * @return size_t - the number of records
+ *
+ */
+ inline size_t getNumRecords() const
+ {
+ return records.size();
+ }
- /**
- * @brief Returns the number of records
- *
- * @return size_t - the number of records
- *
- */
- inline size_t getNumRecords() const
- {
- return records.size();
- }
+ /**
+ * @brief Deletes all records
+ */
+ inline void clear()
+ {
+ records.clear();
+ }
- /**
- * @brief Deletes all records
- */
- inline void clear()
- {
- records.clear();
- }
+ private:
+ /**
+ * @brief returns the sequence ID from a raw history record
+ *
+ * Throws InvalidRecordException if the data is the wrong length.
+ *
+ * @param[in] data - the raw record data as the PS returns it
+ *
+ * @return size_t - the ID from byte 0
+ */
+ size_t getRawRecordID(const std::vector<uint8_t>& data) const;
- private:
+ /**
+ * @brief Creates an instance of a Record from the raw PS data
+ *
+ * @param[in] data - the raw record data as the PS returns it
+ *
+ * @return Record - A filled in Record instance
+ */
+ Record createRecord(const std::vector<uint8_t>& data);
- /**
- * @brief returns the sequence ID from a raw history record
- *
- * Throws InvalidRecordException if the data is the wrong length.
- *
- * @param[in] data - the raw record data as the PS returns it
- *
- * @return size_t - the ID from byte 0
- */
- size_t getRawRecordID(const std::vector<uint8_t>& data) const;
+ /**
+ * @brief The maximum number of entries to keep in the history.
+ *
+ * When a new record is added, the oldest one will be removed.
+ */
+ const size_t maxRecords;
- /**
- * @brief Creates an instance of a Record from the raw PS data
- *
- * @param[in] data - the raw record data as the PS returns it
- *
- * @return Record - A filled in Record instance
- */
- Record createRecord(const std::vector<uint8_t>& data);
+ /**
+ * @brief The last ID the power supply returns before rolling over
+ * back to the first ID of 0.
+ */
+ const size_t lastSequenceID;
- /**
- * @brief The maximum number of entries to keep in the history.
- *
- * When a new record is added, the oldest one will be removed.
- */
- const size_t maxRecords;
-
- /**
- * @brief The last ID the power supply returns before rolling over
- * back to the first ID of 0.
- */
- const size_t lastSequenceID;
-
- /**
- * @brief The list of timestamp/average/maximum records.
- * Newer records are added to the front, and older ones
- * removed from the back.
- */
- std::deque<Record> records;
+ /**
+ * @brief The list of timestamp/average/maximum records.
+ * Newer records are added to the front, and older ones
+ * removed from the back.
+ */
+ std::deque<Record> records;
};
-}
-}
-}
+} // namespace history
+} // namespace power
+} // namespace witherspoon
diff --git a/power-supply/test/test_records.cpp b/power-supply/test/test_records.cpp
index 20b638b..e500322 100644
--- a/power-supply/test/test_records.cpp
+++ b/power-supply/test/test_records.cpp
@@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <gtest/gtest.h>
-#include <iostream>
-#include "names_values.hpp"
#include "../record_manager.hpp"
+#include "names_values.hpp"
+
+#include <iostream>
+
+#include <gtest/gtest.h>
using namespace witherspoon::power::history;
@@ -29,41 +31,41 @@
*/
TEST(LinearFormatTest, TestConversions)
{
- //Mantissa > 0, exponent = 0
+ // Mantissa > 0, exponent = 0
EXPECT_EQ(0, RecordManager::linearToInteger(0));
EXPECT_EQ(1, RecordManager::linearToInteger(1));
EXPECT_EQ(38, RecordManager::linearToInteger(0x26));
EXPECT_EQ(1023, RecordManager::linearToInteger(0x3FF));
- //Mantissa < 0, exponent = 0
+ // Mantissa < 0, exponent = 0
EXPECT_EQ(-1, RecordManager::linearToInteger(0x7FF));
EXPECT_EQ(-20, RecordManager::linearToInteger(0x7EC));
EXPECT_EQ(-769, RecordManager::linearToInteger(0x4FF));
EXPECT_EQ(-989, RecordManager::linearToInteger(0x423));
EXPECT_EQ(-1024, RecordManager::linearToInteger(0x400));
- //Mantissa >= 0, exponent > 0
- //M = 1, E = 2
+ // Mantissa >= 0, exponent > 0
+ // M = 1, E = 2
EXPECT_EQ(4, RecordManager::linearToInteger(0x1001));
- //M = 1000, E = 10
+ // M = 1000, E = 10
EXPECT_EQ(1024000, RecordManager::linearToInteger(0x53E8));
- //M = 10, E = 15
+ // M = 10, E = 15
EXPECT_EQ(327680, RecordManager::linearToInteger(0x780A));
- //Mantissa >= 0, exponent < 0
- //M = 0, E = -1
+ // Mantissa >= 0, exponent < 0
+ // M = 0, E = -1
EXPECT_EQ(0, RecordManager::linearToInteger(0xF800));
- //M = 100, E = -2
+ // M = 100, E = -2
EXPECT_EQ(25, RecordManager::linearToInteger(0xF064));
- //Mantissa < 0, exponent < 0
- //M = -100, E = -1
+ // Mantissa < 0, exponent < 0
+ // M = -100, E = -1
EXPECT_EQ(-50, RecordManager::linearToInteger(0xFF9C));
- //M = -1024, E = -7
+ // M = -1024, E = -7
EXPECT_EQ(-8, RecordManager::linearToInteger(0xCC00));
}
@@ -76,10 +78,8 @@
*
* @return vector<uint8_t> the record buffer
*/
-std::vector<uint8_t> makeRawRecord(
- uint8_t sequenceID,
- uint16_t avgPower,
- uint16_t maxPower)
+std::vector<uint8_t> makeRawRecord(uint8_t sequenceID, uint16_t avgPower,
+ uint16_t maxPower)
{
std::vector<uint8_t> record;
@@ -92,13 +92,12 @@
return record;
}
-
/**
* Test record queue management
*/
TEST(ManagerTest, TestRecordAdds)
{
- //Hold 5 max records. IDs roll over at 8.
+ // Hold 5 max records. IDs roll over at 8.
RecordManager mgr{5, 8};
EXPECT_EQ(0, mgr.getNumRecords());
@@ -118,7 +117,7 @@
mgr.add(makeRawRecord(4, 0, 0));
EXPECT_EQ(5, mgr.getNumRecords());
- //start pruning
+ // start pruning
mgr.add(makeRawRecord(5, 0, 0));
EXPECT_EQ(5, mgr.getNumRecords());
@@ -131,30 +130,30 @@
mgr.add(makeRawRecord(8, 0, 0));
EXPECT_EQ(5, mgr.getNumRecords());
- //rollover
+ // rollover
mgr.add(makeRawRecord(0, 0, 0));
EXPECT_EQ(5, mgr.getNumRecords());
mgr.add(makeRawRecord(1, 0, 0));
EXPECT_EQ(5, mgr.getNumRecords());
- //nonsequential ID, clear previous
+ // nonsequential ID, clear previous
mgr.add(makeRawRecord(4, 0, 10));
EXPECT_EQ(1, mgr.getNumRecords());
- //back to normal
+ // back to normal
mgr.add(makeRawRecord(5, 1, 11));
EXPECT_EQ(2, mgr.getNumRecords());
- //One more good record
+ // One more good record
mgr.add(makeRawRecord(6, 2, 12));
EXPECT_EQ(3, mgr.getNumRecords());
- //Add a garbage length record. No size change
+ // Add a garbage length record. No size change
mgr.add(std::vector<uint8_t>(6, 0));
EXPECT_EQ(3, mgr.getNumRecords());
- //Test the DBus Records
+ // Test the DBus Records
auto avgRecords = mgr.getAverageRecords();
EXPECT_EQ(3, avgRecords.size());
@@ -175,8 +174,7 @@
max--;
}
- //Add a zero length record. Records cleared.
+ // Add a zero length record. Records cleared.
mgr.add(std::vector<uint8_t>{});
EXPECT_EQ(0, mgr.getNumRecords());
}
-
diff --git a/test/nvtest.cpp b/test/nvtest.cpp
index 2abdae9..a7a102b 100644
--- a/test/nvtest.cpp
+++ b/test/nvtest.cpp
@@ -13,15 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <gtest/gtest.h>
#include "names_values.hpp"
+#include <gtest/gtest.h>
+
TEST(NamesValuesTest, TestValues)
{
witherspoon::power::util::NamesValues nv;
std::string expected;
- EXPECT_EQ(nv.get(), expected); //empty
+ EXPECT_EQ(nv.get(), expected); // empty
nv.add("name1", 0);
nv.add("name2", 0xC0FFEE);
@@ -32,4 +33,3 @@
EXPECT_EQ(nv.get(), expected);
}
-
diff --git a/utility.cpp b/utility.cpp
index ac614d4..e9918bb 100644
--- a/utility.cpp
+++ b/utility.cpp
@@ -28,15 +28,11 @@
using namespace phosphor::logging;
-
-std::string getService(const std::string& path,
- const std::string& interface,
+std::string getService(const std::string& path, const std::string& interface,
sdbusplus::bus::bus& bus)
{
- auto method = bus.new_method_call(MAPPER_BUSNAME,
- MAPPER_PATH,
- MAPPER_INTERFACE,
- "GetObject");
+ auto method = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
+ MAPPER_INTERFACE, "GetObject");
method.append(path);
method.append(std::vector<std::string>({interface}));
@@ -45,8 +41,8 @@
if (reply.is_method_error())
{
log<level::ERR>("Error in mapper call to get service name",
- entry("PATH=%s", path.c_str()),
- entry("INTERFACE=%s", interface.c_str()));
+ 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 to get service name");
@@ -57,16 +53,15 @@
if (response.empty())
{
- log<level::ERR>(
- "Error in mapper response for getting service name",
- entry("PATH=%s", path.c_str()),
- entry("INTERFACE=%s", interface.c_str()));
+ log<level::ERR>("Error in mapper response for getting service name",
+ entry("PATH=%s", path.c_str()),
+ entry("INTERFACE=%s", interface.c_str()));
return std::string{};
}
return response.begin()->first;
}
-}
-}
-}
+} // namespace util
+} // namespace power
+} // namespace witherspoon
diff --git a/utility.hpp b/utility.hpp
index f3c62d1..ac7ef1f 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <phosphor-logging/log.hpp>
#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <string>
@@ -12,10 +12,10 @@
namespace util
{
-constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
-constexpr auto SYSTEMD_ROOT = "/org/freedesktop/systemd1";
+constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
+constexpr auto SYSTEMD_ROOT = "/org/freedesktop/systemd1";
constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
-constexpr auto POWEROFF_TARGET = "obmc-chassis-hard-poweroff@0.target";
+constexpr auto POWEROFF_TARGET = "obmc-chassis-hard-poweroff@0.target";
constexpr auto PROPERTY_INTF = "org.freedesktop.DBus.Properties";
/**
@@ -28,8 +28,7 @@
*
* @return The service name
*/
-std::string getService(const std::string& path,
- const std::string& interface,
+std::string getService(const std::string& path, const std::string& interface,
sdbusplus::bus::bus& bus);
/**
@@ -42,20 +41,15 @@
* @param[in] bus - the D-Bus object
* @param[out] value - filled in with the property value
*/
-template<typename T>
-void getProperty(const std::string& interface,
- const std::string& propertyName,
- const std::string& path,
- const std::string& service,
- sdbusplus::bus::bus& bus,
- T& value)
+template <typename T>
+void getProperty(const std::string& interface, const std::string& propertyName,
+ const std::string& path, const std::string& service,
+ sdbusplus::bus::bus& bus, T& value)
{
sdbusplus::message::variant<T> property;
- auto method = bus.new_method_call(service.c_str(),
- path.c_str(),
- PROPERTY_INTF,
- "Get");
+ auto method = bus.new_method_call(service.c_str(), path.c_str(),
+ PROPERTY_INTF, "Get");
method.append(interface, propertyName);
@@ -85,20 +79,15 @@
* @param[in] bus - the D-Bus object
* @param[in] value - the value to set the property to
*/
-template<typename T>
-void setProperty(const std::string& interface,
- const std::string& propertyName,
- const std::string& path,
- const std::string& service,
- sdbusplus::bus::bus& bus,
- T& value)
+template <typename T>
+void setProperty(const std::string& interface, const std::string& propertyName,
+ const std::string& path, const std::string& service,
+ sdbusplus::bus::bus& bus, T& value)
{
sdbusplus::message::variant<T> propertyValue(value);
- auto method = bus.new_method_call(service.c_str(),
- path.c_str(),
- PROPERTY_INTF,
- "Set");
+ auto method = bus.new_method_call(service.c_str(), path.c_str(),
+ PROPERTY_INTF, "Set");
method.append(interface, propertyName, propertyValue);
@@ -114,7 +103,6 @@
// TODO openbmc/openbmc#851 - Once available, throw returned error
throw std::runtime_error("Error in property set call");
}
-
}
/**
@@ -123,15 +111,13 @@
* @tparam T - error that will be logged before the power off
* @param[in] bus - D-Bus object
*/
-template<typename T>
+template <typename T>
void powerOff(sdbusplus::bus::bus& bus)
{
phosphor::logging::report<T>();
- auto method = bus.new_method_call(SYSTEMD_SERVICE,
- SYSTEMD_ROOT,
- SYSTEMD_INTERFACE,
- "StartUnit");
+ auto method = bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_ROOT,
+ SYSTEMD_INTERFACE, "StartUnit");
method.append(POWEROFF_TARGET);
method.append("replace");
@@ -139,6 +125,6 @@
bus.call_noreply(method);
}
-}
-}
-}
+} // namespace util
+} // namespace power
+} // namespace witherspoon