Skip to content

Commit

Permalink
ASoC: mchp-spdiftx: Fix clang -Wbitfield-constant-conversion
Browse files Browse the repository at this point in the history
commit 5c5c2ba upstream.

A recent change in clang strengthened its -Wbitfield-constant-conversion
to warn when 1 is assigned to a 1-bit signed integer bitfield, as it can
only be 0 or -1, not 1:

  sound/soc/atmel/mchp-spdiftx.c:505:20: error: implicit truncation from 'int' to bit-field changes value from 1 to -1 [-Werror,-Wbitfield-constant-conversion]
          dev->gclk_enabled = 1;
                            ^ ~
  1 error generated.

The actual value of the field is never checked, just that it is not
zero, so there is not a real bug here. However, it is simple enough to
silence the warning by making the bitfield unsigned, which matches the
mchp-spdifrx driver.

Fixes: 06ca24e ("ASoC: mchp-spdiftx: add driver for S/PDIF TX Controller")
Link: ClangBuiltLinux/linux#1686
Link: llvm/llvm-project@82afc9b
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/r/20220810010809.2024482-1-nathan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
nathanchance authored and gregkh committed Sep 15, 2022
1 parent 6400eca commit 1578775
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sound/soc/atmel/mchp-spdiftx.c
Expand Up @@ -196,7 +196,7 @@ struct mchp_spdiftx_dev {
struct clk *pclk;
struct clk *gclk;
unsigned int fmt;
int gclk_enabled:1;
unsigned int gclk_enabled:1;
};

static inline int mchp_spdiftx_is_running(struct mchp_spdiftx_dev *dev)
Expand Down

0 comments on commit 1578775

Please sign in to comment.