From patchwork Thu Nov 24 11:15:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 25456 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3334426wrr; Thu, 24 Nov 2022 03:23:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ibmKuQtVDsC93f2K/H54bcOXxIHR5TKhjCeOtTFp2WJSYGFz4ijH83FdHyImWgFFQ8aC+ X-Received: by 2002:aa7:928f:0:b0:56d:2e71:449 with SMTP id j15-20020aa7928f000000b0056d2e710449mr14578441pfa.46.1669289005855; Thu, 24 Nov 2022 03:23:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669289005; cv=none; d=google.com; s=arc-20160816; b=lefWJW8729OpAo8H3QLM22DBeeFqoaEnn1rzarApVIz4TKJMT+EwkM60jbInHRBPDa ivFTNCzleQXoPIMD22rfiL9by7TeG7eX2mTyhBCnsE+XXHums3GOHpk10Z21PpNNls7p I08NX+AFqjxtNnePe0NEdXu0W2lYq7h9bZGVgCm0arbtJVrV+vx8KXWRPrEL3qzonwUS KcvSKu4haewVYsxNtzZfiBz0bLEg6OMGkTopJT4ii9YsGGEDeWyPIIKfpLHJLRnTZnvD z+kxqs3g5SXz2yqRzRrH+VFbSJa7M3+DSuCgjHME50f1AV2z3JouYhN6L0ewTdE+MVsD FLZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EiTXZxb081Yq5NNkWBz6w6sjlyDhWaDs7oz/56WKrNA=; b=vNHQSNT5HNJof6HvALSLETfjhWfXXsHBYg1gs1qNs5Mue/Rioq8/rQppmibyOWRK7N 99DyKeFDXwu4K6WTIzcEmcW7g0moxpx7E7y1+RnUJJ3WGx1Yp+Bk/8HLNz2v5RVJ9bkB pMwAiIyfEeyPWQlsci6WwZP+UIQ4s6bMLEy0JeC/7tSScPllZPdqFHQ1GWda02/zt2xh dlo9+qG+/Q9bkjiDuAnHeRyUYTmzNUcccHRx/9r4p61cfRf0n5C7D6ncudHB05pc6U1p niD+MmNdxZPa3XlEfYoqXryYJFmqi+A1w5Mn67On0uAn6QSYKhV9KY1r7KW8Ph1R4gFN ZmuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=g6cCQ7NX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w9-20020a056a0014c900b00561f40cc9f3si887763pfu.262.2022.11.24.03.23.13; Thu, 24 Nov 2022 03:23:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=g6cCQ7NX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229999AbiKXLQq (ORCPT + 99 others); Thu, 24 Nov 2022 06:16:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230099AbiKXLQ2 (ORCPT ); Thu, 24 Nov 2022 06:16:28 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC3176F826; Thu, 24 Nov 2022 03:16:19 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 150021C0015; Thu, 24 Nov 2022 11:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669288578; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EiTXZxb081Yq5NNkWBz6w6sjlyDhWaDs7oz/56WKrNA=; b=g6cCQ7NXhnUcgl988YxE3QGXEixPtGLZOTuUK6YFKhgWt03pDE5uiY/NST0TATTajDWrAG tmLNkCqwPTXbUcrMY5MMxeZ4aGK5vwVz1drzLyR9XcU46Rx2i9FgfDAA/jAdYLXreJcacz rtmwIWWOdJP4uuOLns20UmGbjUkOB5GeP7hA/kPjwiaRYMtNN/Ep7n9fS/MZqpoJUFC4mD K99iF/a0y/0VQnka/nUlBhZiTsmepsvt5DbTLA5WUbYQNgos7mYmkx/yXVv5BgClYvMfjP LDJr9cemr/bhDxVwjI8zrJE+mMVkmyETxhGLhFOB9nWQU478bPRHLfUGvJauiA== From: Miquel Raynal To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, Robert Marko , Luka Perkov , Thomas Petazzoni , Michael Walle , Marcin Wojtas , , , Vadym Kochan , Miquel Raynal Subject: [PATCH net-next v2 6/7] net: marvell: prestera: Avoid unnecessary DT lookups Date: Thu, 24 Nov 2022 12:15:55 +0100 Message-Id: <20221124111556.264647-7-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221124111556.264647-1-miquel.raynal@bootlin.com> References: <20221124111556.264647-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750376388538555158?= X-GMAIL-MSGID: =?utf-8?q?1750376388538555158?= 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 --- .../net/ethernet/marvell/prestera/prestera_main.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c index 24f9d6024745..d4b48f674a88 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_main.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c @@ -862,17 +862,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"); @@ -1376,7 +1369,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) {