From 30bac3c8a70f254c3bc2b3be2a08e7525c0d68e3 Mon Sep 17 00:00:00 2001 From: Andrea Manzi Date: Sat, 25 Apr 2026 23:05:41 +0200 Subject: [PATCH] customhidsony: fix DKMS build failures on kernel >= 6.12 Two kernel API changes break the hid-sony DKMS module when building against kernel >= 6.12: 1. asm/unaligned.h was removed; the replacement is linux/unaligned.h. Detect this at DKMS pre-build time using the kernel version and patch the downloaded hid-sony.c source accordingly. 2. The hid_driver.report_fixup callback return type changed from u8* to const u8* (kernel >= 6.2). The old rpi-5.10.y source still uses the non-const signature, causing -Werror=incompatible-pointer-types to fail the build. Suppress the error via ccflags-y since promoting u8* to const u8* is always safe. Co-Authored-By: Claude Sonnet 4.6 --- scriptmodules/supplementary/customhidsony.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scriptmodules/supplementary/customhidsony.sh b/scriptmodules/supplementary/customhidsony.sh index 5d0d3b7b98..ba3b17c8f3 100644 --- a/scriptmodules/supplementary/customhidsony.sh +++ b/scriptmodules/supplementary/customhidsony.sh @@ -29,6 +29,8 @@ function sources_customhidsony() { cat > "Makefile" << _EOF_ obj-m := drivers/hid/hid-sony.o +# kernel >= 6.x changed report_fixup return type to const u8*; suppress the pointer-type error +ccflags-y += -Wno-error=incompatible-pointer-types _EOF_ cat > "dkms.conf" << _EOF_ @@ -48,6 +50,13 @@ mkdir -p "drivers/hid/" "patches" curl -s https://raw.githubusercontent.com/raspberrypi/linux/"\$rpi_kernel_ver"/drivers/hid/hid-sony.c -o "drivers/hid/hid-sony.c" curl -s https://raw.githubusercontent.com/raspberrypi/linux/"\$rpi_kernel_ver"/drivers/hid/hid-ids.h -o "drivers/hid/hid-ids.h" patch -p1 <"patches/0001-hidsony-gasiafix.diff" +# kernel >= 6.12 removed asm/unaligned.h; replaced by linux/unaligned.h +KVER="\${kernelver:-\$(uname -r)}" +KMAJ=\$(echo "\$KVER" | cut -d. -f1) +KMIN=\$(echo "\$KVER" | cut -d. -f2 | cut -d- -f1) +if [ "\$KMAJ" -gt 6 ] || { [ "\$KMAJ" -eq 6 ] && [ "\$KMIN" -ge 12 ]; }; then + sed -i 's|#include |#include |g' drivers/hid/hid-sony.c +fi _EOF_ chmod +x "hidsony_source.sh"