Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp261913imw; Mon, 4 Jul 2022 08:44:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sD+P8etXRht5lkb1E6Pp61aMMAUAZ0nbLyuFkGwuisXNtNhPxADSvITon0m6+WTmSOwvsq X-Received: by 2002:a05:6402:3682:b0:435:b12e:57cd with SMTP id ej2-20020a056402368200b00435b12e57cdmr40023943edb.381.1656949459525; Mon, 04 Jul 2022 08:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656949459; cv=none; d=google.com; s=arc-20160816; b=pd/yi9AmHvxH/On+55w1aGim83TQr2/gA3tluVbjiSNASK2VRzXme/QNg9kP28fyW1 +HTaN3mMtjwopdA3TUUR6OJ14i/7smZYWBwynY0mx/FLCxrG4HsuHigQQKVLdKL+Oo8i xZ605OF/qhiyWM+zzA9XQWY6/Z4laotBKofFPlIbwPNMn4Sw57sQ31DGBBhHklw6mNHA A9Kc49XwB5RYKiY8E9zeeXIQZkeaDWOfjqOHeENRIJV6Mnm2mOoL1FYoB0WssfpJA57v 84iAakdPE0/lB6jhoF1GVKaqLKfm2WItxMgJLTs2a1twk41JBFCy8pJAJ30CaZgbaP5D XH9w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=49jmyk6Kr/0yocNEo96l8pdLWi/9xTg3Yv6EvEmNyo0=; b=y937qDlEN60lz8xTeH815KExd4B7/j+rgYjr0yKVyGmZEXPLMc8j6xUCO9nV2MnjKt C2eNT4baB0pTrYx31k6oR4N0gIbeQ9xgwjhDxALMff0Xeqh+aNA1xSsnl62DFB/cJr1c 2LXIdj2wecKIT3Mz+25rc2r6qmM1OAaJZjpGy8l5E96bDMjUqUhTRiNJF68j2SYy+Amy kbS4lYrfqdPcXSSXFptWFtKa95k2lMHO6aFIrK28LMSKlVJLMlXgzwdSLbSpHipI5/QH Fu2Xit0jmNHb85HioZg7bZB25CQEWf3wK59UUZIPGjeWe2oRSWTOhBmK4xqvSNQnLwdi AFjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b="otp/j1cF"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a056402274900b004358eb8f787si10487603edd.447.2022.07.04.08.43.53; Mon, 04 Jul 2022 08:44:19 -0700 (PDT) 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=@walle.cc header.s=mail2016061301 header.b="otp/j1cF"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234430AbiGDPhN (ORCPT + 99 others); Mon, 4 Jul 2022 11:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233983AbiGDPhM (ORCPT ); Mon, 4 Jul 2022 11:37:12 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49C3D101CE; Mon, 4 Jul 2022 08:37:11 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id A857F22175; Mon, 4 Jul 2022 17:37:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1656949029; 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; bh=49jmyk6Kr/0yocNEo96l8pdLWi/9xTg3Yv6EvEmNyo0=; b=otp/j1cF3MyABLdiurF0KYWC8yr8LzLUZTdWmZ+hWcw/UHcaOd/LEDA8L8dEfSAn44D+we l67KQaQf6krAueaLTYQqQtQ6/9J9mJGMiWTrFcPAkhNWGHAlRsZYPRzqIjUzGgs9KqsGrd C7ZwngsCzBsgi8wK7lXGNbHqO0EZGvc= From: Michael Walle To: Horatiu Vultur , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vladimir Oltean Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH net v2] net: lan966x: hardcode the number of external ports Date: Mon, 4 Jul 2022 17:36:54 +0200 Message-Id: <20220704153654.1167886-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Instead of counting the child nodes in the device tree, hardcode the number of ports in the driver itself. The counting won't work at all if an ethernet port is marked as disabled, e.g. because it is not connected on the board at all. It turns out that the LAN9662 and LAN9668 use the same switching IP with the same synthesis parameters. The only difference is that the output ports are not connected. Thus, we can just hardcode the number of physical ports to 8. Fixes: db8bcaad5393 ("net: lan966x: add the basic lan966x driver") Signed-off-by: Michael Walle --- changes since v1: - add fixes tag since the fix is simple - switch from new specific compatible to "just use 8 for all" drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 8 ++------ drivers/net/ethernet/microchip/lan966x/lan966x_main.h | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index 5784c4161e5e..1d6e3b641b2e 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -994,7 +994,7 @@ static int lan966x_probe(struct platform_device *pdev) struct fwnode_handle *ports, *portnp; struct lan966x *lan966x; u8 mac_addr[ETH_ALEN]; - int err, i; + int err; lan966x = devm_kzalloc(&pdev->dev, sizeof(*lan966x), GFP_KERNEL); if (!lan966x) @@ -1025,11 +1025,7 @@ static int lan966x_probe(struct platform_device *pdev) if (err) return dev_err_probe(&pdev->dev, err, "Reset failed"); - i = 0; - fwnode_for_each_available_child_node(ports, portnp) - ++i; - - lan966x->num_phys_ports = i; + lan966x->num_phys_ports = NUM_PHYS_PORTS; lan966x->ports = devm_kcalloc(&pdev->dev, lan966x->num_phys_ports, sizeof(struct lan966x_port *), GFP_KERNEL); diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h index 3b86ddddc756..2787055c1847 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h @@ -34,6 +34,7 @@ /* Reserved amount for (SRC, PRIO) at index 8*SRC + PRIO */ #define QSYS_Q_RSRV 95 +#define NUM_PHYS_PORTS 8 #define CPU_PORT 8 /* Reserved PGIDs */ -- 2.30.2