internals.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2018 Exceet Electronics GmbH
  4. * Copyright (C) 2018 Bootlin
  5. *
  6. * Author: Boris Brezillon <boris.brezillon@bootlin.com>
  7. *
  8. * Helpers needed by the spi or spi-mem logic. Should not be used outside of
  9. * spi-mem.c and spi.c.
  10. */
  11. #ifndef __LINUX_SPI_INTERNALS_H
  12. #define __LINUX_SPI_INTERNALS_H
  13. #include <linux/device.h>
  14. #include <linux/dma-direction.h>
  15. #include <linux/scatterlist.h>
  16. #include <linux/spi/spi.h>
  17. void spi_flush_queue(struct spi_controller *ctrl);
  18. #ifdef CONFIG_HAS_DMA
  19. int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
  20. struct sg_table *sgt, void *buf, size_t len,
  21. enum dma_data_direction dir);
  22. void spi_unmap_buf(struct spi_controller *ctlr, struct device *dev,
  23. struct sg_table *sgt, enum dma_data_direction dir);
  24. #else /* !CONFIG_HAS_DMA */
  25. static inline int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
  26. struct sg_table *sgt, void *buf, size_t len,
  27. enum dma_data_direction dir)
  28. {
  29. return -EINVAL;
  30. }
  31. static inline void spi_unmap_buf(struct spi_controller *ctlr,
  32. struct device *dev, struct sg_table *sgt,
  33. enum dma_data_direction dir)
  34. {
  35. }
  36. #endif /* CONFIG_HAS_DMA */
  37. #endif /* __LINUX_SPI_INTERNALS_H */