Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp521111pxb; Thu, 9 Sep 2021 06:21:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziK8zilKNMlrSluNHL/r02tAf6buICh/NTdcQ48QCBJEpclHo5RDfY7fiJfeT/TsmeiQyw X-Received: by 2002:a92:cbc6:: with SMTP id s6mr2295848ilq.260.1631193666740; Thu, 09 Sep 2021 06:21:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631193666; cv=none; d=google.com; s=arc-20160816; b=gdoHHO1TGDAWeAWri9wwYbbC4kzwLAFJw3ygmEFW1+NPnLVFKLPNR/dCfGTK2PPBYX 4YmlHhgd7yFplwnpiNitaKXOOEgXzZBHYQQ0jf9W/16Sw4cv3Srhx6TjUOnMqLYmi3zb //Zrg14dVdbG7SMytkPl26WCQgTpCLBrt9EbyHW9TRl98gbzgsbacLglV9cenPeqQX4a bcw/hxFxeH2HrVhMqjT1B3t4S9JApq4evy4kO41fanV6y5vrryG0mmUXjn54vYQhLa5G YNzS7in01yM/1lZypmUmhzS0SObhXxJsLcjPYoaTt+mhHxqTGQmLm0bXrLi7L5BqXkNP jEXQ== 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=d1oFTI5LrXGnZJX1ObV0KCgEPzQ2x0FEKVPhof2nzXw=; b=ZMAs6/YuYTaUpGVPQp7a7m/1fjz6tNi0ZDMnFCW1rMqePlfrcdegIKMyw6Q2NfWDxE h4SEsAtQ93Fz/vJEMzZjD1nADktSM4mR8wW3q6IUHtECrsXB20/3XPwBU3klnZhU/8yc AJIU5n9Lss4BcQ2Ovjk74p4rj3BBjAussB6IrKZkjbfnpvRr74H2HHbyNwD30F7E3uI+ WWnzy6Sn2yGcp0AqlC7OT1qk5i78LRmgJLnsTQbyfl68sHRs0QiktSghF46BDTLCtPWw mPce83lUV+ToxL6ZevQBkMbCabCL9ZKgwB2Nb9N95XNiCVGfr0oTrQC15BhHf42bFNbX cv8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bO7DIqzr; 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 a11si1716669jat.53.2021.09.09.06.20.54; Thu, 09 Sep 2021 06:21:06 -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=bO7DIqzr; 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 S1359831AbhIINUa (ORCPT + 99 others); Thu, 9 Sep 2021 09:20:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:42452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357660AbhIINDP (ORCPT ); Thu, 9 Sep 2021 09:03:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B058263283; Thu, 9 Sep 2021 11:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188783; bh=7rPPy9jsMIK4OkpCSNlE5O184vhskXR45nYeIa/uT1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bO7DIqzrdnIHTJqolYJHyQ4N/NkqPwxq7cG781Zr54k8TUzl6M5rSH/l1/rUsiS4G tUcORBf7I7YV+qOWdCHh8FxTx+2V7UGz5gi5LoERlGsfa8y2sdWl0dFyT3/rXy8b// ajQ4tku9ZeMvVlsUUwdasMAcQ72R6BLXk7oAQwqyf6LaJaEaiamp2Z/+iIJ1uo2psR ANnjbDXRBXKu1tEg/CzgrnkKO6Y6tozVuQd15jKKotUC7PoPXv7RB3NTcSB2Vw3qb0 vRqJaquFUt1rWo+jrhgtaXYGFuTXBRKuvDMwucgZeF2Ky8E5UtCw7804JUVXq2KNbm UkXxX1JRx3b2w== 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 4.14 34/59] net: ethernet: stmmac: Do not use unreachable() in ipq806x_gmac_probe() Date: Thu, 9 Sep 2021 07:58:35 -0400 Message-Id: <20210909115900.149795-34-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115900.149795-1-sashal@kernel.org> References: <20210909115900.149795-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 f4ff43a1b5ba..d8c40b68bc96 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c @@ -300,10 +300,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); @@ -320,10 +317,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); @@ -340,8 +334,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); @@ -372,6 +365,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