Skip to content

Merge changes #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed

Merge changes #3

wants to merge 6 commits into from

Conversation

kimocoder
Copy link
Owner

@kimocoder kimocoder commented May 4, 2025

Summary by Sourcery

Add backport compatibility functions and macros for Linux kernel versions before 6.13 and 6.14

Enhancements:

  • Add default value retrieval functions for netlink attributes for various data types
  • Add debugfs-related compatibility macros
  • Add export symbol namespace compatibility macro

Chores:

  • Add a Coccinelle patch for platform driver remove compatibility
  • Modify backport include headers

nbd168 added 6 commits March 19, 2025 12:09
The macro changed to take a string argument, which cannot be backported easily

Signed-off-by: Felix Fietkau <[email protected]>
Copy link

sourcery-ai bot commented May 4, 2025

Reviewer's Guide

This pull request introduces compatibility shims and backports functionality from newer Linux kernel versions (up to 6.14) by adding version-guarded helper functions and macros, adjusting symbol exports, and using a Coccinelle script to adapt driver callbacks for older kernels. Patch files were also updated.

Sequence Diagram for platform_driver_remove Call on Kernels < 6.11

sequenceDiagram
    participant PC as Platform Core
    participant PD as Platform Driver (struct)
    participant Wrap as bp_platform_driver_remove_wrap
    participant Orig as platform_driver_remove (original func)

    Note over PC, Orig: On Kernel < 6.11
    PC->>PD: Call driver.remove(dev)
    activate PD
    PD->>Wrap: dev.remove points to wrapper
    activate Wrap
    Wrap->>Orig: Call original remove function(dev)
    activate Orig
    Orig-->>Wrap: (Returns void)
    deactivate Orig
    Wrap-->>PD: Return 0
    deactivate Wrap
    PD-->>PC: Return 0
    deactivate PD
Loading

File-Level Changes

Change Details Files
Add compatibility shims for Netlink attribute getters.
  • Added various nla_get_*_default helper functions.
  • Guarded new functions with LINUX_VERSION_IS_LESS(6,13,0).
backport/backport-include/net/netlink.h
Add compatibility shims for Debugfs API.
  • Defined debugfs_short_fops for kernels < 6.13.
  • Added debugfs_change_name macro for kernels < 6.14.
backport/backport-include/linux/debugfs.h
Adjust symbol export macro for older kernels.
  • Conditionally undefined EXPORT_SYMBOL_NS_GPL for kernels < 6.13.
backport/backport-include/linux/export.h
Introduce wrapper for platform driver remove callback.
  • Added Coccinelle script to conditionally wrap the .remove callback for kernels < 6.11 to handle signature changes.
patches/0100-platform_driver_remove.cocci
Update backport patch set.
  • Removed obsolete patch files and copy-list.
  • Added new patch 0006-pcim_request_all_regions.patch.
copy-list
patches/0004-disable-wext-kconfig.patch
patches/0084-disable-some-staging-dirs.patch
patches/0006-pcim_request_all_regions.patch

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @kimocoder - I've reviewed your changes - here's some feedback:

  • Consider updating the pull request title and description to summarize the changes.
  • Consider explaining the addition and removal of patch files in the pull request description.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -385,4 +385,126 @@ MIN_LEN_VALIDATION(42)
.range = (struct netlink_range_validation *)_range, \
}

#if LINUX_VERSION_IS_LESS(6,13,0)
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider using a macro to generate the nla_get_*_default functions.

You can reduce duplication by parameterizing the common pattern with a helper macro. For example, you might introduce a macro like this:

#define NLA_GET_DEFAULT(T, suffix, getter)             \
static inline T nla_get_##suffix##_default(const struct nlattr *nla, T defvalue) { \
    return (!nla) ? defvalue : getter(nla);              \
}

Then instantiate it for all types:

NLA_GET_DEFAULT(u32, u32, nla_get_u32)
NLA_GET_DEFAULT(__be32, be32, nla_get_be32)
NLA_GET_DEFAULT(__le32, le32, nla_get_le32)
NLA_GET_DEFAULT(u16, u16, nla_get_u16)
NLA_GET_DEFAULT(__be16, be16, nla_get_be16)
NLA_GET_DEFAULT(__le16, le16, nla_get_le16)
NLA_GET_DEFAULT(u8, u8, nla_get_u8)
NLA_GET_DEFAULT(u64, u64, nla_get_u64)
NLA_GET_DEFAULT(__be64, be64, nla_get_be64)
NLA_GET_DEFAULT(__le64, le64, nla_get_le64)
NLA_GET_DEFAULT(s32, s32, nla_get_s32)
NLA_GET_DEFAULT(s16, s16, nla_get_s16)
NLA_GET_DEFAULT(s8, s8, nla_get_s8)
NLA_GET_DEFAULT(s64, s64, nla_get_s64)
NLA_GET_DEFAULT(__be32, in_addr, nla_get_in_addr)
NLA_GET_DEFAULT(unsigned long, msecs, nla_get_msecs)

This approach keeps the functionality intact while reducing redundancy and complexity in the file.

@kimocoder kimocoder closed this May 4, 2025
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.

2 participants