mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 09:34:12 +08:00
spi: Replace if-else-if by bitops and multiplications
Instead of if-else-if, simply call roundup_pow_of_two(BITS_PER_BYTES()). Note, there is no division assumed as compiler may optimize it away. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20230710154932.68377-4-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
440c47331b
commit
2b308e7176
@ -3643,13 +3643,7 @@ int spi_split_transfers_maxwords(struct spi_controller *ctlr,
|
||||
size_t maxsize;
|
||||
int ret;
|
||||
|
||||
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));
|
||||
if (xfer->len > maxsize) {
|
||||
ret = __spi_split_transfer_maxsize(ctlr, msg, &xfer,
|
||||
maxsize, gfp);
|
||||
|
Loading…
Reference in New Issue
Block a user