common: Ensure helpers are endian-safe

The specification states that all multibyte values communicated via mbox
are little-endian[0]. Do the conversions in the helpers to enforce this
property.

[0] https://github.com/openbmc/mboxbridge/blob/master/Documentation/mbox_protocol.md#information

Change-Id: I9f96281c439fd666cb1c9ae643454569d61f7a81
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/common.c b/common.c
index b562cc9..c460815 100644
--- a/common.c
+++ b/common.c
@@ -54,21 +54,23 @@
 
 uint16_t get_u16(uint8_t *ptr)
 {
-	return *(uint16_t *)ptr;
+	return le16toh(*(uint16_t *)ptr);
 }
 
 void put_u16(uint8_t *ptr, uint16_t val)
 {
+	val = htole16(val);
 	memcpy(ptr, &val, sizeof(val));
 }
 
 uint32_t get_u32(uint8_t *ptr)
 {
-	return *(uint32_t *)ptr;
+	return le32toh(*(uint32_t *)ptr);
 }
 
 void put_u32(uint8_t *ptr, uint32_t val)
 {
+	val = htole32(val);
 	memcpy(ptr, &val, sizeof(val));
 }