[Ilugc] Enumerating a new device from inside a kernel module

  • From: cyborg4k@xxxxxxxxx (Shakthi Kannan)
  • Date: Thu May 4 19:46:36 2006

Hi Binand, Joseph, and others,

--- Binand Sethumadhavan <binand@xxxxxxxxx> wrote:

I'm curious how some of the USB devices I see
in the stores
here are handled, then. They are dual-purpose - for
example, a USB
flash drive + a wireless mouse. 

Ohh! These are called "composite" or
"multi-functional" devices [1]. I am not sure if this
is what Joseph was refering to or which distribution,
specific kernel version he is using.

For any device in USB you have descriptors that
describe the characteristics of a device. They follow
this hierarchy:

 device descriptor
        |
 config descriptor
        |
interface descriptor
        |
endpoint descriptor

So a multi-functional device has many interfaces to
it. For example, you can have a USB VOIP phone that
also has a mass storage interface. Each interface has
endpoints that has buffers to which data is
sent/received.

The endpoint is analogous to the concept of "ports" in
your TCP/IP stack. To identify a unique application on
a system across a network, you specify the IP
address:port number, for example, 192.168.10.1:80.

Similarily, in USB you have a device address and its
endpoint number. For a multi-functional device, both
the interfaces should have the same device address (it
is still only one device), but many endpoints.

When you plugin such a device, enumeration will happen
only once for the single device. All details of the
device, configuration, interfaces, endpoints are
obtained by the host from the device. The usbcore
module will claim the appropriate interface drivers,
in your example, HID (mouse) and mass storage (flash
drive).

If you have multiple partitions in a flash drive, they
get detected as /dev/sda1, /dev/sda2 etc, which you
can automount with udev for the end-user. Similarily,
corresponding device files should be detected for a
multi-functional device.

I don't know if such devices are available in Chennai,
but, as per the USB specification and Linux USB
implementation, this should work.

HTH,

SK

[1] USB Specification (usb_20.pdf). Chapter 4:
Architectural Overview.

--
Shakthi Kannan
http://www.shakthimaan.com

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com ;

Other related posts: