Re: Problems with printk logs and my driver

From: Alan Stern
Date: Wed Sep 23 2015 - 20:38:48 EST


On Thu, 24 Sep 2015, Eric Curtin wrote:

> Hi Guys,
>
> Just wondering what I am doing wrong. I can't see my logs. I figured
> out what driver is used for my keyboard and started adding logging:
>
> [curtine@localhost ~]$ sudo lsusb -v | grep eyboard -B 13
> Bus 001 Device 003: ID 04ca:008d Lite-On Technology Corp.

...

> /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/10p, 480M
> |__ Port 4: Dev 2, If 0, Class=Wireless, Driver=btusb, 12M
> |__ Port 4: Dev 2, If 1, Class=Wireless, Driver=btusb, 12M
> |__ Port 7: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M
> |__ Port 7: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 12M
> |__ Port 7: Dev 3, If 2, Class=Human Interface Device, Driver=usbhid, 12M

...

> So, first I added a little logging and then some more, but I can't see
> any of it (see patch at bottom of email, I used KERN_EMERG, it's just
> temporary logging).
>
> I'm think I'm doing most things right, this is how I compile my code I
> wrote a little script (I'm on fedora):

...

> I reboot, load new kernel, blah blah. When I type keys I don't see my
> logs in dmesg, I don't see them in /var/log/messages either, I don't
> see them in /home/curtine/log.log either when I do a:
>
> sudo killall klogd
> sudo /sbin/klogd -f /home/curtine/log.log
>
> What am I doing wrong here?

You made a very simple mistake. See below.

> Also, as regards etiquette on these mailing lists, is it ok to
> regularly cc linux-kernel@xxxxxxxxxxxxxxx?

It's okay. But there's no need to do it if your topic is limited to a
single subsystem.

> diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
> index 9a332e6..2038d94 100644
> --- a/drivers/hid/usbhid/usbkbd.c
> +++ b/drivers/hid/usbhid/usbkbd.c
> @@ -112,6 +112,7 @@ struct usb_kbd {
>
> static void usb_kbd_irq(struct urb *urb)
> {
> + printk(KERN_EMERG "usb_kbd_irq");
> struct usb_kbd *kbd = urb->context;
> int i;
>
...

Your mistake was thinking that the driver for your keyboard is usbkbd.
It isn't. It's usbhid, as you can see in the "lsusb -t" output above.

Even though the source code for usbkbd is located in the usbhid
directory, they are separate drivers. Look at the Kconfig file in
drivers/hid/usbhid and you'll see.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/