On Thu, Nov 16, 2023 at 06:46:00PM -0700, Nathan Chancellor wrote: > Clang warns (or errors with CONFIG_WERROR=y): > > drivers/mmc/host/sdhci-of-dwcmshc.c:873:7: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical] > 873 | if ((device_property_read_bool(dev, "mmc-ddr-1_8v")) | > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 874 | (device_property_read_bool(dev, "mmc-hs200-1_8v")) | > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | || > 875 | (device_property_read_bool(dev, "mmc-hs400-1_8v"))) > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/mmc/host/sdhci-of-dwcmshc.c:873:7: note: cast one or both operands to int to silence this warning > drivers/mmc/host/sdhci-of-dwcmshc.c:873:7: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical] > 873 | if ((device_property_read_bool(dev, "mmc-ddr-1_8v")) | > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | || > 874 | (device_property_read_bool(dev, "mmc-hs200-1_8v")) | > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/mmc/host/sdhci-of-dwcmshc.c:873:7: note: cast one or both operands to int to silence this warning > 2 errors generated. > > There is little reason for this if statement to use bitwise ORs, as the > short circuiting of logical OR does not need to be avoided in this > context; it would be wasteful to call device_property_read_bool() three > times if the first two calls returned true. Switch to logical OR to fix > the warning. > > While in the area, the parentheses around the calls to > device_property_read_bool() are not necessary and make the if statement > harder to read, so remove them. > > Closes: https://github.com/ClangBuiltLinux/linux/issues/1960 > Fixes: aff35fbc7830 ("mmc: sdhci-of-dwcmshc: Add support for T-Head TH1520") > Signed-off-by: Nathan Chancellor <nathan@xxxxxxxxxx> Tested-by: Drew Fustini <dfustini@xxxxxxxxxxxx> Thanks for fixing this. I'll add clang to my testing going forward. Drew