Skip to content

fix(ccs): handle 1-param pm_runtime_get_if_active (issue #92) - #96

Open
Till0196 wants to merge 1 commit into
tbsdtv:latestfrom
Till0196:fix/ccs-pm-runtime
Open

fix(ccs): handle 1-param pm_runtime_get_if_active (issue #92)#96
Till0196 wants to merge 1 commit into
tbsdtv:latestfrom
Till0196:fix/ccs-pm-runtime

Conversation

@Till0196

@Till0196 Till0196 commented Apr 6, 2026

Copy link
Copy Markdown

fix(ccs): handle 1-param pm_runtime_get_if_active (issue #92)

Fixes #92

Problem

v6.8-ccs.patch changes pm_runtime_get_if_active() to its 2-param form for
kernels ≤ 6.8. This is correct for mainline kernels 5.6–6.8, which introduced
the bool ign_usage_count parameter.

However, some distributions backport the simplified 1-param form from
kernel 6.9+ to their 6.8 kernel (e.g. Ubuntu 6.8). On those kernels the patched
2-param call fails to compile:

error: too many arguments to function 'pm_runtime_get_if_active'

Fix

Detect which variant the kernel exposes by matching the prototype pattern
pm_runtime_get_if_active[^)]*bool in include/linux/pm_runtime.h via
make_config_compat.pl. This matches on the presence of a bool second
parameter rather than a specific parameter name, making the check robust
across vendor/backport trees that may rename the parameter:

/* mainline 5.6–6.8: pattern matches → no wrapper needed */
extern int pm_runtime_get_if_active(struct device *dev, bool ign_usage_count);

/* 6.9+ and distros that backport the simplification: no match → wrapper needed */
extern int pm_runtime_get_if_active(struct device *dev);

When the pattern is absent (1-param kernel), NEED_PM_RUNTIME_GET_IF_ACTIVE_WRAPPER
is defined and compat.h provides a variadic macro that drops the second argument:

#ifdef NEED_PM_RUNTIME_GET_IF_ACTIVE_WRAPPER
#define pm_runtime_get_if_active(dev, ...) (pm_runtime_get_if_active)(dev)
#endif

The (pm_runtime_get_if_active) notation prevents recursive macro expansion.
A macro is used instead of a static inline wrapper because compat.h is
force-included before kernel headers, so the function is not yet declared at
that point.

v6.8-ccs.patch and v5.6_pm_runtime_get_if_active.patch are left unchanged.

Testing

Verified that the build completes without errors on Ubuntu 6.8.0-107-generic,
which ships the 1-param variant of pm_runtime_get_if_active.

Copilot AI review requested due to automatic review settings April 6, 2026 05:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes build failures on kernels where pm_runtime_get_if_active() has been backported to the newer 1-parameter form (e.g., Ubuntu 6.8), while existing backport patches expect the older 2-parameter form.

Changes:

  • Extend make_config_compat.pl to detect whether the kernel headers expose the 2-parameter pm_runtime_get_if_active() variant.
  • Add a conditional compat macro in v4l/compat.h to drop the second argument when only the 1-parameter API exists.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
v4l/scripts/make_config_compat.pl Adds header scanning to decide whether a compat wrapper is needed for pm_runtime_get_if_active().
v4l/compat.h Provides a conditional macro wrapper to make 2-arg call sites compile against 1-arg kernels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread v4l/scripts/make_config_compat.pl Outdated
…kport kernel 6.9 API (issue tbsdtv#92)

v6.8-ccs.patch correctly adds the 2-param form for mainline kernels <= 6.8,
but some distributions (e.g. Ubuntu 6.8) backport the simplified 1-param
pm_runtime_get_if_active() from 6.9+, causing a "too many arguments" error.

Detect the 2-param variant by matching the prototype pattern
"pm_runtime_get_if_active[^)]*bool" in the kernel's pm_runtime.h via
make_config_compat.pl.  This matches on the presence of a bool second
parameter rather than a specific parameter name, making the check robust
across vendor/backport trees that may rename the parameter.

When the pattern is absent (1-param kernel), NEED_PM_RUNTIME_GET_IF_ACTIVE_WRAPPER
is defined and compat.h provides a variadic macro that drops the second
argument.  The (pm_runtime_get_if_active) notation prevents recursive macro
expansion and avoids forward-declaration issues since compat.h is
force-included before kernel headers.

Existing patches (v6.8-ccs.patch, v5.6_pm_runtime_get_if_active.patch) and
their stacking order are left unchanged.
@Till0196
Till0196 force-pushed the fix/ccs-pm-runtime branch from 92382ed to eb535f5 Compare April 6, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure with v6.8-ccs.patch

2 participants