我正在为linux内核编写一个简单的misc设备驱动程序。我有一些打印消息来帮助调试。我尝试了dev_alert
和dev_crit
问题在于其中一些是印刷的,有些则不是。我想知道为什么?
以下是我写函数的示例:
ssize_t misc_write(struct file *filp, const char __user *buff,
size_t count, loff_t *offp)
{
ssize_t retval;
dev_crit(my_dev.this_device, "LOG_ENTER: misc_wrrite\n");
if (count != strlen(MY_UNIQUE_ID)+1) {
dev_alert(my_dev.this_device, "misc_write: strlen not equal\n");
retval = -EINVAL;
goto out;
}
if (copy_from_user(my_buff, buff, count)) {
dev_crit(my_dev.this_device, "misc_write: couldn't copy from userspace\n");
retval = -EINVAL;
goto out;
}
if (strncmp(MY_UNIQUE_ID, my_buff, count)) {
dev_crit(my_dev.this_device, "misc_write: string not equal to my unique ID\n");
retval = -EINVAL;
} else {
dev_crit(my_dev.this_device, "The passed value is equal to my unique ID\n");
retval = count;
}
out:
dev_crit(my_dev.this_device, "LOG_EXIT: misc_wrrite\n");
return retval;
}