linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: max31335: Fix comparison in max31335_volatile_reg()
@ 2024-01-17 17:54 Nathan Chancellor
  2024-01-18  0:27 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2024-01-17 17:54 UTC (permalink / raw)
  To: antoniu.miclaus, alexandre.belloni
  Cc: linux, linux-rtc, llvm, patches, Nathan Chancellor

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>
---
 drivers/rtc/rtc-max31335.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-max31335.c b/drivers/rtc/rtc-max31335.c
index 3ddfe71bbb56..565d4c9ee399 100644
--- a/drivers/rtc/rtc-max31335.c
+++ b/drivers/rtc/rtc-max31335.c
@@ -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;

---
base-commit: dedaf03b99d6561fae06457fd7fc2b0aa154d003
change-id: 20240117-rtc-max3133-fix-comparison-65e4fac8e346

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtc: max31335: Fix comparison in max31335_volatile_reg()
  2024-01-17 17:54 [PATCH] rtc: max31335: Fix comparison in max31335_volatile_reg() Nathan Chancellor
@ 2024-01-18  0:27 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2024-01-18  0:27 UTC (permalink / raw)
  To: antoniu.miclaus, Nathan Chancellor; +Cc: linux, linux-rtc, llvm, patches

On Wed, 17 Jan 2024 10:54:16 -0700, Nathan Chancellor wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] rtc: max31335: Fix comparison in max31335_volatile_reg()
      https://git.kernel.org/abelloni/c/dd7fe5d9fd6a

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-18  0:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-17 17:54 [PATCH] rtc: max31335: Fix comparison in max31335_volatile_reg() Nathan Chancellor
2024-01-18  0:27 ` Alexandre Belloni

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).