Add Linux kernel 6.8.x compatibility support - #72
Conversation
This commit backports the driver to work with Linux kernel 6.8.x, enabling support for Ubuntu 22.04 LTS and other distributions using older kernel versions. Changes made: - Replace linux/unaligned.h with asm/unaligned.h (kernel 6.8 compat) - Replace BACKLIGHT_POWER_ON with FB_BLANK_UNBLANK - Update platform_profile API from ops to handler structure - Add wrapper functions for platform_profile_handler callbacks - Update platform_profile_register() call signature - Remove device parameter from platform_profile_notify() - Update wmi_notify handler to use u32 value parameter - Add wmi_get_event_data() call for event handling - Add proper memory cleanup with kfree() for event data - Add compatibility wrapper for platform driver remove callback Tested on: - Kernel: 6.8.0-90-generic - Distribution: Ubuntu 22.04 LTS - Hardware: Acer Nitro AN515-45 The driver compiles successfully and loads without errors on kernel 6.8.x while maintaining compatibility with the existing codebase structure.
There was a problem hiding this comment.
Pull request overview
This PR adds backward compatibility for Linux kernel 6.8.x to enable the driver to work on older LTS distributions like Ubuntu 22.04, while maintaining compatibility with kernel 6.12+.
Key Changes:
- Updated API calls to use kernel 6.8-compatible equivalents (header includes, backlight API, platform profile handler, WMI notify handler)
- Added wrapper functions and compatibility shims for API differences between kernel versions
- Added memory management with
kfree()for WMI event data cleanup
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!obj) | ||
| return; |
There was a problem hiding this comment.
Memory leak: when obj is NULL after wmi_get_event_data succeeds, the response.pointer memory allocated by ACPI_ALLOCATE_BUFFER is not freed. The function returns early without calling kfree(obj), but the ACPI buffer may still contain allocated memory that needs to be freed.
| if (!obj) | |
| return; | |
| if (!obj) { | |
| kfree(response.pointer); | |
| return; | |
| } |
| return; | ||
| } | ||
|
|
||
| return_value = *((struct event_return_value *)obj->buffer.pointer); switch (return_value.function) { |
There was a problem hiding this comment.
Formatting issue: the switch statement should be on a new line. This line combines two statements on one line which affects code readability and does not follow standard C formatting conventions.
| return_value = *((struct event_return_value *)obj->buffer.pointer); switch (return_value.function) { | |
| return_value = *((struct event_return_value *)obj->buffer.pointer); | |
| switch (return_value.function) { |
| if (!quirks->predator_v4 && !quirks->nitro_sense && !quirks->nitro_v4) | ||
| return 0; | ||
| for (int attempt = 1; attempt <= max_retries; attempt++) { | ||
| err = platform_profile_register(&acer_predator_v4_platform_profile_handler); |
There was a problem hiding this comment.
Missing platform profile cleanup: the platform_profile_handler is registered but there's no corresponding unregistration in acer_platform_remove. This could lead to a dangling handler reference when the module is removed. A platform_profile_remove or platform_profile_unregister call should be added in the cleanup path.
Summary
This PR adds backward compatibility for Linux kernel 6.8.x, enabling the driver to work on Ubuntu 22.04 LTS and other distributions using older kernel versions.
Motivation
Currently, the driver only compiles on kernel 6.12+. Many users are still on LTS distributions like Ubuntu 22.04 (kernel 6.8) and cannot use this driver without upgrading their entire system.
Changes Made
linux/unaligned.htoasm/unaligned.hfor kernel 6.8BACKLIGHT_POWER_ONtoFB_BLANK_UNBLANKplatform_profile_opstoplatform_profile_handlerstructurewmi_get_event_data()supportkfree()for allocated event dataTesting
Compatibility
Notes