kernel: v4l2_fh_add/del gained file* arg in 6.18 — version-conditional

DKMS build failure on higgs (Pi CM5, kernel 6.18.29+rpt-rpi-2712):

  daedalus_v4l2_main.c:1049: error: too few arguments to function 'v4l2_fh_add'
  v4l2-fh.h:97: void v4l2_fh_add(struct v4l2_fh *fh, struct file *filp);
  daedalus_v4l2_main.c:1063: error: too few arguments to function 'v4l2_fh_del'

Signature changed exactly at v6.18 (verified v6.13–v6.17 still use the
one-arg form via raw.githubusercontent.com tag walk). Wrap the calls
with LINUX_VERSION_CODE >= KERNEL_VERSION(6, 18, 0) so the module
keeps building against:

  * 6.12 LTS / RPi 6.12.75 (one-arg)        — hertz
  * 6.12.88+deb13-arm64 (one-arg)
  * 6.18.29+rpt-rpi-2712 (file* arg)        — higgs running kernel

Build verified on both: hertz 6.12.75 clean, higgs 6.18.29 clean +
modprobe daedalus_v4l2 succeeds, /dev/daedalus-v4l2 + /dev/video0
appear.

Add #include <linux/version.h> for KERNEL_VERSION + LINUX_VERSION_CODE
(also pulled transitively via module.h but explicit is better than
implicit).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-20 10:15:24 +02:00
parent f55b2cd002
commit f0cd29a340
+14
View File
@@ -30,6 +30,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/version.h> /* LINUX_VERSION_CODE / KERNEL_VERSION */
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
@@ -1046,7 +1047,16 @@ static int daedalus_open(struct file *file)
goto err_ctrl;
}
ctx->fh.m2m_ctx = ctx->m2m_ctx;
/*
* v4l2_fh_add/del gained a `struct file *filp` second arg in
* Linux 6.18 (commit landing between v6.17 and v6.18 tags).
* Keep building against both 6.12 LTS (no filp arg) and 6.18+.
*/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 18, 0)
v4l2_fh_add(&ctx->fh, file);
#else
v4l2_fh_add(&ctx->fh);
#endif
return 0;
err_ctrl:
@@ -1060,7 +1070,11 @@ static int daedalus_release(struct file *file)
{
struct daedalus_ctx *ctx = file_to_ctx(file);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 18, 0)
v4l2_fh_del(&ctx->fh, file);
#else
v4l2_fh_del(&ctx->fh);
#endif
v4l2_m2m_ctx_release(ctx->m2m_ctx);
v4l2_ctrl_handler_free(&ctx->hdl);
v4l2_fh_exit(&ctx->fh);