Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp452097pxb; Thu, 9 Sep 2021 04:56:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDKdzo4hMJWYNxr0b7r2J/0Z0J9tjKaeMhW8TD6RaHn/YsH2zohIzYY+S0EwMWJxdHAy16 X-Received: by 2002:a05:6402:1490:: with SMTP id e16mr2767183edv.369.1631188580371; Thu, 09 Sep 2021 04:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188580; cv=none; d=google.com; s=arc-20160816; b=xgsqJcFCltlzxyJ/QgbAWjaGkSkJG9oJbXzb+DgGZfwhf0HvNH+55PuYtDCWreCvg+ 7Z/jNoctY6tHBydYTqRhZ1K2JlTLTRMJA/oJSYQoCVp4jhYQDscoOmSf9yh0mjm0H/8I Wp+ckNLK/VFFOw7iCDDDeXuYt0GiMWJS2YG2yCeFsRcLlJR8PxdY7AwDTXsDtH3VZ/6U 1GqbVlVgLGEidPCbyalMpJUeBUtJyV6QU/7rISP+ipNlHIFkc6jwVfrqGxKdfIyGz5jC XJCYmEYjnrUucZbOLxHf+T5raCiwJyzanPvXTwzL4UYkq+T8FwfrTeATcChPZYDq1x6I K3mg== 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=bttQex7p7TMAo0fwRqoYpI04NJBJ57+vkBopoOl7Jfo=; b=W97El4sJVI+bAxgORxF3oh8TSPxM1YjQHYlGbKO7oQUz/AjxF3X4VFO5M/80mI42gS qJ7qT8WE4oJQGsgpUqQjTKEey/FKdl8ij+5B2Viw8iwYuro0hcnK9uX8Fonek525Xw+Z iOiXOsMDQMwMUvgUI1U3cAVfKd/HGbharCzBD/5LjpLV7u+i5036aIqUwb3KpP+xmAo7 NaScBmJssaWeJ20JY45ukGbxokQDRYMIvzd7Le6CV+PQ1nobXctnugB7aI9HemgMrFho ft5Sa0wZkYLBMb4kTQuQf1o8kYUZ7z+mGc7CmAS6aQG4rwtcs7Z9LL4hnBx2m7PUGzyu eEGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Fl14Y4YS; 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 h12si2210146edb.310.2021.09.09.04.55.55; Thu, 09 Sep 2021 04:56:20 -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=Fl14Y4YS; 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 S240993AbhIILws (ORCPT + 99 others); Thu, 9 Sep 2021 07:52:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:54736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237548AbhIILu2 (ORCPT ); Thu, 9 Sep 2021 07:50:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B961A61213; Thu, 9 Sep 2021 11:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187829; bh=A/QQumOH8O6k/Xn5qDY6TMC4AxTRp7rzpMcWLtKRmjY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fl14Y4YSxLbg/rUWjj3lLh9PW9y/AfsvAxLQP/OqUKqhtzAiXwOgAndEjCBePJEUS 2ofrnAvsI6Kvez4tQMtEiRXwxnhrCUqXmMxTFqzqYi9oqBWjrQlOz9hGGm72i7yTKC 78UkXCxiuFS5M+KNswTgQR/FKWvJC0OcPiFMMyPONE1kR3xRk/Ikq/qxLQVw00XWO5 ExdiOMBRDsZjr86+l/DPetGtLw5/zHinsA4mOu5gm4dC7VU/WzkJBihW9SIyjsuyrw KZ2YEkGI9L9D/PqIQqXDnwh5PV0LM31yB+fErL5Jbl8W9zAFDaIiFcRULSun2J0oFa xXUcRMQcZ2oSA== 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.14 126/252] net: ethernet: stmmac: Do not use unreachable() in ipq806x_gmac_probe() Date: Thu, 9 Sep 2021 07:39:00 -0400 Message-Id: <20210909114106.141462-126-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-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 28dd0ed85a82..f7dc8458cde8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c @@ -289,10 +289,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); @@ -309,10 +306,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); @@ -329,8 +323,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); @@ -361,6 +354,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