diff mbox series

[v1,1/8] spi: Introduce internal spi_xfer_is_dma_mapped() helper

Message ID 20240531194723.1761567-2-andriy.shevchenko@linux.intel.com (mailing list archive)
State Not Applicable
Headers show
Series spi: Rework DMA mapped flag | expand

Commit Message

Andy Shevchenko May 31, 2024, 7:42 p.m. UTC
There are few drivers that use the same pattern to check if the transfer
is DMA mapped or not. Provide a helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/internals.h | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Bryan O'Donoghue June 3, 2024, 10:53 p.m. UTC | #1
On 31/05/2024 20:42, Andy Shevchenko wrote:
> There are few drivers that use the same pattern to check if the transfer
> is DMA mapped or not. Provide a helper.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/spi/internals.h | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/spi/internals.h b/drivers/spi/internals.h
> index 4a28a8395552..47a87c2a6979 100644
> --- a/drivers/spi/internals.h
> +++ b/drivers/spi/internals.h
> @@ -40,4 +40,12 @@ static inline void spi_unmap_buf(struct spi_controller *ctlr,
>   }
>   #endif /* CONFIG_HAS_DMA */
>   
> +static inline bool spi_xfer_is_dma_mapped(struct spi_controller *ctlr,
> +					  struct spi_device *spi,
> +					  struct spi_transfer *xfer)
> +{
> +	return ctlr->can_dma && ctlr->can_dma(ctlr, spi, xfer) &&
> +	       ctlr->cur_msg_mapped;
> +}
> +
>   #endif /* __LINUX_SPI_INTERNALS_H */

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
diff mbox series

Patch

diff --git a/drivers/spi/internals.h b/drivers/spi/internals.h
index 4a28a8395552..47a87c2a6979 100644
--- a/drivers/spi/internals.h
+++ b/drivers/spi/internals.h
@@ -40,4 +40,12 @@  static inline void spi_unmap_buf(struct spi_controller *ctlr,
 }
 #endif /* CONFIG_HAS_DMA */
 
+static inline bool spi_xfer_is_dma_mapped(struct spi_controller *ctlr,
+					  struct spi_device *spi,
+					  struct spi_transfer *xfer)
+{
+	return ctlr->can_dma && ctlr->can_dma(ctlr, spi, xfer) &&
+	       ctlr->cur_msg_mapped;
+}
+
 #endif /* __LINUX_SPI_INTERNALS_H */