diff options
author | Daniel Drake <dsd@gentoo.org> | 2008-03-06 23:25:20 +0000 |
---|---|---|
committer | Daniel Drake <dsd@gentoo.org> | 2008-03-06 23:25:20 +0000 |
commit | 9cfdb494fccac53a4277da7c8b6d15f1a72a4959 (patch) | |
tree | a6aa93d20fe9768534074b8c5792999bf45f9add /libusb/libusbi.h | |
parent | 77cea822788e024c848c7f554915f771a2dc1e0f (diff) | |
download | libusb-9cfdb494fccac53a4277da7c8b6d15f1a72a4959.tar.gz |
Rework device discovery API
libusb_find_devices and libusb_get_devices are no more
libusb_get_device_list obtains a list of libusb_device structures for all
known devices in the system.
Each libusb_device now has a reference count, defaulting to 1 on
instantiation. The reference count of 1 refers to the fact that it is
present in the list in this scenario.
Opening a device adds a pointer to the libusb_device structure in the
handle, so that also adds a reference. Closing the device removes that
reference.
The function to free the device list can optionally unref all the devices
inside.
In future we will make the libusb_device instances all "global" so that if
the app calls get_device_list twice it actually gets the same libusb_device
structure references back. This way we can start to track disconnects, and
we can investigate adding a unique "session ID" to each libusb_device, an
identifier guaranteed to be unique to that device until reboot.
Diffstat (limited to 'libusb/libusbi.h')
-rw-r--r-- | libusb/libusbi.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libusb/libusbi.h b/libusb/libusbi.h index b639ed6..c6b7f3e 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -143,8 +143,8 @@ void usbi_log(enum usbi_log_level, const char *function, const char *format, ... #define usbi_warn(fmt...) _usbi_log(LOG_LEVEL_WARNING, fmt) #define usbi_err(fmt...) _usbi_log(LOG_LEVEL_ERROR, fmt) -struct libusb_dev { - struct list_head list; +struct libusb_device { + int refcnt; char *nodepath; struct libusb_dev_descriptor desc; struct libusb_config_descriptor *config; @@ -152,7 +152,7 @@ struct libusb_dev { struct libusb_dev_handle { struct list_head list; - struct libusb_dev *dev; + struct libusb_device *dev; int fd; }; |