From 894571d9a2a7b0ab1504c6f66e5e0b1a72a5d702 Mon Sep 17 00:00:00 2001 From: Patrick Venture Date: Thu, 9 Nov 2017 14:46:54 -0800 Subject: watchdog: cleanup style and similar fixes Some style cleanup. Change-Id: I4f8ce595294797cc015a55cc6c9477aee7b6938a Signed-off-by: Patrick Venture --- app/watchdog.cpp | 45 ++++++++++++++++++++++++++------------------- app/watchdog.hpp | 20 ++++++++++++++------ 2 files changed, 40 insertions(+), 25 deletions(-) (limited to 'app') diff --git a/app/watchdog.cpp b/app/watchdog.cpp index 0dad74f..84e8426 100644 --- a/app/watchdog.cpp +++ b/app/watchdog.cpp @@ -1,33 +1,40 @@ #include "watchdog.hpp" +#include "utils.hpp" #include + #include +#include extern sd_bus *bus; struct set_wd_data_t { - uint8_t t_use; - uint8_t t_action; + uint8_t timer_use; + uint8_t timer_action; uint8_t preset; uint8_t flags; uint8_t ls; uint8_t ms; } __attribute__ ((packed)); - - -ipmi_ret_t ipmi_app_set_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, ipmi_response_t response, - ipmi_data_len_t data_len, ipmi_context_t context) +static constexpr auto objname = "/xyz/openbmc_project/watchdog/host0"; +static constexpr auto iface = "xyz.openbmc_project.State.Watchdog"; +static constexpr auto property_iface = "org.freedesktop.DBus.Properties"; + +ipmi_ret_t ipmi_app_set_watchdog( + ipmi_netfn_t netfn, + ipmi_cmd_t cmd, + ipmi_request_t request, + ipmi_response_t response, + ipmi_data_len_t data_len, + ipmi_context_t context) { - const char *objname = "/xyz/openbmc_project/watchdog/host0"; - const char *iface = "xyz.openbmc_project.State.Watchdog"; - const char *property_iface = "org.freedesktop.DBus.Properties"; sd_bus_message *reply = NULL; sd_bus_error error = SD_BUS_ERROR_NULL; int r = 0; set_wd_data_t *reqptr = (set_wd_data_t*) request; + uint16_t timer = 0; // Making this uint64_t to match with provider @@ -65,12 +72,12 @@ ipmi_ret_t ipmi_app_set_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd, * expiration aren't supported by phosphor-watchdog yet, so when the * action set is "none", we should just leave the timer disabled. */ - if (0 == reqptr->t_action) + if (0 == reqptr->timer_action) { goto finish; } - if (reqptr->t_use & 0x40) + if (reqptr->timer_use & 0x40) { sd_bus_error_free(&error); reply = sd_bus_message_unref(reply); @@ -104,14 +111,14 @@ finish: return (r < 0) ? -1 : IPMI_CC_OK; } - -ipmi_ret_t ipmi_app_reset_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, ipmi_response_t response, - ipmi_data_len_t data_len, ipmi_context_t context) +ipmi_ret_t ipmi_app_reset_watchdog( + ipmi_netfn_t netfn, + ipmi_cmd_t cmd, + ipmi_request_t request, + ipmi_response_t response, + ipmi_data_len_t data_len, + ipmi_context_t context) { - const char *objname = "/xyz/openbmc_project/watchdog/host0"; - const char *iface = "xyz.openbmc_project.State.Watchdog"; - const char *property_iface = "org.freedesktop.DBus.Properties"; sd_bus_message *reply = NULL; sd_bus_error error = SD_BUS_ERROR_NULL; int r = 0; diff --git a/app/watchdog.hpp b/app/watchdog.hpp index 059a4e7..f434493 100644 --- a/app/watchdog.hpp +++ b/app/watchdog.hpp @@ -11,9 +11,13 @@ * * @return IPMI_CC_OK on success, -1 otherwise. */ -ipmi_ret_t ipmi_app_set_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, ipmi_response_t response, - ipmi_data_len_t data_len, ipmi_context_t context); +ipmi_ret_t ipmi_app_set_watchdog( + ipmi_netfn_t netfn, + ipmi_cmd_t cmd, + ipmi_request_t request, + ipmi_response_t response, + ipmi_data_len_t data_len, + ipmi_context_t context); /** @brief The RESET watchdog IPMI command. * @@ -26,7 +30,11 @@ ipmi_ret_t ipmi_app_set_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd, * * @return IPMI_CC_OK on success, -1 otherwise. */ -ipmi_ret_t ipmi_app_reset_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, ipmi_response_t response, - ipmi_data_len_t data_len, ipmi_context_t context); +ipmi_ret_t ipmi_app_reset_watchdog( + ipmi_netfn_t netfn, + ipmi_cmd_t cmd, + ipmi_request_t request, + ipmi_response_t response, + ipmi_data_len_t data_len, + ipmi_context_t context); -- cgit v1.2.1