spi: Replace if-else-if by bitops and multiplications
[platform/kernel/linux-starfive.git] / drivers / spi / spi.c
index 6d74218..125dea8 100644 (file)
@@ -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);