From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4069C1B0D8 for ; Mon, 14 Dec 2020 09:18:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A1FC22AAA for ; Mon, 14 Dec 2020 09:18:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439726AbgLNJSK (ORCPT ); Mon, 14 Dec 2020 04:18:10 -0500 Received: from ns2.baikalelectronics.com ([94.125.187.42]:46530 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439657AbgLNJR4 (ORCPT ); Mon, 14 Dec 2020 04:17:56 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH 14/25] net: stmmac: Use optional clock request method to get stmmaceth Date: Mon, 14 Dec 2020 12:16:04 +0300 Message-ID: <20201214091616.13545-15-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- .../ethernet/stmicro/stmmac/stmmac_platform.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 56419f511a48..e79b3e3351a9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -566,17 +566,19 @@ 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 can have a specific + * clocks set and their naming. + */ + 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(&pdev->dev, "pclk"); if (IS_ERR(plat->pclk)) { if (PTR_ERR(plat->pclk) == -EPROBE_DEFER) { -- 2.29.2