[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251128185518.3989250-3-andriy.shevchenko@linux.intel.com>
Date: Fri, 28 Nov 2025 19:52:40 +0100
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Prajna Rajendra Kumar <prajna.rajendrakumar@...rochip.com>,
Mark Brown <broonie@...nel.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
linux-spi@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v4 2/2] spi: microchip-core: use XOR instead of ANDNOT to simplify the logic
Use XOR instead of ANDNOT to simplify the logic. The current approach
with (foo & BAR & ~baz) is harder to process than more usual pattern
for the comparing misconfiguration using ((foo ^ baz) & BAR) which
can be read as "find all different bits between foo and baz that are
related to BAR (mask)". Besides that it makes binary code shorter.
Function old new delta
mchp_corespi_setup 103 99 -4
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
drivers/spi/spi-microchip-core-spi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-microchip-core-spi.c b/drivers/spi/spi-microchip-core-spi.c
index 98bf0e6cd00e..2f4b21ad56a7 100644
--- a/drivers/spi/spi-microchip-core-spi.c
+++ b/drivers/spi/spi-microchip-core-spi.c
@@ -161,7 +161,7 @@ static int mchp_corespi_setup(struct spi_device *spi)
return -EOPNOTSUPP;
}
- if (spi->mode & SPI_MODE_X_MASK & ~spi->controller->mode_bits) {
+ if ((spi->mode ^ spi->controller->mode_bits) & SPI_MODE_X_MASK) {
dev_err(&spi->dev, "incompatible CPOL/CPHA, must match controller's Motorola mode\n");
return -EINVAL;
}
--
2.50.1
Powered by blists - more mailing lists