nm: Refactor to reduce code duplication

Add nm_set_id() and nm_check_id() functions, use them and
the existing htoipmi24() to reduce code duplication.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
Alexander Amelkin
2019-02-22 18:12:30 +03:00
parent e0811437a2
commit be9f1660fb
2 changed files with 33 additions and 47 deletions

View File

@@ -19,6 +19,7 @@
#pragma once
#include <ipmitool/ipmi.h>
#include <ipmitool/helper.h>
/* Configuration and control commands per
* Intel Intelligent Power Node Manager 2.0
@@ -41,6 +42,9 @@
#define IPMI_NM_GET_ALERT_DS 0xCF
#define IPMI_NM_LIMITING 0xF2
/* Node Manager identification */
#define IPMI_NM_ID 0x000157 /* Three bytes */
/* Node Manager Policy Control Flags */
#define IPMI_NM_GLOBAL_ENABLE 0x01
#define IPMI_NM_DOMAIN_ENABLE 0x02
@@ -169,3 +173,13 @@ struct nm_suspend {
} __attribute__ ((packed));
int ipmi_nm_main(struct ipmi_intf *intf, int argc, char **argv);
static inline void nm_set_id(void *buf)
{
htoipmi24(IPMI_NM_ID, buf);
}
static inline bool nm_check_id(void *buf)
{
return IPMI_NM_ID == ipmi24toh(buf);
}