From patchwork Mon Dec 14 09:16:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343867 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=unavailable 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 DC53BC1B0D8 for ; Mon, 14 Dec 2020 09:28:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 996A122AB0 for ; Mon, 14 Dec 2020 09:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389338AbgLNJW5 (ORCPT ); Mon, 14 Dec 2020 04:22:57 -0500 Received: from mx.baikalchip.com ([94.125.187.42]:46516 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439715AbgLNJSL (ORCPT ); Mon, 14 Dec 2020 04:18:11 -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 15/25] net: stmmac: Use optional clock request method to get pclk Date: Mon, 14 Dec 2020 12:16:05 +0300 Message-ID: <20201214091616.13545-16-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 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Let's replace the manual implementation of the optional "pclk" functionality with using devm_clk_get_optional(). By doing so we'll improve the code maintainability, and fix a hidden bug which will cause problems if the "pclk" clock has been actually passed to the device, but the clock framework failed to request it. Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index e79b3e3351a9..3809b00d3077 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -579,15 +579,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) clk_prepare_enable(plat->stmmac_clk); - plat->pclk = devm_clk_get(&pdev->dev, "pclk"); + plat->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); if (IS_ERR(plat->pclk)) { - if (PTR_ERR(plat->pclk) == -EPROBE_DEFER) { - rc = PTR_ERR(plat->pclk); - goto error_pclk_get; - } - - plat->pclk = NULL; + rc = PTR_ERR(plat->pclk); + dev_err_probe(&pdev->dev, rc, "Cannot get CSR clock\n"); + goto error_pclk_get; } + clk_prepare_enable(plat->pclk); /* Fall-back to main clock in case of no PTP ref is passed */