Commit a48acad7 authored by Miquel Raynal's avatar Miquel Raynal Committed by Paolo Abeni

net: marvell: prestera: Avoid unnecessary DT lookups

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: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 4c47867b
...@@ -858,17 +858,10 @@ static void prestera_event_handlers_unregister(struct prestera_switch *sw) ...@@ -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) static int prestera_switch_set_base_mac_addr(struct prestera_switch *sw)
{ {
struct device_node *base_mac_np; int ret;
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);
}
}
if (sw->np)
ret = of_get_mac_address(sw->np, sw->base_mac);
if (!is_valid_ether_addr(sw->base_mac) || ret) { if (!is_valid_ether_addr(sw->base_mac) || ret) {
eth_random_addr(sw->base_mac); eth_random_addr(sw->base_mac);
dev_info(prestera_dev(sw), "using random base mac address\n"); dev_info(prestera_dev(sw), "using random base mac address\n");
...@@ -1372,7 +1365,7 @@ static int prestera_switch_init(struct prestera_switch *sw) ...@@ -1372,7 +1365,7 @@ static int prestera_switch_init(struct prestera_switch *sw)
{ {
int err; 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); err = prestera_hw_switch_init(sw);
if (err) { if (err) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment