Can not compile dahdi 3.2 on fedora 36

Kernel is 5.19.8

dahdi 3.2.0

CC [M] /home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.o
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c: In function ‘t4_allocate_buffers’:
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c:3864:17: error: implicit declaration of function ‘pci_alloc_consistent’ [-Werror=implicit-function-declaration]
3864 | alloc = pci_alloc_consistent(wc->dev, numbufs * T4_BASE_SIZE(wc) * 2,
| ^~~~~~~~~~~~~~~~~~~~
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c:3864:15: warning: assignment to ‘void *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
3864 | alloc = pci_alloc_consistent(wc->dev, numbufs * T4_BASE_SIZE(wc) * 2,
| ^
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c: In function ‘t4_increase_latency’:
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c:3943:9: error: implicit declaration of function ‘pci_free_consistent’ [-Werror=implicit-function-declaration]
3943 | pci_free_consistent(wc->dev, T4_BASE_SIZE(wc) * oldbufs * 2,
| ^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
CC [M] /home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.o
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c: In function ‘t4_allocate_buffers’:
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c:3864:17: error: implicit declaration of function ‘pci_alloc_consistent’ [-Werror=implicit-function-declaration]
3864 | alloc = pci_alloc_consistent(wc->dev, numbufs * T4_BASE_SIZE(wc) * 2,
| ^~~~~~~~~~~~~~~~~~~~
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c:3864:15: warning: assignment to ‘void *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
3864 | alloc = pci_alloc_consistent(wc->dev, numbufs * T4_BASE_SIZE(wc) * 2,
| ^
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c: In function ‘t4_increase_latency’:
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c:3943:9: error: implicit declaration of function ‘pci_free_consistent’ [-Werror=implicit-function-declaration]
3943 | pci_free_consistent(wc->dev, T4_BASE_SIZE(wc) * oldbufs * 2,
| ^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
CC [M] /home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.o
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c: In function ‘t4_allocate_buffers’:
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c:3864:17: error: implicit declaration of function ‘pci_alloc_consistent’ [-Werror=implicit-function-declaration]
3864 | alloc = pci_alloc_consistent(wc->dev, numbufs * T4_BASE_SIZE(wc) * 2,
| ^~~~~~~~~~~~~~~~~~~~
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c:3864:15: warning: assignment to ‘void *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
3864 | alloc = pci_alloc_consistent(wc->dev, numbufs * T4_BASE_SIZE(wc) * 2,
| ^
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c: In function ‘t4_increase_latency’:
/home/toninho/Downloads/dahdi/linux/drivers/dahdi/wct4xxp/base.c:3943:9: error: implicit declaration of function ‘pci_free_consistent’ [-Werror=implicit-function-declaration]
3943 | pci_free_consistent(wc->dev, T4_BASE_SIZE(wc) * oldbufs * 2,
| ^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

Thanks for any help on this

These are bugs exposed by an improved gcc on the newer kernel (5.19)

If you compile on a 5.10 and possibly 5.15 kernel it should compile without fatal warnings, not sure if that’s possible for you, but maybe a way to get running quickly.

I will try to incorporate a patch this week to address these but it won’t be immediate.

In the meantime, you should report this on the DAHDI issue tracker, at https://issues.asterisk.org
If you don’t have an account, you can register at https://signup.asterisk.org/signup/

This is untested, but try adding this near the top of drivers/dahdi/wct4xxp/base.c or include/dahdi/kernel.h:

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
#include <linux/dma-mapping.h>
static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
		     dma_addr_t *dma_handle)
{
	return dma_alloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC);
}

static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size, void *vaddr, dma_addr_t dma_handle)
{
	dma_free_coherent(&hwdev->dev, size, vaddr, dma_handle);
}

static inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
{
	return dma_map_single(&hwdev->dev, ptr, size, (enum dma_data_direction)direction);
}

static inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
		 size_t size, int direction)
{
	dma_unmap_single(&hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
}

static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
{
	return dma_set_mask(&dev->dev, mask);
}
#endif