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

From: prasannatsmkumar
Date: Sun May 27 2012 - 00:50:12 EST


Hi Anil,

If I open a device file (say a printer device) who determines the
correct driver and sends the call? How subsequent calls get processed
etc. Yes I know the init function will be called while the driver is
loaded (while running insmod driver.ko). How a open or write call
comes to the driver from user space? Who keeps track of the driver's
internal data (*dev) and sends that while calling methods in the
driver? I am more interested in things like that.

Thanks,
Prasanna Kumar

On Sun, May 27, 2012 at 7:37 AM, Anil Nair <anilcoll90@xxxxxxxxx> wrote:
> Hi Prasanna,
>
> On Fri, May 25, 2012 at 8:13 PM, prasannatsmkumar
> <prasannatsmkumar@xxxxxxxxx> wrote:
>> Thanks for your recommendation but I have went through the USB 2.0
>> specification and also had a chance to glance Linux USB Stack Design
>> Book. I am interested in software side - how things are going in
>> Linux. Upon connecting a mass storage device or USB keyboard is
>> connected how things works - the flow and the stack. Including the
>> user space tools that gets involved.
>
> Try compiling the linux kernel CONFIG_USB_DEBUG enabled. You can learn
> a lot by observing the kernel log, to view kernel log type dmesg. Try
> using usbmon Documentation can be found in
> Documentation/usb/usbmon.txt, i hope you have tried that.
>           Typically a driver starts from the probe function checks if
> the device is listed in its table "usb_device_id", try working from
> the probe function. A good way to start is the usb-skeleton.c present
> in linux kernel source "drivers/usb/usb-skeleton.c".
>            Also working of a kernel module differ the life cycle of
> the kernel module start from _init function when it is called or
> inserted to kernel using "insmod" of "modprobe".
>            And make sure you use reply-to-all when in the mailing
> list. :).  So, that others can help you too.
>
>
>
> --
> Regards,
> Anil Nair
--
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/