netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
To: Rob Herring <robh+dt@kernel.org>,
	Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Johan Hovold <johan@kernel.org>,
	Maxime Ripard <mripard@kernel.org>,
	Joao Pinto <jpinto@synopsys.com>, Lars Persson <larper@axis.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Serge Semin <Sergey.Semin@baikalelectronics.ru>,
	Serge Semin <fancer.lancer@gmail.com>,
	Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>,
	Pavel Parkhomenko <Pavel.Parkhomenko@baikalelectronics.ru>,
	Vyacheslav Mitrofanov 
	<Vyacheslav.Mitrofanov@baikalelectronics.ru>,
	<netdev@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v2 14/24] net: stmmac: Use optional clock request method to get stmmaceth
Date: Mon, 8 Feb 2021 16:55:58 +0300	[thread overview]
Message-ID: <20210208135609.7685-15-Sergey.Semin@baikalelectronics.ru> (raw)
In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru>

The "stmmaceth" clock is expected to be optional by the current driver
design, but there are several problems in the implementation. First if the
clock is specified, but failed to be requested due to an internal error or
due to not being ready yet for configuration, then the DT-probe procedure
will just proceed with further initializations. It is erroneous in both
cases. Secondly if we'd use the clock API, which expect the clock being
optional we wouldn't have needed to avoid the clock request procedure for
the "snps,dwc-qos-ethernet-4.10"-compatible devices to prevent the error
message from being printed. All of that can be fixed by using the
devm_clk_get_optional() method here provided by the common clock
framework.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
---
 .../ethernet/stmicro/stmmac/stmmac_platform.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index ff66c470f07f..a66467baf30a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -566,16 +566,17 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 	if (rc)
 		goto error_dma_cfg_alloc;
 
-	/* clock setup */
-	if (!of_device_is_compatible(np, "snps,dwc-qos-ethernet-4.10")) {
-		plat->stmmac_clk = devm_clk_get(&pdev->dev,
-						STMMAC_RESOURCE_NAME);
-		if (IS_ERR(plat->stmmac_clk)) {
-			dev_warn(&pdev->dev, "Cannot get CSR clock\n");
-			plat->stmmac_clk = NULL;
-		}
-		clk_prepare_enable(plat->stmmac_clk);
+	/* All clocks are optional since the sub-drivers may use the platform
+	 * clocks pointers to preserve their own clock-descriptors.
+	 */
+	plat->stmmac_clk = devm_clk_get_optional(&pdev->dev,
+						 STMMAC_RESOURCE_NAME);
+	if (IS_ERR(plat->stmmac_clk)) {
+		rc = PTR_ERR(plat->stmmac_clk);
+		dev_err_probe(&pdev->dev, rc, "Cannot get CSR clock\n");
+		goto error_dma_cfg_alloc;
 	}
+	clk_prepare_enable(plat->stmmac_clk);
 
 	plat->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
 	if (IS_ERR(plat->pclk)) {
-- 
2.29.2


  parent reply	other threads:[~2021-02-08 14:04 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08 13:55 [PATCH v2 00/24] net: stmmac: Fix clocks/reset-related procedures Serge Semin
2021-02-08 13:55 ` [PATCH v2 01/24] dt-bindings: net: dwmac: Validate PBL for all IP-cores Serge Semin
2021-02-08 13:55 ` [PATCH v2 02/24] dt-bindings: net: dwmac: Extend number of PBL values Serge Semin
2021-02-08 13:55 ` [PATCH v2 03/24] dt-bindings: net: dwmac: Fix the TSO property declaration Serge Semin
2021-02-09 21:54   ` Rob Herring
2021-02-08 13:55 ` [PATCH v2 04/24] dt-bindings: net: dwmac: Refactor snps,*-config properties Serge Semin
2021-02-09 22:26   ` Rob Herring
2021-02-10 21:57     ` Serge Semin
2021-02-18 15:55       ` Serge Semin
2021-02-08 13:55 ` [PATCH v2 05/24] dt-bindings: net: dwmac: Elaborate stmmaceth/pclk description Serge Semin
2021-02-08 13:55 ` [PATCH v2 06/24] dt-bindings: net: dwmac: Add Tx/Rx clock sources Serge Semin
2021-02-08 13:55 ` [PATCH v2 07/24] dt-bindings: net: dwmac: Detach Generic DW MAC bindings Serge Semin
2021-02-09 22:32   ` Rob Herring
2021-02-10 22:05     ` Serge Semin
2021-02-08 13:55 ` [PATCH v2 08/24] net: stmmac: Add {axi,mtl-rx,mtl-tx}-config sub-nodes support Serge Semin
2021-02-08 13:55 ` [PATCH v2 09/24] net: stmmac: dwmac-rk: Cleanup STMMAC DT-config in remove cb Serge Semin
2021-02-08 13:55 ` [PATCH v2 10/24] net: stmmac: dwmac-sti: " Serge Semin
2021-02-08 13:55 ` [PATCH v2 11/24] net: stmmac: dwmac-stm32: " Serge Semin
2021-02-08 13:55 ` [PATCH v2 12/24] net: stmmac: Directly call reverse methods in stmmac_probe_config_dt() Serge Semin
2021-02-08 13:55 ` [PATCH v2 13/24] net: stmmac: Fix clocks left enabled on glue-probes failure Serge Semin
2021-02-08 13:55 ` Serge Semin [this message]
2021-02-08 13:55 ` [PATCH v2 15/24] net: stmmac: Use optional clock request method to get ptp_clk Serge Semin
2021-02-08 13:56 ` [PATCH v2 16/24] net: stmmac: Use optional reset control API to work with stmmaceth Serge Semin
2021-02-10  6:49   ` Jisheng Zhang
2021-02-10 22:14     ` Serge Semin
2021-02-08 13:56 ` [PATCH v2 17/24] net: stmmac: dwc-qos: Cleanup STMMAC platform data clock pointers Serge Semin
2021-02-08 13:56 ` [PATCH v2 18/24] net: stmmac: dwc-qos: Use dev_err_probe() for probe errors handling Serge Semin
2021-02-08 13:56 ` [PATCH v2 19/24] net: stmmac: Add Tx/Rx platform clocks support Serge Semin
2021-02-08 13:56 ` [PATCH v2 20/24] net: stmmac: dwc-qos: Discard Tx/Rx clocks request Serge Semin
2021-02-08 13:56 ` [PATCH v2 21/24] net: stmmac: dwmac-imx: Discard Tx clock request Serge Semin
2021-02-08 13:56 ` [PATCH v2 22/24] net: stmmac: Call stmmaceth clock as system clock in warn-message Serge Semin
2021-02-08 13:56 ` [PATCH v2 23/24] net: stmmac: Use pclk to set MDC clock frequency Serge Semin
2021-02-08 13:56 ` [PATCH v2 24/24] net: stmmac: dwc-qos: Save master/slave clocks in the plat-data Serge Semin
2021-02-08 19:05 ` [PATCH v2 00/24] net: stmmac: Fix clocks/reset-related procedures Jakub Kicinski
2021-02-09 10:59   ` Serge Semin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210208135609.7685-15-Sergey.Semin@baikalelectronics.ru \
    --to=sergey.semin@baikalelectronics.ru \
    --cc=Alexey.Malahov@baikalelectronics.ru \
    --cc=Pavel.Parkhomenko@baikalelectronics.ru \
    --cc=Vyacheslav.Mitrofanov@baikalelectronics.ru \
    --cc=alexandre.torgue@st.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=fancer.lancer@gmail.com \
    --cc=joabreu@synopsys.com \
    --cc=johan@kernel.org \
    --cc=jpinto@synopsys.com \
    --cc=kuba@kernel.org \
    --cc=larper@axis.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mripard@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).