编辑#4:
我想通了,我不应该被分配attr_groups到groups该领域driver中的场struct platform_driver结构。寻找/* WRONGO: should not be assigned here. */下面的评论。
我还没想好我应该把它分配在哪里......
由于 NULL 引用,我的平台驱动程序代码在读取 sysfs 属性时设法导致内核“OOPS”。我确定这是以下代码中的一个简单疏忽,但我看不到它:
...
static int samples_per_frame = SAMPLE_CHANNEL_COUNT;
DEVICE_INT_ATTR(samples_per_frame, S_IRUGO | S_IWUSR, samples_per_frame);
static struct attribute *attrs[] = {
&dev_attr_samples_per_frame.attr.attr, NULL,
};
static struct attribute_group attr_group = {
.attrs = attrs,
};
static const struct attribute_group *attr_groups[] = {
&attr_group, NULL,
};
static struct platform_driver platform = {
.remove = my_remove,
.probe = my_probe, …Run Code Online (Sandbox Code Playgroud)