11f0f7e1cSFrançois Tigeot /*
21f0f7e1cSFrançois Tigeot * Copyright (c) 2020 François Tigeot <ftigeot@wolfpond.org>
31f0f7e1cSFrançois Tigeot * All rights reserved.
41f0f7e1cSFrançois Tigeot *
51f0f7e1cSFrançois Tigeot * Redistribution and use in source and binary forms, with or without
61f0f7e1cSFrançois Tigeot * modification, are permitted provided that the following conditions
71f0f7e1cSFrançois Tigeot * are met:
81f0f7e1cSFrançois Tigeot * 1. Redistributions of source code must retain the above copyright
91f0f7e1cSFrançois Tigeot * notice unmodified, this list of conditions, and the following
101f0f7e1cSFrançois Tigeot * disclaimer.
111f0f7e1cSFrançois Tigeot * 2. Redistributions in binary form must reproduce the above copyright
121f0f7e1cSFrançois Tigeot * notice, this list of conditions and the following disclaimer in the
131f0f7e1cSFrançois Tigeot * documentation and/or other materials provided with the distribution.
141f0f7e1cSFrançois Tigeot *
151f0f7e1cSFrançois Tigeot * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
161f0f7e1cSFrançois Tigeot * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
171f0f7e1cSFrançois Tigeot * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
181f0f7e1cSFrançois Tigeot * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
191f0f7e1cSFrançois Tigeot * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
201f0f7e1cSFrançois Tigeot * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
211f0f7e1cSFrançois Tigeot * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
221f0f7e1cSFrançois Tigeot * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
231f0f7e1cSFrançois Tigeot * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
241f0f7e1cSFrançois Tigeot * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
251f0f7e1cSFrançois Tigeot */
261f0f7e1cSFrançois Tigeot
271f0f7e1cSFrançois Tigeot #ifndef _LINUX_PCI_DMA_COMPAT_H
281f0f7e1cSFrançois Tigeot #define _LINUX_PCI_DMA_COMPAT_H
291f0f7e1cSFrançois Tigeot
301f0f7e1cSFrançois Tigeot #include <linux/dma-mapping.h>
311f0f7e1cSFrançois Tigeot
321f0f7e1cSFrançois Tigeot static inline void *
pci_alloc_consistent(struct pci_dev * pdev,size_t size,dma_addr_t * dma_handle)331f0f7e1cSFrançois Tigeot pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_handle)
341f0f7e1cSFrançois Tigeot {
351f0f7e1cSFrançois Tigeot /* Our dma_alloc_coherent() implementation does not support a NULL pdev */
361f0f7e1cSFrançois Tigeot BUG_ON(pdev == NULL);
371f0f7e1cSFrançois Tigeot
381f0f7e1cSFrançois Tigeot return dma_alloc_coherent(&pdev->dev, size, dma_handle, GFP_ATOMIC);
391f0f7e1cSFrançois Tigeot }
401f0f7e1cSFrançois Tigeot
41*aaf7b518SFrançois Tigeot static inline void
pci_free_consistent(struct pci_dev * pdev,size_t size,void * vaddr,dma_addr_t dma_handle)42*aaf7b518SFrançois Tigeot pci_free_consistent(struct pci_dev *pdev,
43*aaf7b518SFrançois Tigeot size_t size, void *vaddr, dma_addr_t dma_handle)
44*aaf7b518SFrançois Tigeot {
45*aaf7b518SFrançois Tigeot dma_free_coherent(&pdev->dev, size, vaddr, dma_handle);
46*aaf7b518SFrançois Tigeot }
47*aaf7b518SFrançois Tigeot
481f0f7e1cSFrançois Tigeot #endif /* _LINUX_PCI_DMA_COMPAT_H */
49