Skip to content

Commit a48acad

Browse files
miquelraynalPaolo Abeni
authored andcommitted
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: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 4c47867 commit a48acad

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

drivers/net/ethernet/marvell/prestera/prestera_main.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -858,17 +858,10 @@ static void prestera_event_handlers_unregister(struct prestera_switch *sw)
858858

859859
static int prestera_switch_set_base_mac_addr(struct prestera_switch *sw)
860860
{
861-
struct device_node *base_mac_np;
862-
int ret = 0;
863-
864-
if (sw->np) {
865-
base_mac_np = of_parse_phandle(sw->np, "base-mac-provider", 0);
866-
if (base_mac_np) {
867-
ret = of_get_mac_address(base_mac_np, sw->base_mac);
868-
of_node_put(base_mac_np);
869-
}
870-
}
861+
int ret;
871862

863+
if (sw->np)
864+
ret = of_get_mac_address(sw->np, sw->base_mac);
872865
if (!is_valid_ether_addr(sw->base_mac) || ret) {
873866
eth_random_addr(sw->base_mac);
874867
dev_info(prestera_dev(sw), "using random base mac address\n");
@@ -1372,7 +1365,7 @@ static int prestera_switch_init(struct prestera_switch *sw)
13721365
{
13731366
int err;
13741367

1375-
sw->np = of_find_compatible_node(NULL, NULL, "marvell,prestera");
1368+
sw->np = sw->dev->dev->of_node;
13761369

13771370
err = prestera_hw_switch_init(sw);
13781371
if (err) {

0 commit comments

Comments
 (0)