Re: Code flow from device connection to device node in /dev creation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 25, 2012 at 11:37:02AM +0530, prasannatsmkumar wrote:
> Hi,
> 
> I have been looking into USB code. I have some basic idea of what is
> going on but still I have some doubts which I try to explain here.
> 
> I have explained how the code flow takes place as per my understanding,
> My current understanding:
> 
> 1. USB Device connected physically.
> 2. khubd detects the connection of USB device (I hope that khub gets
> interrupt from Host Controller).
> 3. Kernel notifies the user space about the device connection
> (probably udev involves in this).

udev can be listening for this, yes.

> 4. Driver for the corresponding device is detected using the device
> VID/PID and loaded (modprobe is loading the driver).

Yes.

> 5. A device file (nod in /dev - like /dev/ttyUSB0) is created for the
> USB device.

No, not all USB drivers create device nodes (think about usb networking
devices as one example.)

> Is my understanding correct?

Close.

> Doubts and Questions:
> 1. How kernel notifies the user space about the device arrival? What
> is the work of udev here?

udev can be the tool listening to this.  Other tools are out there that
can also do this (mdev is one example.)

> 2. How the device file gets associated with the driver (or device)?

Device files are dependant on the driver for the device.  As stated
above, not all drivers talk to userspace through device files.

> i.e., When a user space code does a open or write call to the device
> file (e.g., /dev/ttyUSB0) who determines the correct driver (or
> device) and sends the commands to the device?

That's a different type of question, have you read documentation like
the "Linux Device Drivers" book already?  It is free online and should
answer things like this.

> How the device file to physical device mapping magic works?

Squirrels are involved in creating the magic. :)

No, seriously, go look up the above mentioned book, it should help
explain things better.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux