Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

USB
[Linux 2.6 support]

USB. More...

Data Structures

struct  usb_proc_info_s
 Key information about USB devices from /proc that is not available in sysfs. More...


Defines

#define USB_IDS_MAX_LINE_LEN   512
 Maximum length of lines in usb.ids.


Typedefs

typedef usb_proc_info_s usb_proc_info
 Key information about USB devices from /proc that is not available in sysfs.


Functions

void usb_ids_line_iter_init ()
 Initialize the usb.ids line iterator to the beginning of the file.

char * usb_ids_line_iter_get_line (unsigned int *line_len)
 Get the next line from usb.ids.

dbus_bool_t usb_ids_line_iter_has_more ()
 See if there are more lines to process in usb.ids.

void usb_ids_find (int vendor_id, int product_id, char **vendor_name, char **product_name)
 Find the names for a USB device.

dbus_bool_t usb_ids_load (const char *path)
 Load the USB database used for mapping vendor, product, subsys_vendor and subsys_product numbers into names.

dbus_bool_t usb_ids_free ()
 Free resources used by to store the USB database.

usb_proc_infousb_proc_find_virtual_hub (int bus_number)
 Find the USB virtual root hub device for a USB bus.

usb_proc_infousb_proc_find_virtual_hub_child (int bus_number, int port_number)
 Find a child of a USB virtual root hub device for a USB bus.

usb_proc_infousb_proc_find_on_hub (int bus_number, int port_number, int parent_device_number)
 Find a child of a given hub device given a bus and port number.

void usb_proc_handle_topology (usb_proc_info *info, char *s)
 Parse the topology field.

void usb_proc_handle_device_info (usb_proc_info *info, char *s)
 Parse the device descriptor field.

void usb_proc_device_done (usb_proc_info *info)
 Called when an entry from /proc/bus/usb/devices have been parsed.

void usb_proc_parse_line (char *s)
 Parse a line from /proc/bus/usb/devices.

void usb_proc_parse ()
 Parse /proc/bus/usb/devices.

char * usbif_compute_udi (HalDevice *d, int append_num)
 This function will compute the device uid based on other properties of the device.

char * usb_compute_udi (HalDevice *d, int append_num)
 This function will compute the device uid based on other properties of the device.

void usb_add_caps_from_class (HalDevice *d, int if_class, int if_sub_class, int if_proto)
 Set capabilities from interface and/or device class.

void visit_device_usbif_got_parent (HalDevice *parent, void *data1, void *data2)
 Callback when the parent is found or if there is no parent..

void visit_device_usb_interface (const char *path, struct sysfs_device *device)
 Visitor function for interfaces on a USB device.

void visit_device_usb_got_parent (HalDevice *parent, void *data1, void *data2)
 Callback when the parent is found or if there is no parent..

void visit_device_usb (const char *path, struct sysfs_device *device)
 Visitor function for USB device.

void linux_usb_init ()
 Init function for USB handling.

void linux_usb_detection_done ()
 This function is called when all device detection on startup is done in order to perform optional batch processing on devices.

void linux_usb_shutdown ()
 Shutdown function for USB handling.


Variables

char * usb_ids = NULL
 Pointer to where the usb.ids file is loaded.

unsigned int usb_ids_len
 Length of data store at at usb_ids.

unsigned int usb_ids_iter_pos
 Iterator position into usb_ids.

usb_proc_infousb_proc_head = NULL
 First element in usb proc linked list.

usb_proc_infousb_proc_cur_info = NULL
 Unique device id of the device we are working on.


Detailed Description

USB.


Function Documentation

void usb_add_caps_from_class HalDevice d,
int  if_class,
int  if_sub_class,
int  if_proto
[static]
 

Set capabilities from interface and/or device class.

This is a function from hell, maybe some searchable data-structure would be better...

Parameters:
d The HalDevice to set the caps
if_class Interface class
if_sub_class Interface sub class
if_proto Interface protocol

Definition at line 605 of file linux_usb.c.

References ds_add_capability(), ds_property_set_string(), and HalDevice.

Referenced by visit_device_usb(), and visit_device_usbif_got_parent().

char* usb_compute_udi HalDevice d,
int  append_num
[static]
 

This function will compute the device uid based on other properties of the device.

Specifically, the following properties are required:

  • usb.idVendor, usb.idProduct, usb.bcdDevice.

Other properties may also be used, specifically the usb.SerialNumber is used if available.

Requirements for uid:

  • do not rely on bus, port etc.; we want this id to be as unique for the device as we can
  • make sure it doesn't rely on properties that cannot be obtained from the minimal information we can obtain on an unplug event

Parameters:
d HalDevice object
append_num Number to append to name if not -1
Returns:
New unique device id; only good until the next invocation of this function

Definition at line 568 of file linux_usb.c.

References ds_property_exists(), ds_property_get_int(), ds_property_get_string(), and HalDevice.

