|
11 | 11 | * From: Ch 12 : Kernel Synchronization - Part 1
|
12 | 12 | ****************************************************************
|
13 | 13 | * Brief Description:
|
14 |
| - * This driver is built upon our previous ch12/miscdrv_rdwr/ misc driver. |
| 14 | + * This driver is built upon the LKP Part 2 book's first chapter 'misc' driver here: |
| 15 | + * https://github.com/PacktPublishing/Linux-Kernel-Programming-Part-2/tree/main/ch1/miscdrv_rdwr |
| 16 | + * |
15 | 17 | * The really important and key difference: previously, we used a few global data
|
16 | 18 | * items throughout *without* protection; this time, we fix this egregious error
|
17 | 19 | * by using a mutex lock to protect the critical sections - the places in the
|
18 | 20 | * code where we access global / shared writeable data.
|
19 | 21 | * The functionality (the get and set of the 'secret') remains identical to the
|
20 | 22 | * original implementation.
|
21 | 23 | *
|
22 |
| - * For details, please refer the book, Ch 12. |
| 24 | + * Note: also do |
| 25 | + * make rdwr_test_secret |
| 26 | + * to build the user space app for testing... |
| 27 | + * |
| 28 | + * For details, please refer both the books, Ch 12 and Ch 1 resp. |
23 | 29 | */
|
24 | 30 | #define pr_fmt(fmt) "%s:%s(): " fmt, KBUILD_MODNAME, __func__
|
25 | 31 |
|
@@ -286,7 +292,7 @@ static int __init miscdrv_init_mutexlock(void)
|
286 | 292 | * freeing the memory automatically upon driver 'detach' or when the driver
|
287 | 293 | * is unloaded from memory
|
288 | 294 | */
|
289 |
| - ctx = kzalloc(sizeof(struct drv_ctx), GFP_KERNEL); |
| 295 | + ctx = devm_kzalloc(llkd_miscdev.this_device, sizeof(struct drv_ctx), GFP_KERNEL); |
290 | 296 | if (unlikely(!ctx))
|
291 | 297 | return -ENOMEM;
|
292 | 298 |
|
|
0 commit comments