linux - Why is the probe function in my kernel module not being called? -
while following, among others, tutorial ([http://tali.admingilde.org/linux-docbook/writing_usb_driver.pdf][1]) , reading chapters in linux device drivers book, cannot pr_debug statements in probe function show output in dmesg.
here's code:
#include <linux/module.h> /*included kernel modules*/ #include <linux/kernel.h> /*included kern_debug*/ #include <linux/init.h> /*included __init , __exit macros*/ #include <linux/usb.h> #include <linux/usb/input.h> #include <linux/hid.h> #define vendor_id 0x0930 #define device_id 0x6545 module_license("gpl"); module_author("dev"); module_description("eusb driver"); static struct usb_device_id eusb_table[] = { { usb_device(vendor_id, device_id) }, { } /* terminating entry */ }; module_device_table (usb, eusb_table); static int eusb_probe(struct usb_interface *interface, const struct usb_device_id *id) { pr_debug("usb probe function called\n"); return 0; } static void eusb_disconnect(struct usb_interface *interface) { pr_debug("usb disconnect function called\n"); } static struct usb_driver eusb_driver = { //.owner = this_module, .name = "eusb", .probe = eusb_probe, .disconnect = eusb_disconnect, .id_table = eusb_table }; static int __init eusb_init(void) { int result = 0; pr_debug("hello world!\n"); result = usb_register(&eusb_driver); if(result){ pr_debug("error %d while registering usb\n", result);} else{pr_debug("no error while registering usb\n");} return 0; } static void __exit eusb_exit(void) { usb_deregister(&eusb_driver); pr_debug("exiting module\n"); } module_init(eusb_init); module_exit(eusb_exit);
and makefile:
obj-m := eusb.o cflags_eusb.o := -ddebug kdir := /lib/modules/$(shell uname -r)/build pwd := $(shell pwd) default: $(make) -c $(kdir) subdirs=$(pwd) modules
make finishes without errors, after insmod can see module listed in lsmod , pr_debug in init , exit functions show output in dmesg.
when inserting device probe function seems not called (or pr_debug statements not show output in dmesg).
dmesg output:
[ 7777.521236] hello world! [ 7777.521264] usbcore: registered new interface driver eusb [ 7777.521266] no error while registering usb [ 7780.597087] usb 1-6: usb disconnect, device number 9 [ 7797.686970] usb 1-6: new high-speed usb device number 10 using xhci_hcd [ 7797.857324] usb 1-6: new usb device found, idvendor=0930, idproduct=6545 [ 7797.857328] usb 1-6: new usb device strings: mfr=1, product=2, serialnumber=3 [ 7797.857330] usb 1-6: product: datatraveler 2.0 [ 7797.857331] usb 1-6: manufacturer: kingston [ 7797.857333] usb 1-6: serialnumber: 08606e6d407fed10571e5067 [ 7797.858787] usb-storage 1-6:1.0: usb mass storage device detected [ 7797.858902] scsi host11: usb-storage 1-6:1.0 [ 7798.931417] scsi 11:0:0:0: direct-access kingston datatraveler 2.0 pmap pq: 0 ansi: 4 [ 7798.931824] sd 11:0:0:0: attached scsi generic sg3 type 0 [ 7800.184749] sd 11:0:0:0: [sdc] 60964864 512-byte logical blocks: (31.2 gb/29.0 gib) [ 7800.186338] sd 11:0:0:0: [sdc] write protect off [ 7800.186343] sd 11:0:0:0: [sdc] mode sense: 23 00 00 00 [ 7800.187948] sd 11:0:0:0: [sdc] no caching mode page found [ 7800.187952] sd 11:0:0:0: [sdc] assuming drive cache: write through [ 7800.220477] sdc: sdc1 sdc2 sdc3 [ 7800.225068] sd 11:0:0:0: [sdc] attached scsi removable disk [ 7802.798403] iso 9660 extensions: microsoft joliet level 3 [ 7802.799507] iso 9660 extensions: rrip_1991a
i have tried device, tried printk instead of pr_debug. found several questions on same problem, code far can tell almost/completely same code in answers.
i have tried with
usb_interface_info( usb_interface_class_hid, usb_interface_subclass_boot, usb_interface_protocol_keyboard)
instead of usb_device (the other device keyboard).
i noticed answers talk platform_driver instead of usb_driver, think not relevant me, never mentioned in tutorials.
where going wrong?
is purpose educational? otherwise driver there , it's called usb-storage
. seems driver enumerates device first. try disable usb-storage
, load driver again. or better use virtual machine (kvm / qemu) try drivers.
Comments
Post a Comment