dev_alert并不总是打印出来

时间:2014-04-12 05:02:20

标签: c linux linux-kernel linux-device-driver

我正在为linux内核编写一个简单的misc设备驱动程序。我有一些打印消息来帮助调试。我尝试了dev_alertdev_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;
}

0 个答案:

没有答案