X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fasix-sigma%2Fasix-sigma.c;h=e33b5b7959242376ed2c7573867303cd488d4e29;hb=340cfac0f0629aa3ee84a0a4db53381d04079fe3;hp=76b046a0592e221984ba47d2bb0a709847345e24;hpb=da0918aae0d43ab25cb72ddf8773831f0364ebdb;p=libsigrok.git diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index 76b046a0..e33b5b79 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -332,13 +332,13 @@ static int bin2bitbang(const char *filename, fseek(f, 0, SEEK_SET); if (!(compressed_buf = g_try_malloc(file_size))) { - sr_err("asix: %s: compressed_buf malloc failed", __func__); + sr_err("sigma: %s: compressed_buf malloc failed", __func__); fclose(f); return SR_ERR_MALLOC; } if (!(firmware = g_try_malloc(buffer_size))) { - sr_err("asix: %s: firmware malloc failed", __func__); + sr_err("sigma: %s: firmware malloc failed", __func__); fclose(f); g_free(compressed_buf); return SR_ERR_MALLOC; @@ -366,7 +366,7 @@ static int bin2bitbang(const char *filename, *buf = p = (unsigned char *)g_try_malloc(*buf_size); if (!p) { - sr_err("asix: %s: buf/p malloc failed", __func__); + sr_err("sigma: %s: buf/p malloc failed", __func__); g_free(compressed_buf); g_free(firmware); return SR_ERR_MALLOC; @@ -403,7 +403,7 @@ static int hw_init(const char *deviceinfo) deviceinfo = deviceinfo; if (!(sigma = g_try_malloc(sizeof(struct sigma)))) { - sr_err("asix: %s: sigma malloc failed", __func__); + sr_err("sigma: %s: sigma malloc failed", __func__); return 0; /* FIXME: Should be SR_ERR_MALLOC. */ } @@ -675,19 +675,28 @@ static int configure_probes(struct sr_device_instance *sdi, GSList *probes) return SR_OK; } -static void hw_closedev(int device_index) +static int hw_closedev(int device_index) { struct sr_device_instance *sdi; struct sigma *sigma; - if ((sdi = sr_get_device_instance(device_instances, device_index))) - { - sigma = sdi->priv; - if (sdi->status == SR_ST_ACTIVE) - ftdi_usb_close(&sigma->ftdic); + if (!(sdi = sr_get_device_instance(device_instances, device_index))) { + sr_err("sigma: %s: sdi was NULL", __func__); + return SR_ERR; /* TODO: SR_ERR_ARG? */ + } - sdi->status = SR_ST_INACTIVE; + if (!(sigma = sdi->priv)) { + sr_err("sigma: %s: sdi->priv was NULL", __func__); + return SR_ERR; /* TODO: SR_ERR_ARG? */ } + + /* TODO */ + if (sdi->status == SR_ST_ACTIVE) + ftdi_usb_close(&sigma->ftdic); + + sdi->status = SR_ST_INACTIVE; + + return SR_OK; } static void hw_cleanup(void) @@ -1367,8 +1376,8 @@ struct sr_device_plugin asix_sigma_plugin_info = { .api_version = 1, .init = hw_init, .cleanup = hw_cleanup, - .open = hw_opendev, - .close = hw_closedev, + .opendev = hw_opendev, + .closedev = hw_closedev, .get_device_info = hw_get_device_info, .get_status = hw_get_status, .get_capabilities = hw_get_capabilities,