Cannot compile kernel module after upgrade 15.3 to 15.4

I have an old serial card which I use to talk to my UPS. It requires a kernel module. I last installed it a few months ago on Leap 15.3 and have to recompile the module with every new kernel - which has worked over several kernel versions. It will not compile in 15.4.

The card is maybe 10 years old and the module source was last updated in 2018 - but it worked until recently.

Normally I do

cd /home/david/projects/UPS/perle_serial_card/perle-serial-3.9.2/pserial/
sudo make install
sudo depmod

In 15.4 that gives

david@localhost:~/projects/UPS/perle_serial_card/perle-serial-3.9.2/pserial> make
make -C /lib/modules/5.14.21-150400.22-default/build SUBDIRS=/home/david/projects/UPS/perle_serial_card/perle-serial-3.9.2/pserial modules
make[1]: Entering directory '/usr/src/linux-5.14.21-150400.22-obj/x86_64/default'
mkdir: cannot create directory ‘.tmp_14531’: Permission denied
mkdir: cannot create directory ‘.tmp_14533’: Permission denied
mkdir: cannot create directory ‘.tmp_14629’: Permission denied
mkdir: cannot create directory ‘.tmp_14631’: Permission denied
ln: failed to create symbolic link 'source': Permission denied
make[2]: *** [/usr/src/linux-5.14.21-150400.22/Makefile:577: outputmakefile] Error 1
make[1]: *** [/usr/src/linux-5.14.21-150400.22/Makefile:220: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-5.14.21-150400.22-obj/x86_64/default'
make: *** [Makefile:34: all] Error 2

If I use sudo I get

david@localhost:~/projects/UPS/perle_serial_card/perle-serial-3.9.2/pserial> sudo make
[sudo] password for root: 
make -C /lib/modules/5.14.21-150400.22-default/build SUBDIRS=/home/david/projects/UPS/perle_serial_card/perle-serial-3.9.2/pserial modules
make[1]: Entering directory '/usr/src/linux-5.14.21-150400.22-obj/x86_64/default'
  GEN     Makefile
make[3]: *** No rule to make target 'arch/x86/entry/syscalls/syscall_32.tbl', needed by 'arch/x86/include/generated/uapi/asm/unistd_32.h'.  Stop.
make[2]: *** [/usr/src/linux-5.14.21-150400.22/arch/x86/Makefile:231: archheaders] Error 2
make[1]: *** [/usr/src/linux-5.14.21-150400.22/Makefile:220: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-5.14.21-150400.22-obj/x86_64/default'
make: *** [Makefile:34: all] Error 2

I’m well out of my depth here. Something has changed and it’s possible that a small tweak will make it work again. Any suggestions - apart from to buy a USB-serial adapter?

make M=$PWD

which has been the standard way to build external module for as long as I remember. But it fails to build anyway, it needs quite some efforts to make it compatible with current kernel. Like

/home/bor/src/perle-serial-3.9.2/pserial/perle-serial.c: In function ‘transmit_chars’:
/home/bor/src/perle-serial-3.9.2/pserial/perle-serial.c:971:17: error: ‘struct tty_struct’ has no member named ‘stopped’; did you mean ‘hw_stopped’?
      info->tty->stopped || info->tty->hw_stopped) {

Well, ->stopped member was replaced by ->flow.stopped in kernel 5.14.

You broke kernel devel packages. At this point you should remove kernel-default-devel and kernel-devel, delete all remaining directories (they may not have been removed due to make writing extraneous files there) and reinstall these packages.

Thanks arvidjaar. I fixed the kernel-devel stuff as you specified. I also deleted kernel-preempt-devel which contained 5.3.18 files.

Using make M=$PWD I get loads of errors - see

I’ll go through it when I have some time. Why have all these errors appeared between 5.3.18 and 5.14.21? The module source hasn’t been updated since 2018. Has something major changed recently in the compile system?

Anyway, thanks for the help.

A little bit old, last supported kernel is 4…

But kernel source has.

Yes, obviously, I know the module hadn’t changed for years and the kernel has. But it’s not as if it hasn’t compiled and worked since kernel v4 - it worked with whatever kernel was last released in 15.3.

So I was just wondering what particular change to the kernel - or, I suspect, to the compiler defaults - broke the camel’s back.

Leap 15.3 has a backported kernel 5.9.
Leap 15.4 has a backported kernel 5.15 (I think).

So many changes between those kernel.

You have to patch your sources, as I do with the Network Drivers in my Repo…

Use this patch:

Thanks Malcolm.

I applied that patch (something new to learn about) and some of it worked:

david@localhost:~/projects/UPS/perle_serial_card/leap_15.4/perle-serial-3.9.2/pserial> patch perle-serial.c patch_1.patch
patching file perle-serial.c
Hunk #1 succeeded at 934 (offset -13 lines).
patch unexpectedly ends in middle of line
Hunk #2 succeeded at 2186 with fuzz 1 (offset -13 lines).

It added 12 lines, which reduced the number of error from 33 to 27. Some of the additions in the patch are, I think, already in my source.

Anyway, the original 33 errors are of only 7 different types, I think, so it’s not an insuperable job, even though I don’t know C. The serial card is not required often. I’m going on holiday. When I return I’ll look for more patch files and google each type of error.

Thanks to all who responded.

Look at some of the other patches, if I get time, can have a look at an rpm package

Here is a full patch…

Test when you get a moment, patch with a P1 option as well.

+#undef __KERNEL__
+#include <linux/tty_flags.h>
+#define __KERNEL__ 1

That does not look right (actually it looks very wrong). While this makes driver compile, those definitions are no more used by kernel, so it is unpredictable how driver will behave. This really needs porting to the current kernel API, not sweeping the problem under the carpet.

That needs to be done by the product developers… :wink:

I applied that patch, but on compiling got
“KERNEL_VERSION” is not defined.

So I moved
#include <linux/version.h>
up to the top and it compiles OK.

The card now works with the UPS.

Thanks very much for your help, Malcolm.