* [PATCH 1/2 v2] net: eth: Refactor OF tree fixup of one node into new function
@ 2015-10-21 19:37 Trent Piepho
2015-10-22 7:08 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Trent Piepho @ 2015-10-21 19:37 UTC (permalink / raw)
To: barebox
Code that fixes up one node with a new MAC address is refactored into
a new function that eth_of_fixup() calls in a loop.
Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
---
net/eth.c | 62 ++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 34 insertions(+), 28 deletions(-)
diff --git a/net/eth.c b/net/eth.c
index b22e556..befa8d8 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -289,42 +289,48 @@ static int eth_param_set_ethaddr(struct param_d *param, void *priv)
}
#ifdef CONFIG_OFTREE
-static int eth_of_fixup(struct device_node *root, void *unused)
+static void eth_of_fixup_node(struct device_node *root,
+ const char *node_path, int ethid,
+ const u8 ethaddr[6])
{
- struct eth_device *edev;
struct device_node *node;
int ret;
+ if (!is_valid_ether_addr(ethaddr)) {
+ pr_debug("%s: no valid mac address, cannot fixup\n",
+ __func__);
+ return;
+ }
+
+ if (node_path) {
+ node = of_find_node_by_path_from(root, node_path);
+ } else {
+ char eth[12];
+ sprintf(eth, "ethernet%d", ethid);
+ node = of_find_node_by_alias(root, eth);
+ }
+
+ if (!node) {
+ pr_debug("%s: no node to fixup\n", __func__);
+ return;
+ }
+
+ ret = of_set_property(node, "mac-address", ethaddr, 6, 1);
+ if (ret)
+ pr_err("Setting mac-address property of %s failed with: %s\n",
+ node->full_name, strerror(-ret));
+}
+
+static int eth_of_fixup(struct device_node *root, void *unused)
+{
+ struct eth_device *edev;
+
/*
* Add the mac-address property for each network device we
* find a nodepath for and which has a valid mac address.
*/
- list_for_each_entry(edev, &netdev_list, list) {
- if (!is_valid_ether_addr(edev->ethaddr)) {
- dev_dbg(&edev->dev,
- "%s: no valid mac address, cannot fixup\n",
- __func__);
- continue;
- }
-
- if (edev->nodepath) {
- node = of_find_node_by_path_from(root, edev->nodepath);
- } else {
- char eth[12];
- sprintf(eth, "ethernet%d", edev->dev.id);
- node = of_find_node_by_alias(root, eth);
- }
-
- if (!node) {
- dev_dbg(&edev->dev, "%s: no node to fixup\n", __func__);
- continue;
- }
-
- ret = of_set_property(node, "mac-address", edev->ethaddr, 6, 1);
- if (ret)
- pr_err("Setting mac-address property of %s failed with: %s\n",
- node->full_name, strerror(-ret));
- }
+ list_for_each_entry(edev, &netdev_list, list)
+ eth_of_fixup_node(root, edev->nodepath, edev->dev.id, edev->ethaddr);
return 0;
}
--
1.8.3.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/2 v2] net: eth: Refactor OF tree fixup of one node into new function
2015-10-21 19:37 [PATCH 1/2 v2] net: eth: Refactor OF tree fixup of one node into new function Trent Piepho
@ 2015-10-22 7:08 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-10-22 7:08 UTC (permalink / raw)
To: Trent Piepho; +Cc: barebox
On Wed, Oct 21, 2015 at 07:37:00PM +0000, Trent Piepho wrote:
> Code that fixes up one node with a new MAC address is refactored into
> a new function that eth_of_fixup() calls in a loop.
>
> Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
> ---
> net/eth.c | 62 ++++++++++++++++++++++++++++++++++----------------------------
> 1 file changed, 34 insertions(+), 28 deletions(-)
Applied, thanks. Also applied 2/2.
Sascha
>
> diff --git a/net/eth.c b/net/eth.c
> index b22e556..befa8d8 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -289,42 +289,48 @@ static int eth_param_set_ethaddr(struct param_d *param, void *priv)
> }
>
> #ifdef CONFIG_OFTREE
> -static int eth_of_fixup(struct device_node *root, void *unused)
> +static void eth_of_fixup_node(struct device_node *root,
> + const char *node_path, int ethid,
> + const u8 ethaddr[6])
> {
> - struct eth_device *edev;
> struct device_node *node;
> int ret;
>
> + if (!is_valid_ether_addr(ethaddr)) {
> + pr_debug("%s: no valid mac address, cannot fixup\n",
> + __func__);
> + return;
> + }
> +
> + if (node_path) {
> + node = of_find_node_by_path_from(root, node_path);
> + } else {
> + char eth[12];
> + sprintf(eth, "ethernet%d", ethid);
> + node = of_find_node_by_alias(root, eth);
> + }
> +
> + if (!node) {
> + pr_debug("%s: no node to fixup\n", __func__);
> + return;
> + }
> +
> + ret = of_set_property(node, "mac-address", ethaddr, 6, 1);
> + if (ret)
> + pr_err("Setting mac-address property of %s failed with: %s\n",
> + node->full_name, strerror(-ret));
> +}
> +
> +static int eth_of_fixup(struct device_node *root, void *unused)
> +{
> + struct eth_device *edev;
> +
> /*
> * Add the mac-address property for each network device we
> * find a nodepath for and which has a valid mac address.
> */
> - list_for_each_entry(edev, &netdev_list, list) {
> - if (!is_valid_ether_addr(edev->ethaddr)) {
> - dev_dbg(&edev->dev,
> - "%s: no valid mac address, cannot fixup\n",
> - __func__);
> - continue;
> - }
> -
> - if (edev->nodepath) {
> - node = of_find_node_by_path_from(root, edev->nodepath);
> - } else {
> - char eth[12];
> - sprintf(eth, "ethernet%d", edev->dev.id);
> - node = of_find_node_by_alias(root, eth);
> - }
> -
> - if (!node) {
> - dev_dbg(&edev->dev, "%s: no node to fixup\n", __func__);
> - continue;
> - }
> -
> - ret = of_set_property(node, "mac-address", edev->ethaddr, 6, 1);
> - if (ret)
> - pr_err("Setting mac-address property of %s failed with: %s\n",
> - node->full_name, strerror(-ret));
> - }
> + list_for_each_entry(edev, &netdev_list, list)
> + eth_of_fixup_node(root, edev->nodepath, edev->dev.id, edev->ethaddr);
>
> return 0;
> }
> --
> 1.8.3.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-22 7:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-21 19:37 [PATCH 1/2 v2] net: eth: Refactor OF tree fixup of one node into new function Trent Piepho
2015-10-22 7:08 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox