xref: /dflybsd-src/sys/dev/drm/include/linux/pci-dma-compat.h (revision 1f0f7e1cab47396a4d19cf37fe8dba2a43f10e75)
1*1f0f7e1cSFrançois Tigeot /*
2*1f0f7e1cSFrançois Tigeot  * Copyright (c) 2020 François Tigeot <ftigeot@wolfpond.org>
3*1f0f7e1cSFrançois Tigeot  * All rights reserved.
4*1f0f7e1cSFrançois Tigeot  *
5*1f0f7e1cSFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6*1f0f7e1cSFrançois Tigeot  * modification, are permitted provided that the following conditions
7*1f0f7e1cSFrançois Tigeot  * are met:
8*1f0f7e1cSFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9*1f0f7e1cSFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10*1f0f7e1cSFrançois Tigeot  *    disclaimer.
11*1f0f7e1cSFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12*1f0f7e1cSFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13*1f0f7e1cSFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14*1f0f7e1cSFrançois Tigeot  *
15*1f0f7e1cSFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*1f0f7e1cSFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*1f0f7e1cSFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*1f0f7e1cSFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*1f0f7e1cSFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*1f0f7e1cSFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*1f0f7e1cSFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*1f0f7e1cSFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*1f0f7e1cSFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*1f0f7e1cSFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*1f0f7e1cSFrançois Tigeot  */
26*1f0f7e1cSFrançois Tigeot 
27*1f0f7e1cSFrançois Tigeot #ifndef _LINUX_PCI_DMA_COMPAT_H
28*1f0f7e1cSFrançois Tigeot #define _LINUX_PCI_DMA_COMPAT_H
29*1f0f7e1cSFrançois Tigeot 
30*1f0f7e1cSFrançois Tigeot #include <linux/dma-mapping.h>
31*1f0f7e1cSFrançois Tigeot 
32*1f0f7e1cSFrançois Tigeot static inline void *
33*1f0f7e1cSFrançois Tigeot pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_handle)
34*1f0f7e1cSFrançois Tigeot {
35*1f0f7e1cSFrançois Tigeot 	/* Our dma_alloc_coherent() implementation does not support a NULL pdev */
36*1f0f7e1cSFrançois Tigeot 	BUG_ON(pdev == NULL);
37*1f0f7e1cSFrançois Tigeot 
38*1f0f7e1cSFrançois Tigeot 	return dma_alloc_coherent(&pdev->dev, size, dma_handle, GFP_ATOMIC);
39*1f0f7e1cSFrançois Tigeot }
40*1f0f7e1cSFrançois Tigeot 
41*1f0f7e1cSFrançois Tigeot #endif	/* _LINUX_PCI_DMA_COMPAT_H */
42