LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   USB kernel module, how functions get called by kernel (https://www.linuxquestions.org/questions/linux-kernel-70/usb-kernel-module-how-functions-get-called-by-kernel-855969/)

falmdavis 01-12-2011 07:43 PM

USB kernel module, how functions get called by kernel
 
The USB kernel module is called "ums-usbat,ko" for the 2.6.37 kernel found from www.kernel.org. The source file is "shuttle_usbat.c" which is in linux-2.6.37/drivers/usb/storage directory. It depends on usb-storage.

Much of this will be beginning questions about how the functions get called in the kernel module. In the source file, there are many functions. When the module is inserted, the

Code:

static int __init usbat_init(void)
{
        return usb_register(&usbat_driver);
}

init function is called. When the module is removed, the

Code:

static void __exit usbat_exit(void)
{
        usb_deregister(&usbat_driver);
}

exit function is called. What makes the other functions get called? How can I call one of the functions?

There is also a macro called US_DEBUG. It is defined somewhere else, maybe in the kernel tree. How can I turn this on/off? I am building the module on its own.

When I plug in an RCA k@zoo mp3 player, it does not create a scsi device. How can I find out if the functions are getting called?

What could I do to try to read the device:
Quote:

usb 3-1: New USB device found, idVendor=069b, idProduct=2220
usb 3-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 3-1: usb_probe_device
usb 3-1: configuration #1 chosen from 1 choice
usb 3-1: adding 3-1:1.0 (config #1, interface 0)
drivers/usb/core/inode.c: creating file '004'
hub 3-0:1.0: state 7 ports 2 chg 0000 evt 0002
hub 1-0:1.0: hub_suspend
usb usb1: bus auto-suspend
ehci_hcd 0000:00:10.4: suspend root hub

Aquarius_Girl 01-18-2011 01:58 PM

Quote:

Originally Posted by falmdavis (Post 4222359)
What makes the other functions get called? How can I call one of the functions?

http://tldp.org/HOWTO/Module-HOWTO/x627.html This might be of some use to both of us. Can you give an example of a function which you wonder how s getting called? Point out to the source too.

Quote:

Originally Posted by falmdavis (Post 4222359)
How can I find out if the functions are getting called?

Try dmesg or printk.


All times are GMT -5. The time now is 04:53 AM.