public inbox for linux-spi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] spi: microchip-core: use XOR instead of ANDNOT to fix the logic
@ 2026-01-08 17:49 Andy Shevchenko
  2026-01-09 15:30 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2026-01-08 17:49 UTC (permalink / raw)
  To: Andy Shevchenko, Mark Brown, Prajna Rajendra Kumar, linux-spi,
	linux-kernel
  Cc: Conor Dooley

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

Updated the commit message, added Fixes and Test-by tags, and sent
as standalone patch.

 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 89e40fc45d73..c8ebb58e0369 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


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

* Re: [PATCH v1 1/1] spi: microchip-core: use XOR instead of ANDNOT to fix the logic
  2026-01-08 17:49 [PATCH v1 1/1] spi: microchip-core: use XOR instead of ANDNOT to fix the logic Andy Shevchenko
@ 2026-01-09 15:30 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-01-09 15:30 UTC (permalink / raw)
  To: Prajna Rajendra Kumar, linux-spi, linux-kernel, Andy Shevchenko
  Cc: Conor Dooley

On Thu, 08 Jan 2026 18:49:40 +0100, Andy Shevchenko wrote:
> 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: microchip-core: use XOR instead of ANDNOT to fix the logic
      commit: 19a4505a7a5d4eea70f1a42d601c25d730922fdf

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


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

end of thread, other threads:[~2026-01-09 15:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-08 17:49 [PATCH v1 1/1] spi: microchip-core: use XOR instead of ANDNOT to fix the logic Andy Shevchenko
2026-01-09 15:30 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox