1
votes

I read an article at http://www.technovelty.org/code/linux/plugging-in-usb.html. Its just very good.

In which function exactly the enumeration of a connected device is done by host and in which function uevent is sent ?

I introduced printks in usb_new_device etc functions and If i use "udevadm monitor --kernel", it is showing the kernel events even before the enumeration function which is called in usb_new_device in hub.c ?

Log follows

[ 110.819399] 123456 hub_irq

[ 110.824952] 123456 hub_port_connect_change

[ 110.979624] 123456 hub_port_init

[ 111.059625] usb 2-1.2: new high speed USB device using fsl-ehci and address 3

[ 111.189722] 123456 usb_new_device

[ 111.196219] usb 2-1.2: New USB device found, idVendor=05ac, idProduct=12a0

[ 111.203113] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[ 111.210438] usb 2-1.2: Product: iPhone

[ 111.214196] usb 2-1.2: Manufacturer: Apple Inc.

[ 111.218728] usb 2-1.2: SerialNumber: 9356b662a93170509226069e5adf53f2351d774e

KERNEL[110.940183] add /devices/platform/fsl-ehci.1/usb2/2-1/2-1.2 (usb)

Check the timestamps though udevadm out put is at the end(udevadm runs in user space) its actuallt got the event at [ 110.940183] where as usb_new_device was called at [ 111.189722]

1

1 Answers

3
votes

I am almost Linux kernel illiterate, so not 100% sure of this info..but managed to trace the USB init with the help of http://www.cs.fsu.edu/~baker/devices/lxr/http/find?v=2.6.11.8

Here is the flow of USB Host code (Please correct me if this is wrong), on Linux 2.6.11.8 kernel

usb_init()     // invoked in ../core/usb.c it initializes host, major, usbfs and usb_hub 
usb_hub_init() // in core/hub.c it creates a kernel thread hub_thread()
hub_thread()   // in core/hub.c
hub_events()   // next this if called 
hub_port_connect_change() // then this..