Add a helper htoipmi24() function

The function converts a host 32-bit integer into an IPMI
24-bit value (LSB first).

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
Alexander Amelkin 2019-05-27 20:07:58 +03:00 committed by Alexander Amelkin
parent e11f463b4e
commit c9510635d7

View File

@ -169,6 +169,13 @@ static inline uint32_t ipmi24toh(void *ipmi24)
return h; return h;
} }
static inline void htoipmi24(uint32_t h, uint8_t *ipmi)
{
ipmi[0] = h & 0xFF; /* LSB */
ipmi[1] = (h >> 8) & 0xFF;
ipmi[2] = (h >> 16) & 0xFF; /* MSB */
}
static inline uint32_t ipmi32toh(void *ipmi32) static inline uint32_t ipmi32toh(void *ipmi32)
{ {
uint8_t *ipmi = ipmi32; uint8_t *ipmi = ipmi32;