NVIDIA driver 340.108 not compiling in Debian 12.5 with 6.1.0-21 kernel

My old Dell Vostro 1700 laptop has a built-in GeForce 8400M. I’m using Debian 12.5 Bookworm with kernel 6.1.0-21.

I tried to compile the 340.108 driver, but it eventually fails.

At first it failed to find stdargs.h, so I added
EXTRA_CFLAGS += -I/usr/lib/gcc/x86_64-linux-gnu/12/include
in the Makefile.

Now it fails later:

fatal error: asm/kmap_types.h: No such file or directory
122 | include <asm/kmap_types.h> /* page table entry lookup */
| ^~~~~~~~~~~~~~~~~~
compilation terminated.

I can’t find kmap_types.h anywhere on my system. Where do I get it?

I got past not finding kmap_types.h by doing this in NVIDIA-Linux-x86_64-340.108/kernel:

ln -s /usr/src/linux-headers-6.1.0-21-common/include/uapi/asm-generic/types.h kmap_types.h
mkdir asm
cd asm
ln -s /usr/src/linux-headers-6.1.0-21-common/include/uapi/asm-generic/types.h kmap_types.h

Now it fails while looking for ioctl32.h