Re: [PATCHv2,net-next] net: xgbe: use device_get_mac_addr

From: Jakub Kicinski

Date: Mon Mar 09 2026 - 22:51:47 EST


This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: xgbe: use device_get_mac_addr

This commit refactors the MAC address retrieval code to use
device_get_mac_address() instead of device_property_read_u8_array() with
an explicit is_valid_ether_addr() check. It also removes the
XGBE_MAC_ADDR_PROPERTY definition since the new function supports multiple
MAC address properties.

> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-platform.c b/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
> index 47d53e59ccf6..f2db920fbaec 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
> @@ -252,11 +252,9 @@ static int xgbe_platform_probe(struct platform_device *pdev)
> dev_dbg(dev, "sir1_regs = %p\n", pdata->sir1_regs);
>
> /* Retrieve the MAC address */
> - ret = device_property_read_u8_array(dev, XGBE_MAC_ADDR_PROPERTY,
> - pdata->mac_addr,
> - sizeof(pdata->mac_addr));
> - if (ret || !is_valid_ether_addr(pdata->mac_addr)) {
> - dev_err(dev, "invalid %s property\n", XGBE_MAC_ADDR_PROPERTY);
> + ret = device_get_mac_address(dev, pdata->mac_addr);
> + if (ret) {
> + dev_err(dev, "invalid MAC address property\n");
> if (!ret)
^^^^^^^^

Is this check reachable? When execution enters the 'if (ret)' block above,
ret is guaranteed to be non-zero, so the nested 'if (!ret)' condition can
never be true.

The old code needed 'if (!ret) ret = -EINVAL;' because
device_property_read_u8_array() could return 0 with an invalid MAC address
(checked by the !is_valid_ether_addr() part of the condition).

The new device_get_mac_address() already returns an error when the MAC
address is invalid, so this conversion is no longer needed and the
condition can never execute.

> ret = -EINVAL;
> goto err_io;

[ ... ]
--
pw-bot: cr