Thread (48 messages) 48 messages, 6 authors, 2023-07-12

Re: [PATCH v2 03/15] spi: Replace if-else-if by bitops and multiplications

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2023-07-11 10:59:24
Also in: alsa-devel, linux-amlogic, linux-arm-msm, linux-mediatek, linux-riscv, linux-rockchip, linux-spi, lkml, netdev

On Mon, Jul 10, 2023 at 05:56:59PM +0100, Mark Brown wrote:
On Mon, Jul 10, 2023 at 06:49:20PM +0300, Andy Shevchenko wrote:
quoted
-		if (xfer->bits_per_word <= 8)
-			maxsize = maxwords;
-		else if (xfer->bits_per_word <= 16)
-			maxsize = 2 * maxwords;
-		else
-			maxsize = 4 * maxwords;
-
+		maxsize = maxwords * roundup_pow_of_two(BITS_TO_BYTES(xfer->bits_per_word));
This will change the behaviour if bits_per_word is more than 32.  That
is validated out elsewhere but I shouldn't have had to go around
checking the code to confirm that this is the case.  This is the sort of
thing that should be highlighted when doing this sort of edge case
stylistic change.
Right, I have to add this into commit message of v3.

-- 
With Best Regards,
Andy Shevchenko

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help