Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4021066pxb; Mon, 8 Feb 2021 06:12:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+dGgJxHK307u/3tXBWJn4xF8wzjumGt6vK6/ByuDSk72R8AcV5rNFMEh5gfUeAHCyaI1S X-Received: by 2002:a17:906:4f16:: with SMTP id t22mr7353117eju.307.1612793552232; Mon, 08 Feb 2021 06:12:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612793552; cv=none; d=google.com; s=arc-20160816; b=MFr25lfl4LhegLGMAqeSHn+/fpJVx1xcFefaAo8gSUwJbQ0BuqFBy0jTFsq6OQihLR hBXjB/sioQBhdGV1iNoSgPvbYwDLkdzsPEzSGMZctlUp0lhy2KRVdpW1UqLGt0ht82u2 vwxGTQP/S6XKlOF1ltZVf08EugrDlKF4B1658KftjwETkRyGWzTF0pmhQcqEn0DHyUS1 s/MXVGU8AJMBoZxTt0ly29Xmb+XpdL3vXQj/8ck321zimBGpdmkJyLQkQQUaU/XMBu+n qqDkkD3uTssuSCxloyLH3EpH3LLvFcA+MTeysqNO5vSalIwYMaSUg8WaP5v+717JbNX/ 1eTg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=s4+5lchRVel0gunq25qt+gpQGe8oqVkwLJ3yWCcdEuk=; b=nGEJldkvzdpoKtlEH/PeQgt0LVBwptA3QsbBnvID2rNjXUpf2igZSg8f3669D1FBB3 dkca72tY0raJbnC2Rjd07WjGJwz5I0onrR2Zkh9x+XPZsESrC7dIMHxWAdbNvO8ipN+z uoKghopQkm07UmkfYTLLyR3kRXRa0Q2ogghDx3JjoZVnzyIlGySJ+DHETQnWwhdmGHWG YMUkeXqsGS9REnXF+8cUocATrDQNxxZ5l3RdFnmNQGVosTujzJafyx4kHyRM4LMq3ZPI V685GfMAU5yPiXS/dDONJ5Wj/rh6NcOvViIGqBZUYwDQoJ9gytGtSLervHB5udUL16xk MvTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si11455221edw.370.2021.02.08.06.12.05; Mon, 08 Feb 2021 06:12:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232568AbhBHOIi (ORCPT + 99 others); Mon, 8 Feb 2021 09:08:38 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57080 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231882AbhBHN5r (ORCPT ); Mon, 8 Feb 2021 08:57:47 -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 v2 14/24] net: stmmac: Use optional clock request method to get stmmaceth Date: Mon, 8 Feb 2021 16:55:58 +0300 Message-ID: <20210208135609.7685-15-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-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 | 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