Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 6: Device Drivers


unsigned int toggle[2]; /* one bit for each endpoint
* ([0] = IN, [1] = OUT) */

struct usb_device *parent; /* our hub, unless we’re the root */
struct usb_bus *bus; /* Bus we’re part of */

struct device dev; /* Generic device interface */

struct usb_device_descriptor descriptor;/* Descriptor */
struct usb_host_config *config; /* All of the configs */

struct usb_host_config *actconfig;/* the active configuration */
...
u8 portnum; /* Parent port number (origin 1) */

...
/* static strings from the device */
char *product; /* iProduct string, if present */
char *manufacturer; /* iManufacturer string, if present */
char *serial; /* iSerialNumber string, if present */
...
int maxchild; /* Number of ports if hub */
struct usb_device *children[USB_MAXCHILDREN];
...
};

❑ devnumholds the unique number of the device (globally unique in the entire USB tree).state
andspeedindicate the state (attached, configured, etc.) and the speed of the device. The USB
standard defines three possible values for the speed:USB_SPEED_LOWandUSB_SPEED_FULLfor
USB 1.1andUSB_SPEED_HIGHfor USB 2.0.


❑ devpathspecifies the position of the device in the topology of the USB tree. The port numbers
of all hubs that must be traversed to move from the root element to the device are stored in the
individual array entries.


❑ parentpoints to the data structure of the hub on which the device is attached, andbuspoints
to the corresponding data structure of the bus. Both fields therefore supply information on the
topology of the USB chain.


❑ devestablishes the link to the generic device model.


❑ descriptorgroups together the characteristic data that describe a USB device in a further data
structure (which includes things like vendor ID, product ID, device class, etc.).


❑ actconfigpoints to the current configuration of the device, andconfiglists all possible alterna-
tives.


❑ usbfs_entryis used to link with the USB filesystem that is normally mounted at/proc/bus/usb
and provides access to the devices from userspace.


❑ product,manufacturer,andserialpoint to ASCII strings with the product name, the manufac-
turer, and a serial number for the device, allof which are supplied by the hardware itself.


❑ Two more elements are relevant if the current device is a hub:maxchildspecifies how many
ports the hub has (i.e., how many devices can be attached), andchildrencontains a collection of
pointers to theirusb_deviceinstances. These elements define the topology of the USB tree.

Free download pdf