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: drop gpf arg from __spi_split_transfer_maxsize()

The __spi_split_transfer_maxsize() function has a gpf argument to allow
callers to specify the type of memory allocation that needs to be used.
However, this function only allocates struct spi_transfer and is not
intended to be used from atomic contexts so this type should always be
GFP_KERNEL, so we can just drop the argument.

Some callers of these functions also passed GFP_DMA, but since only
struct spi_transfer is allocated and not any tx/rx buffers, this is
not actually necessary and is removed in this commit.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://lore.kernel.org/r/20240206200648.1782234-1-dlechner@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

David Lechner and committed by
Mark Brown
c0c0293c b9c0b785

+11 -21
+1 -3
drivers/spi/spi-stm32.c
··· 1170 1170 if (spi->cfg->set_number_of_data) { 1171 1171 int ret; 1172 1172 1173 - ret = spi_split_transfers_maxwords(ctrl, msg, 1174 - spi->t_size_max, 1175 - GFP_KERNEL | GFP_DMA); 1173 + ret = spi_split_transfers_maxwords(ctrl, msg, spi->t_size_max); 1176 1174 if (ret) 1177 1175 return ret; 1178 1176 }
+8 -14
drivers/spi/spi.c
··· 1752 1752 */ 1753 1753 if ((msg->spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits & SPI_CS_WORD) || 1754 1754 spi_is_csgpiod(msg->spi))) { 1755 - ret = spi_split_transfers_maxwords(ctlr, msg, 1, GFP_KERNEL); 1755 + ret = spi_split_transfers_maxwords(ctlr, msg, 1); 1756 1756 if (ret) { 1757 1757 msg->status = ret; 1758 1758 spi_finalize_current_message(ctlr); ··· 1767 1767 } 1768 1768 } else { 1769 1769 ret = spi_split_transfers_maxsize(ctlr, msg, 1770 - spi_max_transfer_size(msg->spi), 1771 - GFP_KERNEL | GFP_DMA); 1770 + spi_max_transfer_size(msg->spi)); 1772 1771 if (ret) { 1773 1772 msg->status = ret; 1774 1773 spi_finalize_current_message(ctlr); ··· 3706 3707 static int __spi_split_transfer_maxsize(struct spi_controller *ctlr, 3707 3708 struct spi_message *msg, 3708 3709 struct spi_transfer **xferp, 3709 - size_t maxsize, 3710 - gfp_t gfp) 3710 + size_t maxsize) 3711 3711 { 3712 3712 struct spi_transfer *xfer = *xferp, *xfers; 3713 3713 struct spi_replaced_transfers *srt; ··· 3717 3719 count = DIV_ROUND_UP(xfer->len, maxsize); 3718 3720 3719 3721 /* Create replacement */ 3720 - srt = spi_replace_transfers(msg, xfer, 1, count, NULL, 0, gfp); 3722 + srt = spi_replace_transfers(msg, xfer, 1, count, NULL, 0, GFP_KERNEL); 3721 3723 if (IS_ERR(srt)) 3722 3724 return PTR_ERR(srt); 3723 3725 xfers = srt->inserted_transfers; ··· 3777 3779 * @ctlr: the @spi_controller for this transfer 3778 3780 * @msg: the @spi_message to transform 3779 3781 * @maxsize: the maximum when to apply this 3780 - * @gfp: GFP allocation flags 3781 3782 * 3782 3783 * Return: status of transformation 3783 3784 */ 3784 3785 int spi_split_transfers_maxsize(struct spi_controller *ctlr, 3785 3786 struct spi_message *msg, 3786 - size_t maxsize, 3787 - gfp_t gfp) 3787 + size_t maxsize) 3788 3788 { 3789 3789 struct spi_transfer *xfer; 3790 3790 int ret; ··· 3797 3801 list_for_each_entry(xfer, &msg->transfers, transfer_list) { 3798 3802 if (xfer->len > maxsize) { 3799 3803 ret = __spi_split_transfer_maxsize(ctlr, msg, &xfer, 3800 - maxsize, gfp); 3804 + maxsize); 3801 3805 if (ret) 3802 3806 return ret; 3803 3807 } ··· 3815 3819 * @ctlr: the @spi_controller for this transfer 3816 3820 * @msg: the @spi_message to transform 3817 3821 * @maxwords: the number of words to limit each transfer to 3818 - * @gfp: GFP allocation flags 3819 3822 * 3820 3823 * Return: status of transformation 3821 3824 */ 3822 3825 int spi_split_transfers_maxwords(struct spi_controller *ctlr, 3823 3826 struct spi_message *msg, 3824 - size_t maxwords, 3825 - gfp_t gfp) 3827 + size_t maxwords) 3826 3828 { 3827 3829 struct spi_transfer *xfer; 3828 3830 ··· 3838 3844 maxsize = maxwords * roundup_pow_of_two(BITS_TO_BYTES(xfer->bits_per_word)); 3839 3845 if (xfer->len > maxsize) { 3840 3846 ret = __spi_split_transfer_maxsize(ctlr, msg, &xfer, 3841 - maxsize, gfp); 3847 + maxsize); 3842 3848 if (ret) 3843 3849 return ret; 3844 3850 }
+2 -4
include/linux/spi/spi.h
··· 1365 1365 1366 1366 extern int spi_split_transfers_maxsize(struct spi_controller *ctlr, 1367 1367 struct spi_message *msg, 1368 - size_t maxsize, 1369 - gfp_t gfp); 1368 + size_t maxsize); 1370 1369 extern int spi_split_transfers_maxwords(struct spi_controller *ctlr, 1371 1370 struct spi_message *msg, 1372 - size_t maxwords, 1373 - gfp_t gfp); 1371 + size_t maxwords); 1374 1372 1375 1373 /*---------------------------------------------------------------------------*/ 1376 1374