Referenced by visit_device_usb_got_parent().

void usb_ids_find int  vendor_id,
int  product_id,
char **  vendor_name,
char **  product_name
[static]
 

Find the names for a USB device.

The pointers returned are only valid until the next invocation of this function.

Parameters:
vendor_id USB vendor id or 0 if unknown
product_id USB product id or 0 if unknown
vendor_name Set to pointer of result or #NULL
product_name Set to pointer of result or #NULL

Definition at line 119 of file linux_usb.c.

References usb_ids_line_iter_get_line(), usb_ids_line_iter_has_more(), usb_ids_line_iter_init(), and USB_IDS_MAX_LINE_LEN.

Referenced by visit_device_usb().

dbus_bool_t usb_ids_free  )  [static]
 

Free resources used by to store the USB database.

Parameters:
#FALSE if the USB database wasn't loaded

Definition at line 256 of file linux_usb.c.

References usb_ids.

Referenced by linux_usb_shutdown().

char* usb_ids_line_iter_get_line unsigned int *  line_len  )  [static]
 

Get the next line from usb.ids.

Parameters:
line_len Pointer to where number of bytes in line will be stored
Returns:
Pointer to the line; only valid until the next invocation of this function

Definition at line 77 of file linux_usb.c.

References usb_ids, usb_ids_iter_pos, usb_ids_len, and USB_IDS_MAX_LINE_LEN.

Referenced by usb_ids_find().

dbus_bool_t usb_ids_line_iter_has_more  )  [static]
 

See if there are more lines to process in usb.ids.

Returns:
#TRUE iff there are more lines to process

Definition at line 103 of file linux_usb.c.

References usb_ids_iter_pos, and usb_ids_len.

Referenced by usb_ids_find().

dbus_bool_t usb_ids_load const char *  path  )  [static]
 

Load the USB database used for mapping vendor, product, subsys_vendor and subsys_product numbers into names.

Parameters:
path Path of the usb.ids file, e.g. /usr/share/hwdata/usb.ids
Returns:
#TRUE if the file was succesfully loaded

Definition at line 217 of file linux_usb.c.

References usb_ids, and usb_ids_len.

Referenced by linux_usb_init().

void usb_proc_device_done usb_proc_info info  )  [static]
 

Called when an entry from /proc/bus/usb/devices have been parsed.

Parameters:
info Structure representing the entry

Definition at line 392 of file linux_usb.c.

References usb_proc_info_s::next, usb_proc_head, and usb_proc_info.

Referenced by usb_proc_parse(), and usb_proc_parse_line().

usb_proc_info* usb_proc_find_on_hub int  bus_number,
int  port_number,
int  parent_device_number
[static]
 

Find a child of a given hub device given a bus and port number.

Parameters:
bus_number USB bus number
port_number The port number, starting from 1
parent_device_number The Linux device number
Returns:
The usb_proc_info structure with information retrieved from /proc or #NULL if not found

Definition at line 340 of file linux_usb.c.

References usb_proc_info_s::next, usb_proc_info_s::t_bus, usb_proc_info_s::t_parent, usb_proc_info_s::t_port, usb_proc_head, and usb_proc_info.

Referenced by visit_device_usb_got_parent().

usb_proc_info* usb_proc_find_virtual_hub int  bus_number  )  [static]
 

Find the USB virtual root hub device for a USB bus.

Parameters:
bus_number USB bus number
Returns:
The usb_proc_info structure with information retrieved from /proc or #NULL if not found

Definition at line 298 of file linux_usb.c.

References usb_proc_info_s::next, usb_proc_info_s::t_bus, usb_proc_info_s::t_level, usb_proc_head, and usb_proc_info.

Referenced by visit_device_usb_got_parent().

usb_proc_info* usb_proc_find_virtual_hub_child int  bus_number,
int  port_number
[static]
 

Find a child of a USB virtual root hub device for a USB bus.

Parameters:
bus_number USB bus number
port_number The port number, starting from 1
Returns:
The usb_proc_info structure with information retrieved from /proc or #NULL if not found

Definition at line 318 of file linux_usb.c.

References usb_proc_info_s::next, usb_proc_info_s::t_bus, usb_proc_info_s::t_level, usb_proc_info_s::t_port, usb_proc_head, and usb_proc_info.

Referenced by visit_device_usb_got_parent().

void usb_proc_handle_device_info usb_proc_info info,
char *  s
[static]
 

Parse the device descriptor field.

Parameters:
info Structure to put information into
s Line from /proc/bus/usb/devices starting with "D:"

Definition at line 381 of file linux_usb.c.

References usb_proc_info_s::d_version_bcd, find_bcd2(), and usb_proc_info.

Referenced by usb_proc_parse_line().

void usb_proc_handle_topology usb_proc_info info,
char *  s
[static]
 

Parse the topology field.

