Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 059f545832be ("spi: add support for microchip "soft" spi controller")
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Tested-by: Prajna Rajendra Kumar <prajna.rajendrakumar@microchip.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260108175100.3535306-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Andy Shevchenko and committed by
Mark Brown
19a4505a 36227ab9

+1 -1
+1 -1
drivers/spi/spi-microchip-core-spi.c
··· 161 161 return -EOPNOTSUPP; 162 162 } 163 163 164 - if (spi->mode & SPI_MODE_X_MASK & ~spi->controller->mode_bits) { 164 + if ((spi->mode ^ spi->controller->mode_bits) & SPI_MODE_X_MASK) { 165 165 dev_err(&spi->dev, "incompatible CPOL/CPHA, must match controller's Motorola mode\n"); 166 166 return -EINVAL; 167 167 }