Skip to content

Commit c0c0293

Browse files
dlechbroonie
authored andcommitted
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>
1 parent b9c0b78 commit c0c0293

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

drivers/spi/spi-stm32.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -1170,9 +1170,7 @@ static int stm32_spi_prepare_msg(struct spi_controller *ctrl,
11701170
if (spi->cfg->set_number_of_data) {
11711171
int ret;
11721172

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);
11761174
if (ret)
11771175
return ret;
11781176
}

drivers/spi/spi.c

+8-14
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ static int __spi_pump_transfer_message(struct spi_controller *ctlr,
17521752
*/
17531753
if ((msg->spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits & SPI_CS_WORD) ||
17541754
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);
17561756
if (ret) {
17571757
msg->status = ret;
17581758
spi_finalize_current_message(ctlr);
@@ -1767,8 +1767,7 @@ static int __spi_pump_transfer_message(struct spi_controller *ctlr,
17671767
}
17681768
} else {
17691769
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));
17721771
if (ret) {
17731772
msg->status = ret;
17741773
spi_finalize_current_message(ctlr);
@@ -3707,8 +3706,7 @@ static struct spi_replaced_transfers *spi_replace_transfers(
37073706
static int __spi_split_transfer_maxsize(struct spi_controller *ctlr,
37083707
struct spi_message *msg,
37093708
struct spi_transfer **xferp,
3710-
size_t maxsize,
3711-
gfp_t gfp)
3709+
size_t maxsize)
37123710
{
37133711
struct spi_transfer *xfer = *xferp, *xfers;
37143712
struct spi_replaced_transfers *srt;
@@ -3719,7 +3717,7 @@ static int __spi_split_transfer_maxsize(struct spi_controller *ctlr,
37193717
count = DIV_ROUND_UP(xfer->len, maxsize);
37203718

37213719
/* Create replacement */
3722-
srt = spi_replace_transfers(msg, xfer, 1, count, NULL, 0, gfp);
3720+
srt = spi_replace_transfers(msg, xfer, 1, count, NULL, 0, GFP_KERNEL);
37233721
if (IS_ERR(srt))
37243722
return PTR_ERR(srt);
37253723
xfers = srt->inserted_transfers;
@@ -3779,14 +3777,12 @@ static int __spi_split_transfer_maxsize(struct spi_controller *ctlr,
37793777
* @ctlr: the @spi_controller for this transfer
37803778
* @msg: the @spi_message to transform
37813779
* @maxsize: the maximum when to apply this
3782-
* @gfp: GFP allocation flags
37833780
*
37843781
* Return: status of transformation
37853782
*/
37863783
int spi_split_transfers_maxsize(struct spi_controller *ctlr,
37873784
struct spi_message *msg,
3788-
size_t maxsize,
3789-
gfp_t gfp)
3785+
size_t maxsize)
37903786
{
37913787
struct spi_transfer *xfer;
37923788
int ret;
@@ -3801,7 +3797,7 @@ int spi_split_transfers_maxsize(struct spi_controller *ctlr,
38013797
list_for_each_entry(xfer, &msg->transfers, transfer_list) {
38023798
if (xfer->len > maxsize) {
38033799
ret = __spi_split_transfer_maxsize(ctlr, msg, &xfer,
3804-
maxsize, gfp);
3800+
maxsize);
38053801
if (ret)
38063802
return ret;
38073803
}
@@ -3819,14 +3815,12 @@ EXPORT_SYMBOL_GPL(spi_split_transfers_maxsize);
38193815
* @ctlr: the @spi_controller for this transfer
38203816
* @msg: the @spi_message to transform
38213817
* @maxwords: the number of words to limit each transfer to
3822-
* @gfp: GFP allocation flags
38233818
*
38243819
* Return: status of transformation
38253820
*/
38263821
int spi_split_transfers_maxwords(struct spi_controller *ctlr,
38273822
struct spi_message *msg,
3828-
size_t maxwords,
3829-
gfp_t gfp)
3823+
size_t maxwords)
38303824
{
38313825
struct spi_transfer *xfer;
38323826

@@ -3844,7 +3838,7 @@ int spi_split_transfers_maxwords(struct spi_controller *ctlr,
38443838
maxsize = maxwords * roundup_pow_of_two(BITS_TO_BYTES(xfer->bits_per_word));
38453839
if (xfer->len > maxsize) {
38463840
ret = __spi_split_transfer_maxsize(ctlr, msg, &xfer,
3847-
maxsize, gfp);
3841+
maxsize);
38483842
if (ret)
38493843
return ret;
38503844
}

include/linux/spi/spi.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -1365,12 +1365,10 @@ struct spi_replaced_transfers {
13651365

13661366
extern int spi_split_transfers_maxsize(struct spi_controller *ctlr,
13671367
struct spi_message *msg,
1368-
size_t maxsize,
1369-
gfp_t gfp);
1368+
size_t maxsize);
13701369
extern int spi_split_transfers_maxwords(struct spi_controller *ctlr,
13711370
struct spi_message *msg,
1372-
size_t maxwords,
1373-
gfp_t gfp);
1371+
size_t maxwords);
13741372

13751373
/*---------------------------------------------------------------------------*/
13761374

0 commit comments

Comments
 (0)