blob: dbe56c77b464253b7b6748bd01c59aa15f12929f [file] [log] [blame]
Boris Brezillon46336962018-04-22 20:35:14 +02001/* 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
12#ifndef __LINUX_SPI_INTERNALS_H
13#define __LINUX_SPI_INTERNALS_H
14
15#include <linux/device.h>
16#include <linux/dma-direction.h>
17#include <linux/scatterlist.h>
18#include <linux/spi/spi.h>
19
20#ifdef CONFIG_HAS_DMA
21int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
22 struct sg_table *sgt, void *buf, size_t len,
23 enum dma_data_direction dir);
24void spi_unmap_buf(struct spi_controller *ctlr, struct device *dev,
25 struct sg_table *sgt, enum dma_data_direction dir);
26#else /* !CONFIG_HAS_DMA */
27static inline int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
28 struct sg_table *sgt, void *buf, size_t len,
29 enum dma_data_direction dir)
30{
31 return -EINVAL;
32}
33
34static inline void spi_unmap_buf(struct spi_controller *ctlr,
35 struct device *dev, struct sg_table *sgt,
36 enum dma_data_direction dir)
37{
38}
39#endif /* CONFIG_HAS_DMA */
40
41#endif /* __LINUX_SPI_INTERNALS_H */