On Mon, 28 Feb 2005 [EMAIL PROTECTED] wrote:

> Hi Pete,
> 
> When I connect USB device it gives device information like,
> configuration, interface, and endpoint descriptors. I need bus, level,
> and port information to map device files to particular USB port. But
> this information I can see in /proc/bus/usb/devices file, same I wanted
> to get it from the usb driver and map the device file with respective
> usb port.
> 
> I hope u understand it now.
> 
> Please tell me, how to get this information in USB driver?

We realize that English probably isn't your native language and you find 
it difficult to express yourself clearly.  But you need to do better than 
this before we can understand your question.

        You want to write code that maps a device file to the USB bus,
        level, and port numbers.  Is this code supposed to run within
        a device driver or within a userspace program?

        If this runs in a driver, in what form is it given the device
        file as input?  Does your code get a pointer to a struct
        usb_device?  Does it get a major/minor number pair?  Does it
        get a pointer to an open inode?  Or does it get something else?

        If this runs in a user program, in what form is it given the
        device file as input?  Does your code get an open file descriptor?
        Does it get a file name?  Or does it get something else?

If your code runs within a device driver and it gets a pointer to a struct
usb_device, then most of the information you want is easy to figure out.  
If udev is the struct usb_device *, then the bus number is
udev->bus->busnum.  The level you can calculate by counting how many times
you have to iterate before udev->parent->parent->parent->...->parent is
NULL; if udev->parent is NULL then the level is 1.  The port number you
can find by looking at udev->parent->children[] and seeing which entry in
the array is equal to udev; the port number is the array index plus 1.

Alan Stern



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to