From: Vladimir Oltean Date: Sat, 13 Mar 2021 15:03:16 +0200 Subject: [PATCH v2 02/21] of: extra: Introduce ofnode_phy_is_fixed_link() API In-Reply-To: <20210312133602.31105-3-bmeng.cn@gmail.com> References: <20210312133602.31105-1-bmeng.cn@gmail.com> <20210312133602.31105-3-bmeng.cn@gmail.com> Message-ID: <20210313130316.olj7iburjpef3p26@skbuf> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Fri, Mar 12, 2021 at 09:35:43PM +0800, Bin Meng wrote: > +bool ofnode_phy_is_fixed_link(ofnode eth_node, ofnode *phy_node) > +{ > + bool found = false; > + ofnode node, subnode; > + int len; > + > + /* new binding */ > + subnode = ofnode_find_subnode(eth_node, "fixed-link"); > + if (ofnode_valid(subnode)) { > + node = subnode; > + found = true; > + } > + > + /* old binding */ > + if (ofnode_get_property(eth_node, "fixed-link", &len) && Maybe "else if" here? If an old-style and a new-style binding exist, we should prefer looking at the new one. And with that "else if", we could remove the "found" variable: if (ofnode_valid(subnode)) { } else if (ofnode_get_property(eth_node, "fixed-link", &len) && len == (5 * sizeof(__be32))) { } else { return false; } if (phy_node) *phy_node = node; > + len == (5 * sizeof(__be32))) { > + node = eth_node; > + found = true; > + } > + > + if (found && phy_node) > + *phy_node = node; > + > + return found; > +}