This changes the semantics of the init() call as well. That now only
initializes the driver -- an administrative affair, no hardware gets
touched during this call. It returns a standard SR_OK or SR_ERR* code.
The scan() call does a discovery run for devices it knows, and returns
the number found. It can be called at any time.
}
static int hw_init(void)
}
static int hw_init(void)
+{
+
+ /* Nothing to do. */
+
+ return SR_OK;
+}
+
+static int hw_scan(void)
{
struct sr_dev_inst *sdi;
struct context *ctx;
{
struct sr_dev_inst *sdi;
struct context *ctx;
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
static int hw_init(void)
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
static int hw_init(void)
+{
+
+ /* Nothing to do. */
+
+ return SR_OK;
+}
+
+static int hw_scan(void)
{
int ret;
struct sr_dev_inst *sdi;
{
int ret;
struct sr_dev_inst *sdi;
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
static int hw_init(void)
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
static int hw_init(void)
+{
+
+ /* Nothing to do. */
+
+ return SR_OK;
+}
+
+static int hw_scan(void)
{
struct sr_dev_inst *sdi;
{
struct sr_dev_inst *sdi;
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
*/
static int hw_init(void)
*/
static int hw_init(void)
+{
+
+ if (libusb_init(&usb_context) != 0) {
+ sr_warn("fx2lafw: Failed to initialize libusb.");
+ return SR_ERR;
+ }
+
+ return SR_OK;
+}
+
+static int hw_scan(void)
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
const struct fx2lafw_profile *prof;
struct context *ctx;
libusb_device **devlist;
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
const struct fx2lafw_profile *prof;
struct context *ctx;
libusb_device **devlist;
- int ret;
- int devcnt = 0;
- int i, j;
-
- if (libusb_init(&usb_context) != 0) {
- sr_warn("fx2lafw: Failed to initialize libusb.");
- return 0;
- }
/* Find all fx2lafw compatible devices and upload firmware to them. */
/* Find all fx2lafw compatible devices and upload firmware to them. */
libusb_get_device_list(usb_context, &devlist);
for (i = 0; devlist[i]; i++) {
libusb_get_device_list(usb_context, &devlist);
for (i = 0; devlist[i]; i++) {
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
static int hw_init(void)
{
static int hw_init(void)
{
- struct sr_dev_inst *sdi;
- struct context *ctx;
- int devcnt = 0;
if (libusb_init(&genericdmm_usb_context) != 0) {
sr_err("genericdmm: Failed to initialize USB.");
if (libusb_init(&genericdmm_usb_context) != 0) {
sr_err("genericdmm: Failed to initialize USB.");
+
+ return SR_OK;
+}
+
+static int hw_scan(void)
+{
+ struct sr_dev_inst *sdi;
+ struct context *ctx;
+ int devcnt = 0;
+
if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
sr_err("genericdmm: ctx malloc failed.");
return 0;
if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
sr_err("genericdmm: ctx malloc failed.");
return 0;
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
}
static int hw_init(void)
}
static int hw_init(void)
+{
+
+ if (libusb_init(&usb_context) != 0) {
+ sr_err("hantek-dso: Failed to initialize USB.");
+ return SR_ERR;
+ }
+
+ return SR_OK;
+}
+
+static int hw_scan(void)
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
const struct dso_profile *prof;
struct context *ctx;
libusb_device **devlist;
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
const struct dso_profile *prof;
struct context *ctx;
libusb_device **devlist;
- int err, devcnt, i, j;
-
- if (libusb_init(&usb_context) != 0) {
- sr_err("hantek-dso: Failed to initialize USB.");
- return 0;
- }
/* Find all Hantek DSO devices and upload firmware to all of them. */
devcnt = 0;
libusb_get_device_list(usb_context, &devlist);
for (i = 0; devlist[i]; i++) {
/* Find all Hantek DSO devices and upload firmware to all of them. */
devcnt = 0;
libusb_get_device_list(usb_context, &devlist);
for (i = 0; devlist[i]; i++) {
- if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("hantek-dso: failed to get device descriptor: %d", err);
+ if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
+ sr_err("hantek-dso: failed to get device descriptor: %d", ret);
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
}
static int hw_init(void)
}
static int hw_init(void)
+{
+
+ /* Nothing to do. */
+
+ return SR_OK;
+}
+
+static int hw_scan(void)
{
struct sr_dev_inst *sdi;
int devcnt = 0;
{
struct sr_dev_inst *sdi;
int devcnt = 0;
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
}
static int hw_init(void)
}
static int hw_init(void)
+{
+
+ /* Nothing to do. */
+
+ return SR_OK;
+}
+
+static int hw_scan(void)
{
struct sr_dev_inst *sdi;
struct context *ctx;
{
struct sr_dev_inst *sdi;
struct context *ctx;
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
*/
static int hw_init(void)
*/
static int hw_init(void)
+{
+
+ /* Nothing to do. */
+
+ return SR_OK;
+}
+
+static int hw_scan(void)
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.dev_info_get = hw_dev_info_get,
int api_version;
int (*init) (void);
int (*cleanup) (void);
int api_version;
int (*init) (void);
int (*cleanup) (void);
/* Device-specific */
int (*dev_open) (int dev_index);
/* Device-specific */
int (*dev_open) (int dev_index);
static int hw_init(void)
{
static int hw_init(void)
{