mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Stefan Riedmueller <s.riedmueller@phytec.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] net: eth: of_fixup_node: Use reproducible node name for fixup
Date: Tue, 30 Mar 2021 07:40:17 +0200	[thread overview]
Message-ID: <20210330054017.GK609@pengutronix.de> (raw)
In-Reply-To: <20210329131048.66199-1-s.riedmueller@phytec.de>

On Mon, Mar 29, 2021 at 03:10:48PM +0200, Stefan Riedmueller wrote:
> To be able to fixup older devicetrees, prior to v4.15 where leading
> zeros of the unit addresses were removed, use the reproducible name to
> find the corresponding nodes.

Who would ever run such an old kernel ;)
Anyway, applied, thanks

Sascha

> 
> Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
> ---
>  net/eth.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/net/eth.c b/net/eth.c
> index 626b35d5cc65..84f99d3aa822 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -304,7 +304,8 @@ static void eth_of_fixup_node(struct device_node *root,
>  			      const char *node_path, int ethid,
>  			      const u8 ethaddr[ETH_ALEN])
>  {
> -	struct device_node *node;
> +	struct device_node *bb_node, *fixup_node;
> +	char *name;
>  	int ret;
>  
>  	if (!is_valid_ether_addr(ethaddr)) {
> @@ -314,22 +315,25 @@ static void eth_of_fixup_node(struct device_node *root,
>  	}
>  
>  	if (node_path) {
> -		node = of_find_node_by_path_from(root, node_path);
> +		bb_node = of_find_node_by_path_from(0, node_path);
> +		name = of_get_reproducible_name(bb_node);
> +		fixup_node = of_find_node_by_reproducible_name(root, name);
> +		free(name);
>  	} else {
>  		char eth[12];
>  		sprintf(eth, "ethernet%d", ethid);
> -		node = of_find_node_by_alias(root, eth);
> +		fixup_node = of_find_node_by_alias(root, eth);
>  	}
>  
> -	if (!node) {
> +	if (!fixup_node) {
>  		pr_debug("%s: no node to fixup\n", __func__);
>  		return;
>  	}
>  
> -	ret = of_set_property(node, "mac-address", ethaddr, ETH_ALEN, 1);
> +	ret = of_set_property(fixup_node, "mac-address", ethaddr, ETH_ALEN, 1);
>  	if (ret)
>  		pr_err("Setting mac-address property of %s failed with: %s\n",
> -		       node->full_name, strerror(-ret));
> +		       fixup_node->full_name, strerror(-ret));
>  }
>  
>  static int eth_of_fixup(struct device_node *root, void *unused)
> -- 
> 2.25.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


      reply	other threads:[~2021-03-30  5:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 13:10 Stefan Riedmueller
2021-03-30  5:40 ` Sascha Hauer [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=20210330054017.GK609@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.riedmueller@phytec.de \
    /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