public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: rosenp@gmail.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, edumazet@google.com,
	Raju.Rangoju@amd.com, linux-kernel@vger.kernel.org (open list),
	pabeni@redhat.com, andrew+netdev@lunn.ch, davem@davemloft.net
Subject: Re: [PATCHv2,net-next] net: xgbe: use device_get_mac_addr
Date: Mon,  9 Mar 2026 19:51:27 -0700	[thread overview]
Message-ID: <20260310025127.3751023-1-kuba@kernel.org> (raw)
In-Reply-To: <20260307032227.640904-1-rosenp@gmail.com>

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

      reply	other threads:[~2026-03-10  2:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-07  3:22 [PATCHv2 net-next] net: xgbe: use device_get_mac_addr Rosen Penev
2026-03-10  2:51 ` Jakub Kicinski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260310025127.3751023-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=Raju.Rangoju@amd.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rosenp@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox