Unverified Commit c0c0293c authored by David Lechner's avatar David Lechner Committed by Mark Brown
Browse files

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: default avatarDavid Lechner <dlechner@baylibre.com>
Link: https://lore.kernel.org/r/20240206200648.1782234-1-dlechner@baylibre.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent b9c0b785
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -1170,9 +1170,7 @@ static int stm32_spi_prepare_msg(struct spi_controller *ctrl,
	if (spi->cfg->set_number_of_data) {
		int ret;

		ret = spi_split_transfers_maxwords(ctrl, msg,
						   spi->t_size_max,
						   GFP_KERNEL | GFP_DMA);
		ret = spi_split_transfers_maxwords(ctrl, msg, spi->t_size_max);
		if (ret)
			return ret;
	}
+8 −14
Original line number Diff line number Diff line
@@ -1752,7 +1752,7 @@ static int __spi_pump_transfer_message(struct spi_controller *ctlr,
	 */
	if ((msg->spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits & SPI_CS_WORD) ||
					       spi_is_csgpiod(msg->spi))) {
		ret = spi_split_transfers_maxwords(ctlr, msg, 1, GFP_KERNEL);
		ret = spi_split_transfers_maxwords(ctlr, msg, 1);
		if (ret) {
			msg->status = ret;
			spi_finalize_current_message(ctlr);
@@ -1767,8 +1767,7 @@ static int __spi_pump_transfer_message(struct spi_controller *ctlr,
		}
	} else {
		ret = spi_split_transfers_maxsize(ctlr, msg,
						  spi_max_transfer_size(msg->spi),
						  GFP_KERNEL | GFP_DMA);
						  spi_max_transfer_size(msg->spi));
		if (ret) {
			msg->status = ret;
			spi_finalize_current_message(ctlr);
@@ -3707,8 +3706,7 @@ static struct spi_replaced_transfers *spi_replace_transfers(
static int __spi_split_transfer_maxsize(struct spi_controller *ctlr,
					struct spi_message *msg,
					struct spi_transfer **xferp,
					size_t maxsize,
					gfp_t gfp)
					size_t maxsize)
{
	struct spi_transfer *xfer = *xferp, *xfers;
	struct spi_replaced_transfers *srt;
@@ -3719,7 +3717,7 @@ static int __spi_split_transfer_maxsize(struct spi_controller *ctlr,
	count = DIV_ROUND_UP(xfer->len, maxsize);

	/* Create replacement */
	srt = spi_replace_transfers(msg, xfer, 1, count, NULL, 0, gfp);
	srt = spi_replace_transfers(msg, xfer, 1, count, NULL, 0, GFP_KERNEL);
	if (IS_ERR(srt))
		return PTR_ERR(srt);
	xfers = srt->inserted_transfers;
@@ -3779,14 +3777,12 @@ static int __spi_split_transfer_maxsize(struct spi_controller *ctlr,
 * @ctlr:    the @spi_controller for this transfer
 * @msg:   the @spi_message to transform
 * @maxsize:  the maximum when to apply this
 * @gfp: GFP allocation flags
 *
 * Return: status of transformation
 */
int spi_split_transfers_maxsize(struct spi_controller *ctlr,
				struct spi_message *msg,
				size_t maxsize,
				gfp_t gfp)
				size_t maxsize)
{
	struct spi_transfer *xfer;
	int ret;
@@ -3801,7 +3797,7 @@ int spi_split_transfers_maxsize(struct spi_controller *ctlr,
	list_for_each_entry(xfer, &msg->transfers, transfer_list) {
		if (xfer->len > maxsize) {
			ret = __spi_split_transfer_maxsize(ctlr, msg, &xfer,
							   maxsize, gfp);
							   maxsize);
			if (ret)
				return ret;
		}
@@ -3819,14 +3815,12 @@ EXPORT_SYMBOL_GPL(spi_split_transfers_maxsize);
 * @ctlr:     the @spi_controller for this transfer
 * @msg:      the @spi_message to transform
 * @maxwords: the number of words to limit each transfer to
 * @gfp:      GFP allocation flags
 *
 * Return: status of transformation
 */
int spi_split_transfers_maxwords(struct spi_controller *ctlr,
				 struct spi_message *msg,
				 size_t maxwords,
				 gfp_t gfp)
				 size_t maxwords)
{
	struct spi_transfer *xfer;

@@ -3844,7 +3838,7 @@ int spi_split_transfers_maxwords(struct spi_controller *ctlr,
		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);
							   maxsize);
			if (ret)
				return ret;
		}
+2 −4
Original line number Diff line number Diff line
@@ -1365,12 +1365,10 @@ struct spi_replaced_transfers {

extern int spi_split_transfers_maxsize(struct spi_controller *ctlr,
				       struct spi_message *msg,
				       size_t maxsize,
				       gfp_t gfp);
				       size_t maxsize);
extern int spi_split_transfers_maxwords(struct spi_controller *ctlr,
					struct spi_message *msg,
					size_t maxwords,
					gfp_t gfp);
					size_t maxwords);

/*---------------------------------------------------------------------------*/