我编写了一个小内核模块,用作Raspberry Pi的驱动程序软件,以及使用kobject / sysfs接口创建可以从用户空间操作的目录结构。到目前为止,我已经成功地在/ sys / gpio_driver中创建了一个文件夹,其中包含一个名为gpio_pin的文件(kobject属性)。数字写入“文件”,表示应该使用哪个gpio引脚。然后使用该数字创建另一个kobject,以表示ACTUAL gpio引脚的值。
代码:
#include <linux/init.h> // Macros used to mark up functions e.g. __init __exit
#include <linux/module.h> // Core header for loading LKMs into the kernel
#include <linux/device.h> // Header to support the kernel Driver Model
#include <linux/kernel.h> // Contains types, macros, functions for the kernel
#include <linux/fs.h> // Header for the Linux file system support
#include <linux/uaccess.h> // Required for the copy to user function
#include <asm/io.h>
#define DEVICE_NAME "gpio_driver" //device appear as /dev/gpio_driver
#define CLASS_NAME "gpio_custom" ///< The device class -- this is a character device driver
#define GPIO_BASE 0x3f200000
#undef VERIFY_OCTAL_PERMISSIONS
#define VERIFY_OCTAL_PERMISSIONS(_mode) (_mode)
MODULE_LICENSE("GPL");
static const char name[5] = "gpio\0";
static const char name_pinval[6] = "value\0";
static char pin_pre[20] = "gpio"; //2 additional bytes for gpio num, 1 for nullbyte
static int gpio_pin; //number indicating current activated gpio pin
static int gpio_mode; //0 or 1 indicating input or output
static int gpio_value; //current value gpio pin
static int retval; //sysfs_create_group return val
static struct kobject *gpio_kobj;
static struct kobject *value_kobj = NULL;
static ssize_t write_val(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count){
sscanf(buf, "%d", &gpio_value);
return strnlen(buf, sizeof(buf));
}
static ssize_t show_val(struct kobject *kobj, struct kobj_attribute *attr, char *buf){
return snprintf(buf, sizeof(buf), "%d\n", gpio_value);
}
//problematic function, called when /sys/gpio_driver/gpio_pin gets set
//a value
static ssize_t scan_pin(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count){
sscanf(buf, "%d", &gpio_pin);
printk(KERN_INFO "gpio_pin set to: %d, registering new kobject...\n", gpio_pin);
gpio_value = 0;
if(value_kobj == NULL){
printk(KERN_INFO "deallocating prev kobject instance ..\n");
kobject_put(value_kobj);
}
static struct kobj_attribute pin_values = __ATTR(gpio_value, 0600, show_val, write_val);
static struct attribute *pin_value_attrs[] = {
&pin_values.attr,
NULL,
};
static struct attribute_group value_group = {
.attrs = pin_value_attrs,
.name = name_pinval,
};
snprintf(&pin_pre[4], sizeof(gpio_pin), "%d", gpio_pin);
printk(KERN_ALERT "exposing folder %s .. \n", pin_pre);
value_kobj = kobject_create_and_add(pin_pre, gpio_kobj);
if(!value_kobj){
printk(KERN_ALERT "value kobj not initialized!\n");
return -1;
}
retval = sysfs_create_group(value_kobj, &value_group);
if(!retval){
printk(KERN_ALERT "group registration failed\n");
kobject_put(value_kobj);
return retval;
}
return strnlen(buf, sizeof(buf));
}
static ssize_t read_pin(struct kobject *kobj, struct kobj_attribute *attr, char *buf){
return snprintf(buf, sizeof(buf), "%d\n", gpio_pin);
}
//register kobject attribute using __ATTR macro
//name and access mode
//registers read(show) and set(write) callbacks
static struct kobj_attribute pin_attr = __ATTR(gpio_pin, 0600, read_pin, scan_pin);
//initialize list of attributes used to create attribute group
static struct attribute *gpio_attrs[] = {
&pin_attr.attr,
NULL,
};
static struct attribute_group attr_group = {
//.name = name, leaving name unitialized will not create another directory after /sys/gpio_driver
.attrs = gpio_attrs,
};
static int __init init_driver(void){
gpio_kobj = kobject_create_and_add("gpio_driver", kernel_kobj->parent);
if(!gpio_kobj){
printk(KERN_ALERT "Kobject creation failed\n");
return -1;
}
retval = sysfs_create_group(gpio_kobj, &attr_group);
if(retval){
printk(KERN_ALERT "Kobject group creation failed\n");
kobject_put(gpio_kobj);
return retval;
}
gpio_pin = 69;
printk(KERN_ALERT "Initialization finished, gpio_pin: %d\n", gpio_pin);
return 0;
}
static void __exit driver_exit(void){
printk(KERN_INFO "Current GPIO pin is %d\n", gpio_pin);
kobject_put(gpio_kobj);
printk(KERN_INFO "Freed!\n");
}
module_init(init_driver);
module_exit(driver_exit);
模块可以很好地插入,当我尝试将值回显到/ sys / gpio_driver / gpio_pin时,终端会冻结。检查dmesg有以下消息:
[ 1577.851651] gpio_pin set to: 2, registering new kobject...
[ 1577.851654] exposing folder gpio2 ..
[ 1577.855368] group registration failed
[ 1577.859098] gpio_pin set to: 2, registering new kobject...
[ 1577.859106] exposing folder gpio2 ..
[ 1577.862825] group registration failed
[ 1577.866539] gpio_pin set to: 2, registering new kobject...
[ 1577.866542] exposing folder gpio2 ..
[ 1577.870273] group registration failed
[ 1577.873991] gpio_pin set to: 2, registering new kobject...
[ 1577.873994] exposing folder gpio2 ..
[ 1577.877725] group registration failed
[ 1577.881441] gpio_pin set to: 2, registering new kobject...
[ 1577.881444] exposing folder gpio2 ..
[ 1577.885160] group registration failed
[ 1577.888891] gpio_pin set to: 2, registering new kobject...
[ 1577.888897] exposing folder gpio2 ..
[ 1577.892616] group registration failed
[ 1577.896331] gpio_pin set to: 2, registering new kobject...
[ 1577.896334] exposing folder gpio2 ..
[ 1577.900074] group registration failed
[ 1577.903792] gpio_pin set to: 2, registering new kobject...
[ 1577.903795] exposing folder gpio2 ..
[ 1577.907526] group registration failed
[ 1577.911244] gpio_pin set to: 2, registering new kobject...
[ 1577.911247] exposing folder gpio2 ..
[ 1577.914961] group registration failed
[ 1577.918692] gpio_pin set to: 2, registering new kobject...
[ 1577.918698] exposing folder gpio2 ..
[ 1577.922418] group registration failed
[ 1577.926132] gpio_pin set to: 2, registering new kobject...
[ 1577.926135] exposing folder gpio2 ..
[ 1577.929865] group registration failed
[ 1577.933585] gpio_pin set to: 2, registering new kobject...
[ 1577.933587] exposing folder gpio2 ..
[ 1577.937317] group registration failed
[ 1577.941034] gpio_pin set to: 2, registering new kobject...
[ 1577.941037] exposing folder gpio2 ..
[ 1577.944754] group registration failed
[ 1577.948486] gpio_pin set to: 2, registering new kobject...
[ 1577.948493] exposing folder gpio2 ..
[ 1577.952210] group registration failed
[ 1577.955925] gpio_pin set to: 2, registering new kobject...
[ 1577.955927] exposing folder gpio2 ..
[ 1577.959658] group registration failed
当我尝试删除模块时,我收到了来自内核的各种错误消息。
[ 1791.585926] Internal error: Oops: 5 [#13] SMP ARM
[ 1791.590692] Modules linked in: ebbchar_sys(O+) fuse rfcomm cmac bnep hci_uart btbcm serdev bluetooth ecdh_generic brcmfmac brcmutil cfg80211 rfkill snd_bcm2835(C) snd_pcm snd_timer snd fixed uio_pdrv_genirq uio i2c_dev ip_tables x_tables ipv6 [last unloaded: ebbchar_sys]
[ 1791.615084] CPU: 2 PID: 334 Comm: rs:main Q:Reg Tainted: G D WC O 4.14.34-v7+ #1110
[ 1791.623549] Hardware name: BCM2835
[ 1791.626992] task: b9fc9e00 task.stack: b600a000
[ 1791.631588] PC is at kmem_cache_alloc_trace+0x84/0x23c
[ 1791.636794] LR is at 0xb600bd08
[ 1791.639972] pc : [<80276b84>] lr : [<b600bd08>] psr: 20000013
[ 1791.646324] sp : b600bd08 ip : b600bd08 fp : b600bd4c
[ 1791.651618] r10: 00000000 r9 : b9c01e40 r8 : 00000010
[ 1791.656912] r7 : 80505f30 r6 : 014000c0 r5 : b9c01e40 r4 : 65746f6e
[ 1791.663528] r3 : 00000000 r2 : 80b91760 r1 : 397e6000 r0 : 00000000
[ 1791.670146] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 1791.677379] Control: 10c5383d Table: 375d006a DAC: 00000055
[ 1791.683202] Process rs:main Q:Reg (pid: 334, stack limit = 0xb600a210)
[ 1791.689818] Stack: (0xb600bd08 to 0xb600c000)
[ 1791.694233] bd00: 80160404 8079f9b4 00000001 00010291 00000000 b600bd64
[ 1791.702526] bd20: 00000003 af649d80 80d11538 00400007 80837aa8 b9ee4510 00020901 00000000
[ 1791.710820] bd40: b600bd64 b600bd50 80505f30 80276b0c 00000002 af649d80 b600bda4 b600bd68
[ 1791.719114] bd60: 80506928 80505f08 8021d1c0 b600bea8 00000000 00000003 b600bea8 80837b20
[ 1791.727407] bd80: 80d11538 b9ec5780 b9ee4510 af649d80 00000000 00000000 b600bdd4 b600bda8
[ 1791.735702] bda0: 8028f090 805068f8 af649d88 00000000 af649d80 b9ee4510 af649d88 8028efb0
[ 1791.743995] bdc0: 00000000 b600bf5c b600bdfc b600bdd8 8028676c 8028efbc af649d80 b600bea8
[ 1791.752288] bde0: b97a5100 b9ee4510 00000000 b600bf5c b600be1c b600be00 80287a18 80286578
[ 1791.760580] be00: b9fc9e00 b600bea8 00000000 00020901 b600bea4 b600be20 80298fa8 802879c8
[ 1791.768874] be20: 802defdc 802dee74 80b8ceb4 00000000 b600bea4 b600be40 802e02e4 b600a000
[ 1791.777167] be40: b7442510 80c24008 00000041 af649d80 00000000 00000002 00000000 00000002
[ 1791.785462] be60: b9ee4510 b966a410 b9823bb0 b9e77088 b600be70 ba3715c0 20000093 0000000e
[ 1791.793755] be80: b600bf5c b600bea8 00000001 80108204 b600a000 00000000 b600bf4c b600bea8
[ 1791.802049] bea0: 8029af88 80298cec b966a410 b9823bb0 7410862b 00000004 b63e1015 80276eb8
[ 1791.810343] bec0: 00000000 b9813990 b9ee4510 00000101 00000002 000004be 00000000 00000000
[ 1791.818636] bee0: 00000000 b600bee8 ffffff9c 0000000e b758eb00 b757d700 00000000 00000400
[ 1791.826930] bf00: b600bf3c b600bf10 802aa90c 802aa080 00020901 00020901 b63e1000 00000000
[ 1791.835224] bf20: 00000005 00000002 ffffff9c 00000000 0000000e ffffff9c b63e1000 00000005
[ 1791.843518] bf40: b600bf94 b600bf50 80287df4 8029af24 b600a000 00000000 b600bfa4 00020901
[ 1791.851811] bf60: 80120000 00000002 00000100 00000001 00000901 760fe5dc 000a6970 00000005
[ 1791.860104] bf80: 80108204 b600a000 b600bfa4 b600bf98 80287ed0 80287ce0 00000000 b600bfa8
[ 1791.868398] bfa0: 80108060 80287eb0 00000901 760fe5dc 760fe5dc 00020901 00000000 00000000
[ 1791.876691] bfc0: 00000901 760fe5dc 000a6970 00000005 0008639c 000863a4 00000901 00ce38f8
[ 1791.884985] bfe0: 760fe3ac 760fe3b8 00000000 76f41ea4 80000010 760fe5dc 00000000 00000000
[ 1791.893287] [<80276b84>] (kmem_cache_alloc_trace) from [<80505f30>] (tty_alloc_file+0x34/0x48)
[ 1791.902027] [<80505f30>] (tty_alloc_file) from [<80506928>] (tty_open+0x3c/0x39c)
[ 1791.909617] [<80506928>] (tty_open) from [<8028f090>] (chrdev_open+0xe0/0x1a0)
[ 1791.916944] [<8028f090>] (chrdev_open) from [<8028676c>] (do_dentry_open+0x200/0x328)
[ 1791.924887] [<8028676c>] (do_dentry_open) from [<80287a18>] (vfs_open+0x5c/0x8c)
[ 1791.932391] [<80287a18>] (vfs_open) from [<80298fa8>] (path_openat+0x2c8/0xff8)
[ 1791.939807] [<80298fa8>] (path_openat) from [<8029af88>] (do_filp_open+0x70/0xd4)
[ 1791.947399] [<8029af88>] (do_filp_open) from [<80287df4>] (do_sys_open+0x120/0x1d0)
[ 1791.955164] [<80287df4>] (do_sys_open) from [<80287ed0>] (SyS_open+0x2c/0x30)
[ 1791.962403] [<80287ed0>] (SyS_open) from [<80108060>] (ret_fast_syscall+0x0/0x28)
[ 1791.969992] Code: e7914002 e3540000 0a00005b e5953014 (e7943003)
[ 1791.976204] ---[ end trace 5d8598b342524c19 ]---
[ 1796.920847] Unable to handle kernel paging request at virtual address 65746f6e
[ 1796.928199] pgd = 80004000
[ 1796.930937] [65746f6e] *pgd=00000000
[ 1796.934563] Internal error: Oops: 5 [#14] SMP ARM
[ 1796.939329] Modules linked in: ebbchar_sys(O+) fuse rfcomm cmac bnep hci_uart btbcm serdev bluetooth ecdh_generic brcmfmac brcmutil cfg80211 rfkill snd_bcm2835(C) snd_pcm snd_timer snd fixed uio_pdrv_genirq uio i2c_dev ip_tables x_tables ipv6 [last unloaded: ebbchar_sys]
[ 1796.963721] CPU: 2 PID: 1295 Comm: kworker/u8:2 Tainted: G D WC O 4.14.34-v7+ #1110
[ 1796.972187] Hardware name: BCM2835
[ 1796.975630] task: af4de900 task.stack: b63a4000
[ 1796.980226] PC is at __kmalloc+0x9c/0x278
[ 1796.984287] LR is at __kmalloc+0x1dc/0x278
[ 1796.988435] pc : [<80276924>] lr : [<80276a64>] psr: 20000113
[ 1796.994787] sp : b63a5e28 ip : b63a5e28 fp : b63a5e6c
[ 1797.000080] r10: b9c01e40 r9 : 802e485c r8 : 014000c0
[ 1797.005375] r7 : 00000019 r6 : b63a5e70 r5 : b9c01e40 r4 : 65746f6e
[ 1797.011990] r3 : 00000000 r2 : 80b91760 r1 : 397e6000 r0 : b63a5e28
[ 1797.018608] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 1797.025841] Control: 10c5383d Table: 375d006a DAC: 00000055
[ 1797.031663] Process kworker/u8:2 (pid: 1295, stack limit = 0xb63a4210)
[ 1797.038280] Stack: (0xb63a5e28 to 0xb63a6000)
[ 1797.042696] 5e20: 8028a8b4 8028a728 b63a5e48 00010291 b63a5e6c b63a5e48
[ 1797.050989] 5e40: 802e318c af439e80 af4ba900 b63a5e70 b8a82600 00000000 b8a82640 00000001
[ 1797.059281] 5e60: b63a5efc b63a5e70 802e485c 80276894 00002017 b63a5efc 00000000 00000000
[ 1797.067575] 5e80: af56b1b8 00000000 af4de900 af56b180 7effffb8 b63a4000 b63a5efc abd83f91
[ 1797.075869] 5ea0: 0000000f 00000000 b63a4000 802903a0 b63a5f2c 8029670c 0000000d b9bea9f0
[ 1797.084162] 5ec0: 00000004 af4ba900 00000000 af4ba900 b63a5ef4 80c24c80 af4ba900 80d11540
[ 1797.092455] 5ee0: 80d11540 fffffff8 80c21d24 00000001 b63a5f2c b63a5f00 802911a4 802e4650
[ 1797.100748] 5f00: 80c0d4c0 af4de900 b63e2000 af4ba900 00000000 af56b180 0000050f 80c0db80
[ 1797.109042] 5f20: b63a5f74 b63a5f30 802923c8 80291100 b63a5f4c b63a5f40 af56b1b8 0000050f
[ 1797.117335] 5f40: b63a5f5c 00000000 80c0459c af749c00 b74bff00 80c97d00 00000000 00000000
[ 1797.125628] 5f60: 00000000 00000000 b63a5f8c b63a5f78 80292640 80291f7c 00000000 00000000
[ 1797.133921] 5f80: b63a5fac b63a5f90 80133610 80292614 80102d94 b74bff00 801334a8 00000000
[ 1797.142215] 5fa0: 00000000 b63a5fb0 8010810c 801334b4 00000000 00000000 00000000 00000000
[ 1797.150507] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 1797.158799] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
[ 1797.167108] [<80276924>] (__kmalloc) from [<802e485c>] (load_elf_binary+0x218/0x1100)
[ 1797.175055] [<802e485c>] (load_elf_binary) from [<802911a4>] (search_binary_handler+0xb0/0x24c)
[ 1797.183881] [<802911a4>] (search_binary_handler) from [<802923c8>] (do_execveat_common+0x458/0x698)
[ 1797.193058] [<802923c8>] (do_execveat_common) from [<80292640>] (do_execve+0x38/0x40)
[ 1797.201002] [<80292640>] (do_execve) from [<80133610>] (call_usermodehelper_exec_async+0x168/0x1c0)
[ 1797.210181] [<80133610>] (call_usermodehelper_exec_async) from [<8010810c>] (ret_from_fork+0x14/0x28)
[ 1797.219535] Code: e7914002 e3540000 0a000066 e5953014 (e7943003)
[ 1797.225752] ---[ end trace 5d8598b342524c1a ]---
[ 1797.237585] Unable to handle kernel paging request at virtual address 65746f6e
[ 1797.244916] pgd = af7a4000
[ 1797.247683] [65746f6e] *pgd=00000000
[ 1797.251309] Internal error: Oops: 5 [#15] SMP ARM
[ 1797.256074] Modules linked in: ebbchar_sys(O+) fuse rfcomm cmac bnep hci_uart btbcm serdev bluetooth ecdh_generic brcmfmac brcmutil cfg80211 rfkill snd_bcm2835(C) snd_pcm snd_timer snd fixed uio_pdrv_genirq uio i2c_dev ip_tables x_tables ipv6 [last unloaded: ebbchar_sys]
[ 1797.280466] CPU: 2 PID: 1298 Comm: sudo Tainted: G D WC O 4.14.34-v7+ #1110
[ 1797.288227] Hardware name: BCM2835
[ 1797.291671] task: b88b0f00 task.stack: b74a2000
[ 1797.296267] PC is at kmem_cache_alloc_trace+0x84/0x23c
[ 1797.301473] LR is at 0xb74a3d68
[ 1797.304651] pc : [<80276b84>] lr : [<b74a3d68>] psr: 20000013
[ 1797.311003] sp : b74a3d68 ip : b74a3db0 fp : b74a3dac
[ 1797.316297] r10: 00000000 r9 : b9c01e40 r8 : 0000000c
[ 1797.321591] r7 : 80300ec0 r6 : 01080020 r5 : b9c01e40 r4 : 65746f6e
[ 1797.328208] r3 : 00000000 r2 : 80b91760 r1 : 397e6000 r0 : b9c01e40
[ 1797.334825] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 1797.342058] Control: 10c5383d Table: 2f7a406a DAC: 00000055
[ 1797.347881] Process sudo (pid: 1298, stack limit = 0xb74a2210)
[ 1797.353792] Stack: (0xb74a3d68 to 0xb74a4000)
[ 1797.358207] 3d60: 802a70a8 80187a90 5b1b627e 00010291 0be8042d 00000002
[ 1797.366500] 3d80: b98281c0 00000000 b74a3ef0 00000512 b74a3ea8 b9804220 b98281c0 00000000
[ 1797.374793] 3da0: b74a3dcc b74a3db0 80300ec0 80276b0c 80300df8 b74a3ef0 61c88647 b63e001b
[ 1797.383085] 3dc0: b74a3e1c b74a3dd0 80298760 80300e04 00000000 80300df8 00000000 00000004
[ 1797.391379] 3de0: b74a3ea8 b63e0010 b74a3e1c b74a3df8 80294eb4 b74a3ea8 b63e0010 b74a3ea8
[ 1797.399673] 3e00: 00000003 80108204 b74a3f5c 00000000 b74a3ea4 b74a3e20 80298d68 80298330
[ 1797.407965] 3e20: 80259348 8021dd6c 00000000 807a05fc b74a3e94 b74a3e40 807a05fc b74a2000
[ 1797.416258] 3e40: b62d4240 00000054 00000043 af649b40 76e70000 af7a5db8 00000000 00000000
[ 1797.424551] 3e60: 00000000 00000000 00000000 00000000 baa4e644 00000000 b74a3ea4 00000004
[ 1797.432844] 3e80: b74a3f5c b74a3ea8 00000003 80108204 b74a2000 00000000 b74a3f4c b74a3ea8
[ 1797.441137] 3ea0: 8029af88 80298cec b966a610 b9804198 6bafe300 00000004 b63e0016 80276eb8
[ 1797.449431] 3ec0: b966a110 b9813990 b9828028 00000053 00000002 000004be 00000004 00000001
[ 1797.457724] 3ee0: 00000001 b74a3ee8 b966a610 b9804220 00000000 b6297d18 00000000 00000002
[ 1797.466018] 3f00: b74a3f3c b74a3f10 802aa90c 802aa080 000a4800 000a4800 b63e0000 00000000
[ 1797.474311] 3f20: b98281c0 00000002 ffffff9c 00000000 00000004 ffffff9c b63e0000 00000005
[ 1797.482605] 3f40: b74a3f94 b74a3f50 80287df4 8029af24 80286a40 8028bc7c 00000006 00024800
[ 1797.490898] 3f60: b6290000 00000004 00000100 00000003 00000004 00bea7f0 00000003 00000005
[ 1797.499190] 3f80: 80108204 b74a2000 b74a3fa4 b74a3f98 80287ed0 80287ce0 00000000 b74a3fa8
[ 1797.507484] 3fa0: 80108060 80287eb0 00000004 00bea7f0 76e70040 000a4800 000001d0 0000002f
[ 1797.515777] 3fc0: 00000004 00bea7f0 00000003 00000005 0000008d 00000368 76f58ce8 004ca774
[ 1797.524070] 3fe0: 76e80ecc 7ee70dc8 76e69570 76da2a64 20000010 76e70040 aaaaaaaa aaaaaaaa
[ 1797.532373] [<80276b84>] (kmem_cache_alloc_trace) from [<80300ec0>] (proc_self_get_link+0xc8/0xd8)
[ 1797.541464] [<80300ec0>] (proc_self_get_link) from [<80298760>] (link_path_walk+0x43c/0x4a4)
[ 1797.550026] [<80298760>] (link_path_walk) from [<80298d68>] (path_openat+0x88/0xff8)
[ 1797.557881] [<80298d68>] (path_openat) from [<8029af88>] (do_filp_open+0x70/0xd4)
[ 1797.565473] [<8029af88>] (do_filp_open) from [<80287df4>] (do_sys_open+0x120/0x1d0)
[ 1797.573239] [<80287df4>] (do_sys_open) from [<80287ed0>] (SyS_open+0x2c/0x30)
[ 1797.580478] [<80287ed0>] (SyS_open) from [<80108060>] (ret_fast_syscall+0x0/0x28)
[ 1797.588068] Code: e7914002 e3540000 0a00005b e5953014 (e7943003)
[ 1797.594273] ---[ end trace 5d8598b342524c1b ]---
出于某种原因,scan_pin似乎是连续执行,而不是在一次调用后终止。 scan_pin回调肯定是这里的罪魁祸首,但我不确定为什么。
这是用于构建的Makefile,应该构建在大多数Linux上,因为我没有为这段代码实际映射任何真正的IO:
obj-m+=ebbchar_sys.o
all:
make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean
警告:我的系统在遇到错误后完全搞砸了,虽然重新启动后它很好。运行风险自负