accesio / APCI

Currently supported and recommended PCI drivers
6 stars 8 forks source link

Error compiling for Ubuntu 22.04 #15

Closed mkaivs closed 8 months ago

mkaivs commented 8 months ago

I followed the installation step and got this error:

make CC="gcc" -C /lib/modules/6.5.0-14-generic/build M=/home/mkaivs/APCI 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 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
  CC [M]  /home/mkaivs/APCI/apci_fops.o
  CC [M]  /home/mkaivs/APCI/apci_dev.o
In file included from ./include/linux/linkage.h:7,
                 from ./arch/x86/include/asm/cache.h:5,
                 from ./include/linux/cache.h:6,
                 from ./include/linux/time.h:5,
                 from ./include/linux/stat.h:19,
                 from ./include/linux/module.h:13,
                 from /home/mkaivs/APCI/apci_dev.c:7:
/home/mkaivs/APCI/apci_dev.c: In function ‘apci_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/mkaivs/APCI/apci_dev.c:1933:29: note: in expansion of macro ‘THIS_MODULE’
 1933 |   class_apci = class_create(THIS_MODULE, APCI_CLASS_NAME);
      |                             ^~~~~~~~~~~
In file included from ./include/linux/device.h:31,
                 from ./include/linux/pci.h:37,
                 from /home/mkaivs/APCI/apci_dev.c:10:
./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/mkaivs/APCI/apci_dev.c:1933:16: error: too many arguments to function ‘class_create’
 1933 |   class_apci = class_create(THIS_MODULE, APCI_CLASS_NAME);
      |                ^~~~~~~~~~~~
./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/mkaivs/APCI/apci_dev.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.5.0-14-generic/Makefile:2037: /home/mkaivs/APCI] 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:11: all] Error 2

Please advise on how to compile the driver for Ubuntu 22.04.

jdolanIV commented 8 months ago

@mkaivs

This is because of a kernel API change introduced in kernel version 6.4.0. I have pushed 863de2b to master to address the issue. I have verified on my system, so I'm going to close this issue. Please reopen or let me know if you are still having issues.

-- Jay