Compiling wanpipe driver on kernel 5.11(在内核5.11上编译wanpiet驱动程序)
问题描述
我正在尝试在Ubuntu 21.04和内核v5.11上编译Sangoma的wantube驱动程序v7.0.32,以便与我的A200电话卡一起使用。该驱动程序旨在支持内核5.8。我已经成功地使用5.8内核构建了它,但我更希望能够继续使用5.11内核,这样我就不必降级我的生产服务器。
我缺乏C++知识,无法解决如何在编译wanpie驱动程序时排除‘struct’和";‘’struct FILE_OPERATION‘中没有名为’ioctl‘成员的字段的位置初始化错误。
以下是make的结果:
make KBUILD_VERBOSE=0 KBUILD_MODPOST_WARN=1 -C /lib/modules/5.11.0-22-generic/build M=/usr/src/wanpipe-7.0.32/patches/kdrivers/src/net EXTRA_FLAGS="-I/usr/src/wanpipe-7.0.32/patches/kdrivers/include -I/usr/src/wanpipe-7.0.32/patches/kdrivers/include/annexg -I/usr/src/wanpipe-7.0.32/patches/kdrivers/wanec -D__LINUX__ -I/usr/src/wanpipe-7.0.32/patches/kdrivers/wanec -I/usr/src/wanpipe-7.0.32/patches/kdrivers/wanec/oct6100_api -I/usr/src/wanpipe-7.0.32/patches/kdrivers/wanec/oct6100_api/include -DCONFIG_PRODUCT_WANPIPE_BASE -DCONFIG_PRODUCT_WANPIPE_AFT -DCONFIG_PRODUCT_WANPIPE_AFT_CORE -DCONFIG_PRODUCT_WANPIPE_AFT_TE1 -DCONFIG_PRODUCT_WANPIPE_AFT_TE3 -DCONFIG_PRODUCT_WANPIPE_AFT_56K -DCONFIG_WANPIPE_HWEC -DCONFIG_PRODUCT_WANPIPE_SOCK_DATASCOPE -DCONFIG_PRODUCT_WANPIPE_AFT_BRI -DCONFIG_PRODUCT_WANPIPE_AFT_SERIAL -DCONFIG_PRODUCT_WANPIPE_TDM_VOICE_DCHAN -DCONFIG_PRODUCT_WANPIPE_CODEC_SLINEAR_LAW -DCONFIG_PRODUCT_WANPIPE_AFT_RM -DCONFIG_PRODUCT_WANPIPE_USB -DCONFIG_PRODUCT_WANPIPE_A700 -DCONFIG_PRODUCT_A600 -DCONFIG_PRODUCT_WANPIPE_AFT_A600 -DCONFIG_PRODUCT_WANPIPE_AFT_A700 -DCONFIG_PRODUCT_WANPIPE_AFT_B601 -DCONFIG_PRODUCT_WANPIPE_AFT_B800 -I/lib/modules/5.11.0-22-generic/build/include/linux -I/usr/src/dahdi -DKERN_PROC_PDE_FEATURE=2 -DKERN_MEMCPY_FROM_MSG=1 -DKERN_MEMCPY_TO_MSG=1 -DKERN_SK_FOR_NODE_FEATURE=0 -DKERN_NETIF_TRANS_UPDATE=1 -DKERN_NDO_CHANGE_MTU_RH74=0 -DKERN_CLASS_DEV_GROUPS=1 -DKERN_TIMER_SETUP=2 -DKERN_REFCNT_UPDATE=3 -DKERN_SIG_UPDATE=11 -DKERN_CLASS_PROTO_OPS_UPDATE=0 -DKERN_DEV_CHG_FLAG_UPDATE=2 -DKERN_NDO_TIMEOUT_UPDATE=2 -DKERN_DO_GET_TIME=0 -DKERN_GET_KENEL_DS=0 -DKERN_PROC_CREATE=0 -DKERN_TIMER_32BIT=0 -DWANPIPE_USE_I_PRIVATE " ZAPDIR= ZAPHDLC= HOMEDIR=/usr/src/wanpipe-7.0.32 modules
make[1]: Entering directory '/usr/src/linux-headers-5.11.0-22-generic'
CC [M] /usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.o
In file included from /usr/src/wanpipe-7.0.32/patches/kdrivers/include/wanpipe_defines.h:30,
from /usr/src/wanpipe-7.0.32/patches/kdrivers/include/wanpipe_cdev_iface.h:9,
from /usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.c:16:
/usr/src/wanpipe-7.0.32/patches/kdrivers/include/wanpipe_kernel.h:96:25: error: ‘struct file_operations’ has no member named ‘ioctl’
96 | #define WAN_IOCTL ioctl
| ^~~~~
/usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.c:133:2: note: in expansion of macro ‘WAN_IOCTL’
133 | WAN_IOCTL: wp_cdev_ioctl,
| ^~~~~~~~~
/usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.c:133:13: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
133 | WAN_IOCTL: wp_cdev_ioctl,
| ^~~~~~~~~~~~~
/usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.c:133:13: note: (near initialization for ‘wp_cdev_fops’)
/usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.c:133:13: error: initialization of ‘int (*)(struct file *, loff_t, loff_t, int)’ {aka ‘int (*)(struct file *, long long int, long long int, int)’} from incompatible pointer type ‘int (*)(struct inode *, struct file *, unsigned int, long unsigned int)’ [-Werror=incompatible-pointer-types]
/usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.c:133:13: note: (near initialization for ‘wp_cdev_fops.fsync’)
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:287: /usr/src/wanpipe-7.0.32/patches/kdrivers/src/net/wanpipe_cdev_linux.o] Error 1
make[1]: *** [Makefile:1848: /usr/src/wanpipe-7.0.32/patches/kdrivers/src/net] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.11.0-22-generic'
make: *** [Makefile:399: all_kmod] Error 2
wantube_cdev_linux.c部分:
/*=========================================================
* Static Defines
*=========================================================*/
static struct file_operations wp_cdev_fops = {
owner: THIS_MODULE,
llseek: NULL,
open: wp_cdev_open,
release: wp_cdev_release,
WAN_IOCTL: wp_cdev_ioctl,
read: wp_cdev_read,
write: wp_cdev_write,
poll: wp_cdev_poll,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
compat_ioctl: wp_cdev_compat_ioctl,
#endif
wanpip_kernel.h:
/////////////2.6.36/////////////////////////////
#ifdef HAVE_UNLOCKED_IOCTL
#define WAN_IOCTL unlocked_ioctl
#define WAN_IOCTL_RET_TYPE long
#define WANDEF_IOCTL_FUNC(function, struct_ptr_file, cmd, data) function(struct_ptr_file, cmd, data)
#else
#define WAN_IOCTL ioctl
#define WAN_IOCTL_RET_TYPE int
#define WANDEF_IOCTL_FUNC(function, struct_ptr_file, cmd, data) function(struct inode *inode, struct_ptr_file, cmd, data)
#endif
////////////////////////////////////////////////
感谢任何帮助。
推荐答案
WANPIPE之前的代码仅适用于2.6.36或更低版本的内核。在ubuntu 21.04中,他们对WRT内核5.8做了一些修改。在5.8或更高的内核版本中,文件操作中没有ioctl函数指针。相反,他们使用的是unlock_ioctl。以下更改将消除该错误。你可以用同样的方法核对一下。谢谢!
#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)) && (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,36)))
#ifndef HAVE_UNLOCKED_IOCTL2
#define HAVE_UNLOCKED_IOCTL2
#define WAN_IOCTL unlocked_ioctl
#define WAN_IOCTL_RET_TYPE long
#define WANDEF_IOCTL_FUNC(function, struct_ptr_file, cmd, data) function(struct_ptr_file, cmd, data)
#endif
#else
#ifndef HAVE_UNLOCKED_IOCTL2
#define HAVE_UNLOCKED_IOCTL2
#define WAN_IOCTL unlocked_ioctl
#define WAN_IOCTL_RET_TYPE long
#define WANDEF_IOCTL_FUNC(function, struct_ptr_file, cmd, data) function(struct_ptr_file, cmd, data)
#else
# define WAN_IOCTL ioctl
# define WAN_IOCTL_RET_TYPE int
# define WANDEF_IOCTL_FUNC(function, struct_ptr_file, cmd, data) function(struct inode *inode, struct_ptr_file, cmd, data)
#endif
#endif
这篇关于在内核5.11上编译wanpiet驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在内核5.11上编译wanpiet驱动程序
基础教程推荐
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- 运算符重载的基本规则和习语是什么? 2022-10-31
- C++,'if' 表达式中的变量声明 2021-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- 设计字符串本地化的最佳方法 2022-01-01