lkmpg/examples
毛毛 470fbcd97d
Fix switch-case condition error in sample code (#245)
The code 'case -EINPROGRESS || -EBUSY: ' is the same as
'case -115 || -16 :' at compiler time, as both error code are
implemented with macro like '#define EBUSY 16'.

The code above is essentially the same as 'case 1:'. In C, there is no
real boolean value. Boolean-like value will be converted to 1 or 0.

It does not matter too much if the '-EINPROGRESS || -EBUSY' is
calculated at build time or at runtime. In both case, it will compare
the 'rc' with 1 in the switch expression. It will not compare the
'rc' with any real error code number. When the code is really '-EBUSY',
the execution will fallback to the default branch.

And in practice, most of the compilers will do this simple compile-time
static calculation, and generate code like

static int test_skcipher_result(struct skcipher_def *sk, int rc)
{
    switch (rc) {
    case 0:
        break;
    case 1:
        rc = wait_for_completion_interruptible(&sk->result.completion);
/* code removed for conciseness */
        break;
    default:
        pr_info("skcipher encrypt returned with %d result %d\n", rc,
                sk->result.err);
        break;
    }
    init_completion(&sk->result.completion);
    return rc;
}
2024-01-03 22:13:26 +08:00
..
other Fix incoherent ioctl examples (#139) 2022-02-21 00:53:29 +08:00
.clang-format Introduce Virtual Input Device Driver 2022-04-06 17:13:29 +08:00
bottomhalf.c Fix typo (#240) 2023-10-08 17:14:09 +08:00
chardev.c Remove module * parameter from class_create() (#222) 2023-09-03 02:24:35 +08:00
chardev.h Fix incoherent ioctl examples (#139) 2022-02-21 00:53:29 +08:00
chardev2.c Remove module * parameter from class_create() in chardev2.c (#228) 2023-09-17 18:23:45 +08:00
completions.c Simplify code by removal of outer struct 2023-09-28 06:02:39 +00:00
cryptosha256.c examples: Add missing __init/__exit (#209) 2023-07-05 09:44:21 +08:00
cryptosk.c Fix switch-case condition error in sample code (#245) 2024-01-03 22:13:26 +08:00
devicemodel.c examples: Add missing __init/__exit (#209) 2023-07-05 09:44:21 +08:00
example_atomic.c Add newline to last pr_info to force dmesg to flush 2023-09-28 15:32:50 +00:00
example_mutex.c examples: Add missing __init/__exit (#209) 2023-07-05 09:44:21 +08:00
example_rwlock.c examples: Add missing __init/__exit (#209) 2023-07-05 09:44:21 +08:00
example_spinlock.c examples: Add missing __init/__exit (#209) 2023-07-05 09:44:21 +08:00
example_tasklet.c examples: Add missing __init/__exit (#209) 2023-07-05 09:44:21 +08:00
hello-1.c treewide: Replace kernel.h by printk.h 2023-02-23 12:54:30 +02:00
hello-2.c treewide: Replace kernel.h by printk.h 2023-02-23 12:54:30 +02:00
hello-3.c treewide: Replace kernel.h by printk.h 2023-02-23 12:54:30 +02:00
hello-4.c treewide: Replace kernel.h by printk.h 2023-02-23 12:54:30 +02:00
hello-5.c treewide: Replace kernel.h by printk.h 2023-02-23 12:54:30 +02:00
hello-sysfs.c Enforce Linux kernel coding style (#88) 2021-09-02 15:15:07 +08:00
intrpt.c treewide: Replace kernel.h by printk.h 2023-02-23 12:54:30 +02:00
ioctl.c Correct name/location for ioctl-number.rst 2023-09-04 17:59:31 +00:00
kbleds.c kbleds: Replace magic with driver_name 2023-08-10 08:56:19 +08:00
Makefile Enforce consistent name scheme 2023-12-22 20:40:27 +08:00
print_string.c Fix typo, grammar and remove duplicated words 2022-03-07 16:56:13 +08:00
procfs1.c procfs: Enforce Linux naming style 2023-03-24 11:36:33 +08:00
procfs2.c procfs: Remove unnecessary cleanup on proc_create failure 2023-07-23 18:41:46 +08:00
procfs3.c procfs: Remove unnecessary cleanup on proc_create failure 2023-07-23 18:41:46 +08:00
procfs4.c Fix typo (#240) 2023-10-08 17:14:09 +08:00
sched.c Replace schedule_work with queue_work 2023-10-07 16:32:26 +02:00
sleep.c procfs: Remove unnecessary cleanup on proc_create failure 2023-07-23 18:41:46 +08:00
start.c Apply editorial changes 2021-08-08 01:24:59 +08:00
static_key.c static_key: Include <linux/jump_label.h> (#210) 2023-07-05 23:14:49 +08:00
stop.c Fix the warnings raised by Sparse (#92) 2021-09-04 17:53:29 +08:00
syscall-steal.c syscall-steal: Refine comment 2023-12-22 20:53:21 +08:00
vinput.c vinput: Fix missing error code 2022-11-04 01:16:14 +08:00
vinput.h Add description of sysfs attribute 2022-04-19 01:54:24 +08:00
vkbd.c Add description of sysfs attribute 2022-04-19 01:54:24 +08:00