Skip to content

Commit 8e55b13

Browse files
authored
Merge pull request #19 from tectrolabs/make_compatible_with_kernel_6_9
Making alrandom driver compatible with Kernel 6.9.*
2 parents aeec1ab + 84104eb commit 8e55b13

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

linux/swrandom/swrandom.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* swrandom.c
3-
* ver. 2.5
3+
* ver. 2.6
44
*
55
*/
66

@@ -2179,8 +2179,13 @@ static bool acm_lock_device(void)
21792179
{
21802180
int op_status;
21812181
locks_init_lock(&acmCtxt->fl);
2182+
#ifndef TL_MIN_KERNEL_6_9
21822183
acmCtxt->fl.fl_flags = FL_FLOCK | FL_EXISTS;
21832184
acmCtxt->fl.fl_type = LOCK_READ | LOCK_WRITE;
2185+
#else
2186+
acmCtxt->fl.c.flc_flags = FL_FLOCK | FL_EXISTS;
2187+
acmCtxt->fl.c.flc_type = LOCK_READ | LOCK_WRITE;
2188+
#endif
21842189
op_status = locks_lock_inode_wait(acmCtxt->inode, &acmCtxt->fl);
21852190
if (op_status != 0) {
21862191
pr_info("%s: acm_lock_device(): Could not lock device %s\n", DRIVER_NAME, acmCtxt->dev_name);
@@ -2243,7 +2248,11 @@ static void acm_clean_up(void)
22432248
}
22442249

22452250
if (acmCtxt->device_locked) {
2251+
#ifndef TL_MIN_KERNEL_6_9
22462252
acmCtxt->fl.fl_type = F_UNLCK;
2253+
#else
2254+
acmCtxt->fl.c.flc_type = F_UNLCK;
2255+
#endif
22472256
op_status = locks_lock_inode_wait(acmCtxt->inode, &acmCtxt->fl);
22482257
if (op_status != 0) {
22492258
pr_err("%s: acm_clean_up(): Could not unlock %s\n", DRIVER_NAME, acmCtxt->dev_name);

linux/swrandom/swrandom.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* swrandom.h
3-
* ver. 2.5
3+
* ver. 2.6
44
*
55
*/
66

@@ -62,7 +62,7 @@
6262
#define SUCCESS 0
6363
#define DEVICE_NAME "swrandom"
6464
#define PROC_NAME "info"
65-
#define DRIVER_VERSION "2.5"
65+
#define DRIVER_VERSION "2.6"
6666
#define DRIVER_NAME "SWRNG"
6767

6868

@@ -90,6 +90,10 @@
9090
// Max amount of entropy bytes that user can request at a time.
9191
#define MAX_BYTES_USER_CAN_REQUEST (100000)
9292

93+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,00)
94+
#define TL_MIN_KERNEL_6_9
95+
#endif
96+
9397
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,01,00)
9498
#define TL_MIN_KERNEL_6_1
9599
#endif

0 commit comments

Comments
 (0)