Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * Copyright (C) 2018 Exceet Electronics GmbH
0004  * Copyright (C) 2018 Bootlin
0005  *
0006  * Author: Boris Brezillon <boris.brezillon@bootlin.com>
0007  *
0008  * Helpers needed by the spi or spi-mem logic. Should not be used outside of
0009  * spi-mem.c and spi.c.
0010  */
0011 
0012 #ifndef __LINUX_SPI_INTERNALS_H
0013 #define __LINUX_SPI_INTERNALS_H
0014 
0015 #include <linux/device.h>
0016 #include <linux/dma-direction.h>
0017 #include <linux/scatterlist.h>
0018 #include <linux/spi/spi.h>
0019 
0020 void spi_flush_queue(struct spi_controller *ctrl);
0021 
0022 #ifdef CONFIG_HAS_DMA
0023 int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
0024         struct sg_table *sgt, void *buf, size_t len,
0025         enum dma_data_direction dir);
0026 void spi_unmap_buf(struct spi_controller *ctlr, struct device *dev,
0027            struct sg_table *sgt, enum dma_data_direction dir);
0028 #else /* !CONFIG_HAS_DMA */
0029 static inline int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
0030                   struct sg_table *sgt, void *buf, size_t len,
0031                   enum dma_data_direction dir)
0032 {
0033     return -EINVAL;
0034 }
0035 
0036 static inline void spi_unmap_buf(struct spi_controller *ctlr,
0037                  struct device *dev, struct sg_table *sgt,
0038                  enum dma_data_direction dir)
0039 {
0040 }
0041 #endif /* CONFIG_HAS_DMA */
0042 
0043 #endif /* __LINUX_SPI_INTERNALS_H */