From patchwork Tue Aug 8 12:02:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13346016 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FFB4C001DB for ; Tue, 8 Aug 2023 12:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=LNFTHX2lZayfW9b25ff9c8BoiHthRfBvFmKUO6vltLM=; b=bmOmLgHTqAZ9X9 dlUSZxp0ugbim45l5gbfHC/GQuUnr2OsVUqwE/O5c1rGCqvYag9xz2h5gV359vUoyO7FVeyL1ljy2 scfhc7emCmxKmvv2Yh50xxmP2qViXoDCQzB+NTAyAHXXpoDtPxP4sc/ZHP8KjNIkPrNAIDPy3QO3Y 9ptZMezo8oUnVfsKeYb+Fy5GVKjIGdCYROOmnzA52ADWxFb+SRNdEjgQFiIlYKR23iGpkW3eqhJVx 5ZTrcEmb2yTRXjgyW2dPKlw8h04L8oWt9LMouPAd3lScITynOMt1QTFgSRwKuFMRTMVUC9V8wMzBZ Zx3mQWI5zZUREox/PJpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qTLQe-002WxG-1a; Tue, 08 Aug 2023 12:03:12 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qTLQb-002Wwa-0u for linux-arm-kernel@lists.infradead.org; Tue, 08 Aug 2023 12:03:10 +0000 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-31771a876b5so4185926f8f.3 for ; Tue, 08 Aug 2023 05:03:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1691496186; x=1692100986; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Ie3WcAqbCuJwn+bSe+8uiPLhrE9XYV8epIzLQ3pbcL4=; b=1fO8HtnVKi35e//6KYE+HJ4EBCNIy4ZSnNw2nISTh5Q8eplnrPEKpbjbm6nlmeKh+T HvxCjWZ1/4Ln4x0Va1UeAm+byOL4lMIPCxu/ISYfBdLuWWbfBroA/C0PnEWujlBEhE4j txzQVb8sn+KbtFoGMge7ATRRig61xJaSDJwkFT9Uk2x3JIeVc9lc7X8LYLFsQwWzgPzY IMwp3DSs2kMQuovrw4ustqZBooiINCnAGrfoJHBAZmLB/Keqt4+DHzfc7+6fT76kJn4b NVsko35jwDTttbI1e/izd+NgepzYB3FQM1mzKMT1W02+oqdh+JCq2nuAdHRkpVxdJJg6 UHNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691496186; x=1692100986; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ie3WcAqbCuJwn+bSe+8uiPLhrE9XYV8epIzLQ3pbcL4=; b=FLxnb6GfMNM+VOUdQXSn79e2en/iLlhL8dmMqnw81/NDdF4844AWSXfZNf2FF+m3I9 qdDCf1PeIfRRlOwgV36zwEj1Xjxa2q5Dy6WdVuCbtnEmC676TuLXa+Ck8LV7YAk6+qWQ lpstFShmelBfb/UyDivuEItvnG1k6EEfWSFpHFbAkQ9R7xCT9Bqb9gmz2Y48Cz+lltQI IIa80iefjcmNjg1ZoUyudW0GdHFvH3mvUrYdoWvtGzIbuDmK4Qn+L8BvSEzHCI0zROJk lrVTqXf8ijlLJi/pcgAfYrFbVlIp2HtWrpnyea+UTs/MnLXJP8YLLJIR/XRkblycBKnj em0g== X-Gm-Message-State: AOJu0YyF1r1ooR4BR1aRnHrN5/1sqUDtFWvhvqIA+rx5BF7vxPdt0xf6 byDTCE9n4FWKs++IL8sXLjcovw== X-Google-Smtp-Source: AGHT+IGUZorkCi64YkQRQ50LyONGuQyCaMkyjeEos2tgFQ6faizt7lG2rcTuyHFQW//RTS5PrFhblA== X-Received: by 2002:adf:ea11:0:b0:313:f1c8:a968 with SMTP id q17-20020adfea11000000b00313f1c8a968mr8055326wrm.2.1691496185883; Tue, 08 Aug 2023 05:03:05 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:6a08:bcc0:ae83:e1dc]) by smtp.gmail.com with ESMTPSA id v8-20020adfe4c8000000b00317046f21f9sm13499726wrm.114.2023.08.08.05.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 05:03:05 -0700 (PDT) From: Bartosz Golaszewski To: Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alex Elder , Srini Kandagatla , Andrew Halaney Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH net-next] net: stmmac: don't create the MDIO bus if there's no mdio node on DT Date: Tue, 8 Aug 2023 14:02:54 +0200 Message-Id: <20230808120254.11653-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230808_050309_539848_C25219BA X-CRM114-Status: GOOD ( 16.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Bartosz Golaszewski The stmmac_dt_phy() function that parses the device-tree node of the MAC and allocates the MDIO and PHY resources misses one use-case: when the MAC doesn't have a fixed link but also doesn't define its own mdio bus on the device tree and instead shares the MDIO lines with a different MAC with its PHY phandle reaching over into a different node. As this function could also use some more readability, rework it to handle this use-case and simplify the code. Signed-off-by: Bartosz Golaszewski Acked-by: Alexandre TORGUE --- .../ethernet/stmicro/stmmac/stmmac_platform.c | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index be8e79c7aa34..91844673df43 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -320,12 +320,14 @@ static int stmmac_mtl_setup(struct platform_device *pdev, static int stmmac_dt_phy(struct plat_stmmacenet_data *plat, struct device_node *np, struct device *dev) { - bool mdio = !of_phy_is_fixed_link(np); static const struct of_device_id need_mdio_ids[] = { { .compatible = "snps,dwc-qos-ethernet-4.10" }, {}, }; + if (of_phy_is_fixed_link(np)) + return 0; + if (of_match_node(need_mdio_ids, np)) { plat->mdio_node = of_get_child_by_name(np, "mdio"); } else { @@ -340,20 +342,18 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat, } } - if (plat->mdio_node) { - dev_dbg(dev, "Found MDIO subnode\n"); - mdio = true; - } + if (!plat->mdio_node) + return 0; - if (mdio) { - plat->mdio_bus_data = - devm_kzalloc(dev, sizeof(struct stmmac_mdio_bus_data), - GFP_KERNEL); - if (!plat->mdio_bus_data) - return -ENOMEM; + dev_dbg(dev, "Found MDIO subnode\n"); - plat->mdio_bus_data->needs_reset = true; - } + plat->mdio_bus_data = devm_kzalloc(dev, + sizeof(struct stmmac_mdio_bus_data), + GFP_KERNEL); + if (!plat->mdio_bus_data) + return -ENOMEM; + + plat->mdio_bus_data->needs_reset = true; return 0; }