Re: [PATCH 8/9] spi: dw: Use dma_slave_caps bus width helpers

Frank Li <[email protected]> Thu, 30 Jul 2026 14:31:43 -0500
Newsgroups org.kernel.vger.dmaengine,org.kernel.vger.linux-iio
Message-ID <amumn1HJAcxVEWt5@SMW015318>
On Thu, Jul 30, 2026 at 03:23:15PM +0100, Nuno Sá via B4 Relay wrote:
> [You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> From: Nuno Sá <[email protected]>
>
> 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().
>
> Signed-off-by: Nuno Sá <[email protected]>
> ---

Reviewed-by: Frank Li <[email protected]>

>  drivers/spi/spi-dw-dma.c | 6 +++---
>  drivers/spi/spi-dw.h     | 3 ++-
>  2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/spi-dw-dma.c b/drivers/spi/spi-dw-dma.c
> index fe726b9b1780..2e23ead4a94f 100644
> --- a/drivers/spi/spi-dw-dma.c
> +++ b/drivers/spi/spi-dw-dma.c
> @@ -100,10 +100,10 @@ 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_slave_caps_intersect_widths(&tx, &rx, dws->dma_bus_widths);
>
>         return 0;
>  }
> @@ -253,7 +253,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 test_bit(dma_bus_width, dws->dma_bus_widths);
>  }
>
>  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 9cc79c566a70..9111ffc5e9d7 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/dmaengine.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;
> +       DECLARE_DMA_BUS_WIDTHS(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
>
>