[PATCH v3 8/9] spi: dw: Use dma_slave_caps bus width helpers
From: Nuno Sá
Date: Mon Aug 31 2026 - 07:51:57 EST
Store the common TX destination and RX source bus widths in a
driver-owned DMA bus width bitmap and populate it through the
dma_slave_caps helper.
This avoids depending on the legacy src_addr_widths and dst_addr_widths
masks returned by dma_get_slave_caps().
Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
Signed-off-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
---
drivers/spi/spi-dw-dma.c | 8 +++++---
drivers/spi/spi-dw.h | 3 ++-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-dw-dma.c b/drivers/spi/spi-dw-dma.c
index fe726b9b1780..bbd7ee884d0e 100644
--- a/drivers/spi/spi-dw-dma.c
+++ b/drivers/spi/spi-dw-dma.c
@@ -7,6 +7,7 @@
#include <linux/completion.h>
#include <linux/dma-mapping.h>
+#include <linux/dma/engine/widthmask.h>
#include <linux/dmaengine.h>
#include <linux/irqreturn.h>
#include <linux/jiffies.h>
@@ -100,10 +101,11 @@ static int dw_spi_dma_caps_init(struct dw_spi *dws)
/*
* Assuming both channels belong to the same DMA controller hence the
- * peripheral side address width capabilities most likely would be
+ * peripheral side bus width capabilities most likely would be
* the same.
*/
- dws->dma_addr_widths = tx.dst_addr_widths & rx.src_addr_widths;
+ dma_bus_width_and(dws->dma_bus_widths, tx.dst_bus_widths,
+ rx.src_bus_widths);
return 0;
}
@@ -253,7 +255,7 @@ static bool dw_spi_can_dma(struct spi_controller *ctlr,
dma_bus_width = dw_spi_dma_convert_width(dws->n_bytes);
- return dws->dma_addr_widths & BIT(dma_bus_width);
+ return dma_bus_width_test(dws->dma_bus_widths, dma_bus_width);
}
static int dw_spi_dma_wait(struct dw_spi *dws, unsigned int len, u32 speed)
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index 2f2debc64e73..e33577c96afe 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -10,6 +10,7 @@
#include <linux/scatterlist.h>
#include <linux/spi/spi-mem.h>
#include <linux/bitfield.h>
+#include <linux/dma/engine/types.h>
/* Synopsys DW SSI IP-core virtual IDs */
#define DW_PSSI_ID 0
@@ -190,7 +191,7 @@ struct dw_spi {
struct dma_chan *rxchan;
u32 rxburst;
u32 dma_sg_burst;
- u32 dma_addr_widths;
+ dma_buswidth_mask_t dma_bus_widths;
unsigned long dma_chan_busy;
dma_addr_t dma_addr; /* phy address of the Data register */
const struct dw_spi_dma_ops *dma_ops;
--
2.55.0