Xilinx / hsdp-pcie-driver

GNU General Public License v2.0
3 stars 1 forks source link

Compilation failed on Ubuntu 22.04 LTS #1

Open yuewuo opened 10 months ago

yuewuo commented 10 months ago
helios@Helios:~/GitHub/hsdp-pcie-driver$ sudo make install
src/hsdp_pcie_driver_base.o src/hsdp_mgmt_pcie_driver.o src/hsdp_user_pcie_driver.o src/hsdp_mgmt_soft_pcie_driver.o
make -C /lib/modules/6.5.0-14-generic/build M=/home/helios/GitHub/hsdp-pcie-driver modules
make[1]: Entering directory '/usr/src/linux-headers-6.5.0-14-generic'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
  You are using:           gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
  CC [M]  /home/helios/GitHub/hsdp-pcie-driver/src/hsdp_pcie_driver_base.o
In file included from ./include/linux/linkage.h:7,
                 from ./include/linux/printk.h:8,
                 from ./include/asm-generic/bug.h:22,
                 from ./arch/x86/include/asm/bug.h:87,
                 from ./include/linux/bug.h:5,
                 from ./include/linux/fortify-string.h:5,
                 from ./include/linux/string.h:254,
                 from ./include/linux/uuid.h:11,
                 from ./include/linux/mod_devicetable.h:14,
                 from ./include/linux/pci.h:27,
                 from /home/helios/GitHub/hsdp-pcie-driver/src/hsdp_pcie_driver_base.c:21:
/home/helios/GitHub/hsdp-pcie-driver/src/hsdp_pcie_driver_base.c: In function ‘xil_hsdp_init’:
./include/linux/export.h:29:22: error: passing argument 1 of ‘class_create’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   29 | #define THIS_MODULE (&__this_module)
      |                     ~^~~~~~~~~~~~~~~
      |                      |
      |                      struct module *
/home/helios/GitHub/hsdp-pcie-driver/src/hsdp_pcie_driver_base.c:386:30: note: in expansion of macro ‘THIS_MODULE’
  386 |     xrt_class = class_create(THIS_MODULE, "xil_hsdp_class");
      |                              ^~~~~~~~~~~
In file included from ./include/linux/device.h:31,
                 from ./include/linux/pci.h:37:
./include/linux/device/class.h:230:54: note: expected ‘const char *’ but argument is of type ‘struct module *’
  230 | struct class * __must_check class_create(const char *name);
      |                                          ~~~~~~~~~~~~^~~~
/home/helios/GitHub/hsdp-pcie-driver/src/hsdp_pcie_driver_base.c:386:17: error: too many arguments to function ‘class_create’
  386 |     xrt_class = class_create(THIS_MODULE, "xil_hsdp_class");
      |                 ^~~~~~~~~~~~
./include/linux/device/class.h:230:29: note: declared here
  230 | struct class * __must_check class_create(const char *name);
      |                             ^~~~~~~~~~~~
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:251: /home/helios/GitHub/hsdp-pcie-driver/src/hsdp_pcie_driver_base.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.5.0-14-generic/Makefile:2037: /home/helios/GitHub/hsdp-pcie-driver] Error 2
make[1]: *** [Makefile:234: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.5.0-14-generic'
make: *** [Makefile:16: module] Error 2
yuewuo commented 10 months ago

The following fixes the issue

diff --git a/src/hsdp_pcie_driver_base.c b/src/hsdp_pcie_driver_base.c
index c91dd5e..c379d56 100755
--- a/src/hsdp_pcie_driver_base.c
+++ b/src/hsdp_pcie_driver_base.c
@@ -383,7 +383,7 @@ static int __init xil_hsdp_init(void)
     printk(KERN_INFO LOG_PREFIX "xil_hsdp_init\n");

     // Register the character device class for the actual files
-    xrt_class = class_create(THIS_MODULE, "xil_hsdp_class");
+    xrt_class = class_create("xil_hsdp_class");
     if (IS_ERR(xrt_class)) {
         xil_hsdp_cleanup();
         return PTR_ERR(xrt_class);