From patchwork Thu Nov 17 21:55:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 21954 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp641507wrr; Thu, 17 Nov 2022 13:58:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf6tFbHZsiQWKCqEJgmuLkF0igsgm52Ei4o/C0nAa1r0J9RZd0qU99LxHOncuQvVztpPKuWL X-Received: by 2002:a63:ef42:0:b0:438:a46b:63f2 with SMTP id c2-20020a63ef42000000b00438a46b63f2mr3949920pgk.572.1668722309931; Thu, 17 Nov 2022 13:58:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668722309; cv=none; d=google.com; s=arc-20160816; b=YREOVN1ooIKYjbDtyO9QOy5Qj0yW2wrr+Pt7qex+V44GiMXIvoVvae3tVE4wU5CPb7 SIfwL4Qx2Eztbz6jTGnl31fijHpmzQK2BHM3AfEjGGzIT/82mf+UH4st2XwQBM9V5w96 i+ntDqpMVK1r6Xd+jAJ78roKV2eAL6271xSYrI2oVbeT3uasbMsgQrWK0sxKWwvyTmSr f7+bQVf7t6vWWSH4TVKaS93neZ6M4FB+OaggVqbNIW1zTv1gcMifiObKZfGWTP7oKXmx XGRzR3bAfdukqVPIlujpI9GCgsLPhY0nBmOTZ7YdVrC61+dCrRbybBSrhE4ZDG0BasK1 j4Cg== 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=BzhXw/tnnpe7aL2I4cC8lBzOf7SS+z1zU31LdK/TUCQVJSnbjoAEAIYJkp/UuBHhjr 6QzXA6vjOlTT+3jSOmvABytp+YJlXcXU/WOU4uZTPxsckJLBW3K3AzeHzvdVx1uwwjMz XBbqSesyOAPYzuMUiSd+Pvd+DdzfYYzijFCXV4T2xT8fkc+UQZzqOUSvdVmtEcGzVaB3 bdGPKvrrgAbLH9e8Ypc/ZQ+qTR0E1tQrd36+KZtC89eMjBG0x4oa9wIhVYYab6TtPGjT Ys13avJMW6Oj9Gfk9Y+LTXHaMVZsHmwICBRcu1ypNDRdgVPA71M6wc8DeLxLZbEvoU+p EEOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=G5Tf20En; 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 c22-20020a631c16000000b0046efd063864si2012069pgc.109.2022.11.17.13.58.17; Thu, 17 Nov 2022 13:58:29 -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=G5Tf20En; 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 S241075AbiKQV5G (ORCPT + 99 others); Thu, 17 Nov 2022 16:57:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240975AbiKQV4M (ORCPT ); Thu, 17 Nov 2022 16:56:12 -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 6AA117208F; Thu, 17 Nov 2022 13:56:11 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 601D31C0005; Thu, 17 Nov 2022 21:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668722170; 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=G5Tf20EnfkAQSv27n4L27uE2jLAH3+81NXSpi6NWygE3N22a/E6UYI1OkS0qhQ6p0XATsZ OPgAj40ILTgLbMhYyOILXCWyqeNH5ghkwi0PDyRbiSgRTHrrLB1i3cQq5Th0BkZfVaCGiu S3IOVFhGA6mLXf/TmkBUZekrK4Iegw4TzCtkOWmTTn8lY8szMq6XVb0XRyHSptCCOW2xFb LLfClmSu/h3Eu6KiMpzWmc65cV9dMBh7wyMUl5fBIAeF0bHtHeacL4G+xeRMYm5ixRxKqO iMIoPhxk9lI9ZizylLOGXu0YUL2wODN7x3L4ZRKGRFOOnCzQqyRnrh36Owb8Jg== From: Miquel Raynal To: Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org Cc: Marcin Wojtas , Russell King , Taras Chornyi , , Robert Marko , Luka Perkov , Thomas Petazzoni , Michael Walle , Miquel Raynal Subject: [PATCH net-next 5/6] net: marvell: prestera: Avoid unnecessary DT lookups Date: Thu, 17 Nov 2022 22:55:56 +0100 Message-Id: <20221117215557.1277033-6-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221117215557.1277033-1-miquel.raynal@bootlin.com> References: <20221117215557.1277033-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?1749782164972862371?= X-GMAIL-MSGID: =?utf-8?q?1749782164972862371?= 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) {