- drivers = sr_hw_list();
- if (!drivers[0]) {
- sr_err("dev: %s: no supported hardware drivers", __func__);
- return SR_ERR; /* TODO: More specific error? */
- }
-
- /*
- * Initialize all drivers first. Since the init() call may involve
- * a firmware upload and associated delay, we may as well get all
- * of these out of the way first.
- */
- for (i = 0; drivers[i]; i++)
- sr_hw_init(drivers[i]);
-
- return SR_OK;
-}
-
-/**
- * Return the list of logic analyzer devices libsigrok has detected.
- *
- * If the libsigrok-internal device list is empty, a scan for attached
- * devices -- via a call to sr_dev_scan() -- is performed first.
- *
- * TODO: Error handling?
- *
- * @return The list (GSList) of detected devices, or NULL if none were found.
- */
-SR_API GSList *sr_dev_list(void)
-{
- if (!devs)
- sr_dev_scan();
-
- return devs;
-}
-
-/**
- * Create a new device.
- *
- * The device is added to the (libsigrok-internal) list of devices, but
- * additionally a pointer to the newly created device is also returned.
- *
- * The device has no probes attached to it yet after this call. You can
- * use sr_dev_probe_add() to add one or more probes.
- *
- * TODO: Should return int, so that we can return SR_OK, SR_ERR_* etc.
- *
- * It is the caller's responsibility to g_free() the allocated memory when
- * no longer needed. TODO: Using which API function?
- *
- * @param driver TODO.
- * If 'driver' is NULL, the created device is a "virtual" one.
- * @param driver_index TODO
- *
- * @return Pointer to the newly allocated device, or NULL upon errors.
- */
-SR_API struct sr_dev *sr_dev_new(const struct sr_dev_driver *driver,
- int driver_index)
-{
- struct sr_dev *dev;
-
- /* TODO: Check if driver_index valid? */
-
- if (!(dev = g_try_malloc0(sizeof(struct sr_dev)))) {
- sr_err("dev: %s: dev malloc failed", __func__);