From: Nick Desaulniers <ndesaulniers@google.com>
To: Nathan Chancellor <natechancellor@gmail.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>,
Vinod Koul <vkoul@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
clang-built-linux <clang-built-linux@googlegroups.com>
Subject: Re: [PATCH] phy: intel: Eliminate unnecessary assignment in intel_cbphy_set_mode
Date: Tue, 26 May 2020 11:12:58 -0700 [thread overview]
Message-ID: <CAKwvOdn5R0md+9jVGrzQhR4ZfcSWsCqPE9qK2UxMDOKnWnpaKA@mail.gmail.com> (raw)
In-Reply-To: <20200523035043.3305846-1-natechancellor@gmail.com>
On Fri, May 22, 2020 at 8:51 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns:
>
> drivers/phy/intel/phy-intel-combo.c:202:34: warning: implicit conversion
> from enumeration type 'enum intel_phy_mode' to different enumeration
> type 'enum intel_combo_mode' [-Wenum-conversion]
> enum intel_combo_mode cb_mode = PHY_PCIE_MODE;
> ~~~~~~~ ^~~~~~~~~~~~~
> 1 warning generated.
>
> The correct enum to use would be PCIE0_PCIE1_MODE. However, eliminating
> this assignment is a little better because the switch statement always
Indeed, the switch is exhaustive. Might be a risk if new enumeration
values are added to the enum, though.
Probably should just initialize it to PCIE0_PCIE1_MODE, then you can
simplify the PHY_PCIE_MODE case a little (replace ternary with
if+assignment).
> assigns a new value to cb_mode, which also takes care of the warning.
>
> Fixes: ac0a95a3ea78 ("phy: intel: Add driver support for ComboPhy")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1034
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/phy/intel/phy-intel-combo.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/phy/intel/phy-intel-combo.c b/drivers/phy/intel/phy-intel-combo.c
> index c2a35be4cdfb..4bc1276ecf23 100644
> --- a/drivers/phy/intel/phy-intel-combo.c
> +++ b/drivers/phy/intel/phy-intel-combo.c
> @@ -199,9 +199,9 @@ static int intel_cbphy_pcie_dis_pad_refclk(struct intel_cbphy_iphy *iphy)
>
> static int intel_cbphy_set_mode(struct intel_combo_phy *cbphy)
> {
> - enum intel_combo_mode cb_mode = PHY_PCIE_MODE;
> enum aggregated_mode aggr = cbphy->aggr_mode;
> struct device *dev = cbphy->dev;
> + enum intel_combo_mode cb_mode;
> enum intel_phy_mode mode;
> int ret;
>
>
> base-commit: c11d28ab4a691736e30b49813fb801847bd44e83
> --
--
Thanks,
~Nick Desaulniers
next prev parent reply other threads:[~2020-05-26 18:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-23 3:50 [PATCH] phy: intel: Eliminate unnecessary assignment in intel_cbphy_set_mode Nathan Chancellor
2020-05-26 18:12 ` Nick Desaulniers [this message]
2020-05-26 20:52 ` Nathan Chancellor
2020-06-16 0:30 ` Nathan Chancellor
2020-06-24 12:13 ` Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKwvOdn5R0md+9jVGrzQhR4ZfcSWsCqPE9qK2UxMDOKnWnpaKA@mail.gmail.com \
--to=ndesaulniers@google.com \
--cc=clang-built-linux@googlegroups.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=natechancellor@gmail.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).