net: marvell: prestera: Avoid unnecessary DT lookups
authorMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 24 Nov 2022 11:15:55 +0000 (12:15 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 29 Nov 2022 09:45:54 +0000 (10:45 +0100)
This driver fist makes an expensive DT lookup to retrieve its DT node
(this is a PCI driver) in order to later search for the
base-mac-provider property. This property has no reality upstream and
this code should not have been accepted like this in the first
place. Instead, there is a proper nvmem interface that should be
used. Let's avoid these extra lookups and rely on the nvmem internal
logic.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/marvell/prestera/prestera_main.c

index f8deaee84398f229a07c5e4f635dabfca1a83bd1..8343f203ff2373f76a33d78467f096fe65103543 100644 (file)
@@ -858,17 +858,10 @@ static void prestera_event_handlers_unregister(struct prestera_switch *sw)
 
 static int prestera_switch_set_base_mac_addr(struct prestera_switch *sw)
 {
-       struct device_node *base_mac_np;
-       int ret = 0;
-
-       if (sw->np) {
-               base_mac_np = of_parse_phandle(sw->np, "base-mac-provider", 0);
-               if (base_mac_np) {
-                       ret = of_get_mac_address(base_mac_np, sw->base_mac);
-                       of_node_put(base_mac_np);
-               }
-       }
+       int ret;
 
+       if (sw->np)
+               ret = of_get_mac_address(sw->np, sw->base_mac);
        if (!is_valid_ether_addr(sw->base_mac) || ret) {
                eth_random_addr(sw->base_mac);
                dev_info(prestera_dev(sw), "using random base mac address\n");
@@ -1372,7 +1365,7 @@ static int prestera_switch_init(struct prestera_switch *sw)
 {
        int err;
 
-       sw->np = of_find_compatible_node(NULL, NULL, "marvell,prestera");
+       sw->np = sw->dev->dev->of_node;
 
        err = prestera_hw_switch_init(sw);
        if (err) {