Unverified Commit 19a4505a authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mark Brown
Browse files

spi: microchip-core: use XOR instead of ANDNOT to fix the logic



Use XOR instead of ANDNOT to fix the logic. The current approach with
(foo & BAR & ~baz) is harder to process, and it proved to be wrong,
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 the binary code shorter.

Function                                     old     new   delta
mchp_corespi_setup                           103      99      -4

Fixes: 059f5458 ("spi: add support for microchip "soft" spi controller")
Reviewed-by: default avatarConor Dooley <conor.dooley@microchip.com>
Tested-by: default avatarPrajna Rajendra Kumar <prajna.rajendrakumar@microchip.com>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260108175100.3535306-1-andriy.shevchenko@linux.intel.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 36227ab9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
	}