Parameters:
info Structure to put information into
s Line from /proc/bus/usb/devices starting with "T:"

Definition at line 362 of file linux_usb.c.

References find_bcd2(), find_num(), usb_proc_info_s::t_bus, usb_proc_info_s::t_count, usb_proc_info_s::t_device, usb_proc_info_s::t_level, usb_proc_info_s::t_max_children, usb_proc_info_s::t_parent, usb_proc_info_s::t_port, usb_proc_info_s::t_speed_bcd, and usb_proc_info.

Referenced by usb_proc_parse_line().

void usb_proc_parse_line char *  s  )  [static]
 

Parse a line from /proc/bus/usb/devices.

Parameters:
s Line from /proc/bus/usb/devices

Definition at line 405 of file linux_usb.c.

References DIE, usb_proc_cur_info, usb_proc_device_done(), usb_proc_handle_device_info(), usb_proc_handle_topology(), and usb_proc_info.

Referenced by usb_proc_parse().

char* usbif_compute_udi HalDevice d,
int  append_num
[static]
 

This function will compute the device uid based on other properties of the device.

For USB interfaces it basically is the physical USB device UDI appended with the interface number

Parameters:
d HalDevice object
append_num Number to append to name if not -1
Returns:
New unique device id; only good until the next invocation of this function

Definition at line 522 of file linux_usb.c.

References ds_property_get_int(), ds_property_get_string(), and HalDevice.

Referenced by visit_device_usbif_got_parent().

void visit_device_usb const char *  path,
struct sysfs_device *  device
 

Visitor function for USB device.

This function parses the attributes present and creates a new HAL device based on this information.

Parameters:
path Sysfs-path for device
device libsysfs object for device

Note:
We also set the path here, because otherwise we can't handle two identical devices per the algorithm used in a rename_and_merge()
The point is that we need something unique in the info.bus namespace

Definition at line 826 of file linux_usb.c.

References drivers_lookup(), ds_device_async_find_by_key_value_string(), ds_device_new(), ds_property_get_int(), ds_property_set_bool(), ds_property_set_int(), ds_property_set_string(), get_parent_sysfs_path(), HAL_LINUX_HOTPLUG_TIMEOUT, HalDevice, is_probing, parse_dec(), parse_hex(), usb_add_caps_from_class(), usb_ids_find(), visit_device_usb_got_parent(), and visit_device_usb_interface().

Referenced by visit_device().

void visit_device_usb_got_parent HalDevice parent,
void *  data1,
void *  data2
[static]
 

Callback when the parent is found or if there is no parent..

This is where we get added to the GDL..

Parameters:
parent Async Return value from the find call
data1 User data
data2 User data

Definition at line 1036 of file linux_usb.c.

References usb_proc_info_s::d_version_bcd, ds_device_find(), ds_gdl_add(), ds_property_get_int(), ds_property_get_string(), ds_property_set_int(), ds_property_set_string(), HalDevice, is_probing, rename_and_merge(), usb_proc_info_s::t_device, usb_proc_info_s::t_level, usb_proc_info_s::t_max_children, usb_proc_info_s::t_speed_bcd, HalDevice_s::udi, usb_compute_udi(), usb_proc_find_on_hub(), usb_proc_find_virtual_hub(), usb_proc_find_virtual_hub_child(), usb_proc_info, and usb_proc_parse().

Referenced by visit_device_usb().

void visit_device_usb_interface const char *  path,
struct sysfs_device *  device
[static]
 

Visitor function for interfaces on a USB device.

Parameters:
path Sysfs-path for USB interface
device libsysfs object for USB interface

Note:
We also set the path here, because otherwise we can't handle two identical devices per the algorithm used in a rename_and_merge() The point is that we need something unique in info.bus=usbif namespace

Definition at line 681 of file linux_usb.c.

References drivers_lookup(), ds_device_async_find_by_key_value_string(), ds_device_new(), ds_property_set_bool(), ds_property_set_int(), ds_property_set_string(), get_parent_sysfs_path(), HAL_LINUX_HOTPLUG_TIMEOUT, HalDevice, is_probing, parse_dec(), and visit_device_usbif_got_parent().

Referenced by visit_device_usb().

void visit_device_usbif_got_parent HalDevice parent,
void *  data1,
void *  data2
[static]
 

Callback when the parent is found or if there is no parent..

This is where we get added to the GDL..

Parameters:
parent Async Return value from the find call
data1 User data
data2 User data

Definition at line 766 of file linux_usb.c.

References ds_device_destroy(), ds_device_find(), ds_gdl_add(), ds_property_get_int(), ds_property_set_int(), ds_property_set_string(), HalDevice, rename_and_merge(), HalDevice_s::udi, usb_add_caps_from_class(), and usbif_compute_udi().

Referenced by visit_device_usb_interface().


Generated on Thu Mar 11 21:32:27 2004 for HAL by doxygen 1.3.6-20040222