Skip to content

Commit

Permalink
Amend use of class_create() for kernels >= 6.4
Browse files Browse the repository at this point in the history
The function signature for `class_create()` was changed in kernels >= 6.4.x to only accept a single argument (see kernel commit #dcfbb67).

This change will conditionally modify how `class_create()` is called depending on the kernel version.
  • Loading branch information
chrBrd authored and mbrooksx committed Aug 15, 2023
1 parent 97aeba5 commit 8aca235
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/gasket_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/platform_device.h>
#include <linux/printk.h>
#include <linux/sched.h>
#include <linux/version.h>

#ifdef GASKET_KERNEL_TRACE_SUPPORT
#define CREATE_TRACE_POINTS
Expand Down Expand Up @@ -1837,8 +1838,15 @@ int gasket_register_device(const struct gasket_driver_desc *driver_desc)
internal = &g_descs[desc_idx];
mutex_init(&internal->mutex);
memset(internal->devs, 0, sizeof(struct gasket_dev *) * GASKET_DEV_MAX);
internal->class =
class_create(driver_desc->module, driver_desc->name);

/* Function signature for `class_create()` is changed in kernel >= 6.4.x
* to only accept a single argument.
* */
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
internal->class = class_create(driver_desc->module, driver_desc->name);
#else
internal->class = class_create(driver_desc->name);
#endif

if (IS_ERR(internal->class)) {
pr_err("Cannot register %s class [ret=%ld]\n",
Expand Down

0 comments on commit 8aca235

Please sign in to comment.