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: use min_t() to improve code

Merge series from Qianfeng Rong <rongqianfeng@vivo.com>:

Use min_t() to reduce the code and improve readability.

No functional changes.

Mark Brown f5accfde 9fd5f18c

+11 -16
+4 -4
drivers/spi/spi-fsl-lpspi.c
··· 25 25 #include <linux/spi/spi.h> 26 26 #include <linux/spi/spi_bitbang.h> 27 27 #include <linux/types.h> 28 + #include <linux/minmax.h> 28 29 29 30 #define DRIVER_NAME "fsl_lpspi" 30 31 ··· 474 473 fsl_lpspi->tx = fsl_lpspi_buf_tx_u32; 475 474 } 476 475 477 - if (t->len <= fsl_lpspi->txfifosize) 478 - fsl_lpspi->watermark = t->len; 479 - else 480 - fsl_lpspi->watermark = fsl_lpspi->txfifosize; 476 + fsl_lpspi->watermark = min_t(typeof(fsl_lpspi->watermark), 477 + fsl_lpspi->txfifosize, 478 + t->len); 481 479 482 480 if (fsl_lpspi_can_dma(controller, spi, t)) 483 481 fsl_lpspi->usedma = true;
+2 -4
drivers/spi/spi-npcm-fiu.c
··· 13 13 #include <linux/vmalloc.h> 14 14 #include <linux/regmap.h> 15 15 #include <linux/of.h> 16 + #include <linux/minmax.h> 16 17 #include <linux/spi/spi-mem.h> 17 18 #include <linux/mfd/syscon.h> 18 19 ··· 499 498 500 499 do { 501 500 addr = ((u32)op->addr.val + i); 502 - if (currlen < 16) 503 - readlen = currlen; 504 - else 505 - readlen = 16; 501 + readlen = min_t(int, currlen, 16); 506 502 507 503 buf_ptr = data + i; 508 504 ret = npcm_fiu_uma_read(mem, op, addr, true, buf_ptr,
+5 -8
drivers/spi/spi-pl022.c
··· 33 33 #include <linux/pm_runtime.h> 34 34 #include <linux/of.h> 35 35 #include <linux/pinctrl/consumer.h> 36 + #include <linux/minmax.h> 36 37 37 38 /* 38 39 * This macro is used to define some register default values. ··· 761 760 * we just feed in this, else we stuff in as much 762 761 * as we can. 763 762 */ 764 - if (bytesleft < (PAGE_SIZE - offset_in_page(bufp))) 765 - mapbytes = bytesleft; 766 - else 767 - mapbytes = PAGE_SIZE - offset_in_page(bufp); 763 + mapbytes = min_t(int, bytesleft, 764 + PAGE_SIZE - offset_in_page(bufp)); 765 + 768 766 sg_set_page(sg, virt_to_page(bufp), 769 767 mapbytes, offset_in_page(bufp)); 770 768 bufp += mapbytes; ··· 775 775 } else { 776 776 /* Map the dummy buffer on every page */ 777 777 for_each_sg(sgtab->sgl, sg, sgtab->nents, i) { 778 - if (bytesleft < PAGE_SIZE) 779 - mapbytes = bytesleft; 780 - else 781 - mapbytes = PAGE_SIZE; 778 + mapbytes = min_t(int, bytesleft, PAGE_SIZE); 782 779 sg_set_page(sg, virt_to_page(pl022->dummypage), 783 780 mapbytes, 0); 784 781 bytesleft -= mapbytes;