From c19a9a52783f7ed14fbe5beb7f1be15706222578 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Tue, 10 Nov 2020 17:08:11 +0100 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/47404 Tested-by: siemens-bot Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh --- src/drivers/intel/i210/i210.h | 5 +++-- src/mainboard/siemens/mc_apl1/mainboard.c | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/drivers/intel/i210/i210.h b/src/drivers/intel/i210/i210.h index 718992e477..1cc6a28a0b 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 5b8f70f353..ff0cc597bc 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 @@ static uint8_t is_mac_adr_valid(uint8_t mac[6]) * @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 @@ enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[6]) 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; }