internals.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #ifdef CONFIG_HAS_DMA
  18. int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
  19. struct sg_table *sgt, void *buf, size_t len,
  20. enum dma_data_direction dir);
  21. void spi_unmap_buf(struct spi_controller *ctlr, struct device *dev,
  22. struct sg_table *sgt, enum dma_data_direction dir);
  23. #else /* !CONFIG_HAS_DMA */
  24. static inline int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
  25. struct sg_table *sgt, void *buf, size_t len,
  26. enum dma_data_direction dir)
  27. {
  28. return -EINVAL;
  29. }
  30. static inline void spi_unmap_buf(struct spi_controller *ctlr,
  31. struct device *dev, struct sg_table *sgt,
  32. enum dma_data_direction dir)
  33. {
  34. }
  35. #endif /* CONFIG_HAS_DMA */
  36. #endif /* __LINUX_SPI_INTERNALS_H */