您尚未登录。

楼主 # 2022-06-05 12:31:27

histimes
会员
注册时间: 2022-05-31
已发帖子: 31
积分: 31

printk不能输出, dev_info倒是可以,怎么回事啊?

用的是V3s 4.13的版本,已经在menuconfig中设置了Kernel debugging,Kernel low-level debugging functions
在usb_disconnect这个函数中加了几句话,如下

void usb_disconnect(struct usb_device **pdev)
{
    struct usb_port *port_dev = NULL;
    struct usb_device *udev = *pdev;
    struct usb_hub *hub = NULL;
    int port1 = 1;
    printk(KERN_NOTICE, "usb_disconnect begin\n");

    /* mark the device as inactive, so any further urb submissions for
     * this device (and any of its children) will fail immediately.
     * this quiesces everything except pending urbs.
     */
    usb_set_device_state(udev, USB_STATE_NOTATTACHED);
    dev_info(&udev->dev, "AAUSB disconnect, device number %d\n",
            udev->devnum);
    _dev_info(&udev->dev, "BBBBUSB disconnect, device number %d\n",
            udev->devnum);
    printk(KERN_INFO, "---KERN_INFO usb_disconnect begin\n");
    printk(KERN_ALERT, "--- KERN_ALERTalert usb_disconnect begin\n");
    printk(KERN_WARNING, "---KERN_WARNING usb_disconnect begin\n");
    printk(KERN_NOTICE, "---KERN_WARNING usb_disconnect begin\n");
    printk(KERN_DEBUG, "---KERN_DEBUG usb_disconnect begin\n");
.....
}

输出结果为:
[   35.141543] usb 2-1: AAUSB disconnect, device number 3
[   35.146689] usb 2-1: BBBBUSB disconnect, device number 3

就是说dev_info,_dev_info两个函数可以输出,而printk函数没有输出,这是怎么回事啊?

离线

楼主 #1 2022-06-05 13:32:09

histimes
会员
注册时间: 2022-05-31
已发帖子: 31
积分: 31

Re: printk不能输出, dev_info倒是可以,怎么回事啊?

usb_set_device_state(udev, USB_STATE_NOTATTACHED);
    dev_info(&udev->dev, "1AAUSB disconnect, device number %d\n",
            udev->devnum);
    _dev_info(&udev->dev, "2BBBBUSB disconnect, device number %d\n",
            udev->devnum);
    printk(KERN_ERR "BBBcan't register hub driver\n"),
    printk_emit(0,1,0,0, "KERN_ALERT AAAAAAAAAAAAA");
    printk_emit(0,2,0,0, "KERN_INFO AAAAAAAAAAAAA");
    printk_emit(0,3,0,0, "KERN_WARNING AAAAAAAAAAAAA");
    printk_emit(0,4,0,0, "KERN_NOTICE AAAAAAAAAAAAA");
    printk_emit(0,5,0,0, "KERN_DEBUG AAAAAAAAAAAAA");
这几个都可以输出

现在可以了,谁定义的这种语法啊,printk(KERN_ERR "BBBcan't register hub driver\n"),  KERN_ERR后面没逗号

离线

#2 2022-06-06 09:40:56

abnerl
会员
注册时间: 2020-06-09
已发帖子: 64
积分: 66.5

Re: printk不能输出, dev_info倒是可以,怎么回事啊?

确保100%输出,只能KERN_ERR无疑

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn