Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/47404 )
Change subject: drivers/intel/i210: Define MAC_ADDR_LEN ......................................................................
drivers/intel/i210: Define MAC_ADDR_LEN
Define and use the MAC_ADDR_LEN macro in place of the `6` magic value.
Change-Id: Icfa2ad9bca6668bea3d84b10f613d01e437ac6a2 Signed-off-by: Angel Pons th3fanbus@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/47404 Tested-by: siemens-bot Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Werner Zeh werner.zeh@siemens.com --- M src/drivers/intel/i210/i210.h M src/mainboard/siemens/mc_apl1/mainboard.c 2 files changed, 7 insertions(+), 6 deletions(-)
Approvals: build bot (Jenkins): Verified siemens-bot: Verified Werner Zeh: Looks good to me, approved
diff --git a/src/drivers/intel/i210/i210.h b/src/drivers/intel/i210/i210.h index 718992e..1cc6a28 100644 --- a/src/drivers/intel/i210/i210.h +++ b/src/drivers/intel/i210/i210.h @@ -27,9 +27,10 @@ #define I210_CHECKSUM_ERROR 0x00000010 #define I210_FLASH_UPDATE_ERROR 0x00000020
+#define MAC_ADDR_LEN 6 + /* We need one function we can call to get a MAC address to use */ /* This function can be coded somewhere else but must exist. */ -extern enum cb_err mainboard_get_mac_address(struct device *dev, - uint8_t mac[6]); +extern enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[MAC_ADDR_LEN]);
#endif /* _INTEL_I210_H_ */ diff --git a/src/mainboard/siemens/mc_apl1/mainboard.c b/src/mainboard/siemens/mc_apl1/mainboard.c index 5b8f70f..ff0cc59 100644 --- a/src/mainboard/siemens/mc_apl1/mainboard.c +++ b/src/mainboard/siemens/mc_apl1/mainboard.c @@ -33,9 +33,9 @@ * @param mac Buffer to the MAC address to check * @return 0 if address is not valid, otherwise 1 */ -static uint8_t is_mac_adr_valid(uint8_t mac[6]) +static uint8_t is_mac_adr_valid(uint8_t mac[MAC_ADDR_LEN]) { - uint8_t buf[6]; + uint8_t buf[MAC_ADDR_LEN];
memset(buf, 0, sizeof(buf)); if (!memcmp(buf, mac, sizeof(buf))) @@ -52,7 +52,7 @@ * @param mac buffer where to store the MAC address * @return cb_err CB_ERR or CB_SUCCESS */ -enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[6]) +enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[MAC_ADDR_LEN]) { struct bus *parent = dev->bus; uint8_t buf[16], mapping[16], i = 0, chain_len = 0; @@ -92,7 +92,7 @@ if (memcmp(buf, mapping, chain_len + 4)) continue; /* There is a matching mapping available, get MAC address. */ - if (hwilib_get_field(XMac1 + i, mac, 6) == 6) { + if (hwilib_get_field(XMac1 + i, mac, MAC_ADDR_LEN) == MAC_ADDR_LEN) { if (is_mac_adr_valid(mac)) return CB_SUCCESS; }