]> git.itanic.dy.fi Git - linux-stable/commitdiff
rtc: max31335: Fix comparison in max31335_volatile_reg()
authorNathan Chancellor <nathan@kernel.org>
Wed, 17 Jan 2024 17:54:16 +0000 (10:54 -0700)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 17 Jan 2024 23:59:32 +0000 (00:59 +0100)
Clang warns (or errors with CONFIG_WERROR=y):

    drivers/rtc/rtc-max31335.c:211:36: error: use of logical '||' with constant operand [-Werror,-Wconstant-logical-operand]
      211 |         if (reg == MAX31335_TEMP_DATA_MSB || MAX31335_TEMP_DATA_LSB)
          |                                           ^  ~~~~~~~~~~~~~~~~~~~~~~
    drivers/rtc/rtc-max31335.c:211:36: note: use '|' for a bitwise operation
      211 |         if (reg == MAX31335_TEMP_DATA_MSB || MAX31335_TEMP_DATA_LSB)
          |                                           ^~
          |                                           |
    1 error generated.

This clearly should be a comparison against reg. Fix the comparison so
that max31335_volatile_reg() does not always return true.

Closes: https://github.com/ClangBuiltLinux/linux/issues/1980
Fixes: dedaf03b99d6 ("rtc: max31335: add driver support")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20240117-rtc-max3133-fix-comparison-v1-1-91e98b29d564@kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-max31335.c

index a38d303d9df4d8bb619eb5f7a0fa409e39b2cd00..402fda8fd54884eb8d1485ab456de696049dc510 100644 (file)
@@ -208,7 +208,7 @@ static bool max31335_volatile_reg(struct device *dev, unsigned int reg)
                return true;
 
        /* temperature registers */
-       if (reg == MAX31335_TEMP_DATA_MSB || MAX31335_TEMP_DATA_LSB)
+       if (reg == MAX31335_TEMP_DATA_MSB || reg == MAX31335_TEMP_DATA_LSB)
                return true;
 
        return false;