Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp540978pxb; Thu, 9 Sep 2021 06:45:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQsBX+p5oP532ubGBnfFpLIRE9tSt8De+ad8shayV7vf/8eC5ciKZnp0CqZs4uygdOOsU+ X-Received: by 2002:a92:4406:: with SMTP id r6mr2348402ila.88.1631195123786; Thu, 09 Sep 2021 06:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631195123; cv=none; d=google.com; s=arc-20160816; b=ub5yy3Qt2cWh9gHtoEUBgPM149KZ4br7I71AIAARUC+BSVu43NndTrm8CAQClaU3TT OXPqi2RGkmRlqzdMsZQuau7DVK8eGhICcGcEZiLLTiuMMq8sB28A/altltpwpXqQ2KDW HF9mQG7VTMkib4Cf9RMazYB0YXkEziLLo1G1ZGpcYiWsUj7Lb6z5/YG8xSVwsuKZrRB8 2QvvTq8kpkAlfjUkNEsvJPzQV/Jmbl9p55/CrMnoW+t15aA9FuC92ExGwwLDEBokYmGd m1iXAlFHGgeTwjjY44w4ZyCer+pRqFbTsF9l7CigdNfCdCitaFrIy2ccTALB/qhGZUKJ CijQ== 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 :dkim-signature; bh=tghsTLgmbaHZ0PAq9TGBCb4gOztLCGyvUujPFSUHM1A=; b=k2kVt2y5PRNIJlY7ly7j6TbO2Y7csTweWelhxAX3BrGSoY8zmHaraO1IAS0smj+bu+ yIrnEJRgmCLeW3oAp6/x4UXvz2NKDoGTFsSK0B+Ml18JBoDnKH5WaC/me3PCGGlQxRET mGylHgr7augZZF+Sx0hjBVuftfiQ5k10nPGFr2BhFzMZ2IP76CivWRTrjk3gpYV1UYuP CAiiS0oJu9oqi23QOyt+ED6rIGTh3HwrFYYDEJ37nvgGYvp5iQQFNv/Cxy5cmwYTTEqW VF/0Dw0r/usyn16B8hezyMRamooiLlTDv6agnhrx8nEdtynRnRBoqOXynaaz/ZKTZ5Sx GoAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ofHCIiTj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si2121541jak.6.2021.09.09.06.45.10; Thu, 09 Sep 2021 06:45:23 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ofHCIiTj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357335AbhIINoS (ORCPT + 99 others); Thu, 9 Sep 2021 09:44:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:40984 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352477AbhIIMrH (ORCPT ); Thu, 9 Sep 2021 08:47:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7D8EB6320E; Thu, 9 Sep 2021 11:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188578; bh=CcGd3tLppzua3RpBPmsOGIVB1hJU/S8evCoxGLnypmo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ofHCIiTjHUGtbWOAvRwvha9LyYdK13vGGHBqEVQXVSgL5XdQ1E7dOntfAsXGEauTr W6nM84uk6/WwdMfaj9KVHyUNDypF65bjwWpLRkkRBfAgMLHI7NzEEvVI9/O6whwKSk sVzwafiNRukwTa7TAR3sLVMN2dd9kZEQnYH86GzZxy/7cZd17TfnGXv/RtH08t+ArM zNayzlV0wvjPCFa530i56LKYGP46vcJVlBg4YNRt3yACKI3qiK6F742U0RFOjarZg2 5h9CZie3HMKBROS/P8wfdk8FWnXpjW9B3uwiRI2G4xmvP9qwPY9cqhhLkR1Uc/x+84 OA1dLfBeyLqbA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , Sami Tolvanen , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, clang-built-linux@googlegroups.com Subject: [PATCH AUTOSEL 5.4 056/109] net: ethernet: stmmac: Do not use unreachable() in ipq806x_gmac_probe() Date: Thu, 9 Sep 2021 07:54:13 -0400 Message-Id: <20210909115507.147917-56-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115507.147917-1-sashal@kernel.org> References: <20210909115507.147917-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nathan Chancellor [ Upstream commit 4367355dd90942a71641c98c40c74589c9bddf90 ] When compiling with clang in certain configurations, an objtool warning appears: drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.o: warning: objtool: ipq806x_gmac_probe() falls through to next function phy_modes() This happens because the unreachable annotation in the third switch statement is not eliminated. The compiler should know that the first default case would prevent the second and third from being reached as the comment notes but sanitizer options can make it harder for the compiler to reason this out. Help the compiler out by eliminating the unreachable() annotation and unifying the default case error handling so that there is no objtool warning, the meaning of the code stays the same, and there is less duplication. Reported-by: Sami Tolvanen Tested-by: Sami Tolvanen Signed-off-by: Nathan Chancellor Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../ethernet/stmicro/stmmac/dwmac-ipq806x.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c index 0f56f8e33691..03b11f191c26 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c @@ -288,10 +288,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) val &= ~NSS_COMMON_GMAC_CTL_PHY_IFACE_SEL; break; default: - dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n", - phy_modes(gmac->phy_mode)); - err = -EINVAL; - goto err_remove_config_dt; + goto err_unsupported_phy; } regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val); @@ -308,10 +305,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id); break; default: - dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n", - phy_modes(gmac->phy_mode)); - err = -EINVAL; - goto err_remove_config_dt; + goto err_unsupported_phy; } regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val); @@ -328,8 +322,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id); break; default: - /* We don't get here; the switch above will have errored out */ - unreachable(); + goto err_unsupported_phy; } regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val); @@ -360,6 +353,11 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) return 0; +err_unsupported_phy: + dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n", + phy_modes(gmac->phy_mode)); + err = -EINVAL; + err_remove_config_dt: stmmac_remove_config_dt(pdev, plat_dat); -- 2.30.2