X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fikalogic-scanaplus%2Fapi.c;h=9f8f2506d41c11acec9876eeed795d9c841fa004;hb=91057d2fc24c0ca058aa08c8ea6ada4eadf05ffd;hp=9b4af07de364754aa143bc8165f583814833cc93;hpb=dd5c48a6d567a3cac62c4b0058588273bbeea171;p=libsigrok.git diff --git a/src/hardware/ikalogic-scanaplus/api.c b/src/hardware/ikalogic-scanaplus/api.c index 9b4af07d..9f8f2506 100644 --- a/src/hardware/ikalogic-scanaplus/api.c +++ b/src/hardware/ikalogic-scanaplus/api.c @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * along with this program; if not, see . */ #include @@ -44,8 +43,6 @@ static const char *channel_names[] = { /* Note: The IKALOGIC ScanaPLUS always samples at 100MHz. */ static const uint64_t samplerates[1] = { SR_MHZ(100) }; -static int dev_acquisition_stop(struct sr_dev_inst *sdi); - static void clear_helper(void *priv) { struct dev_context *devc; @@ -66,18 +63,12 @@ static int dev_clear(const struct sr_dev_driver *di) static GSList *scan(struct sr_dev_driver *di, GSList *options) { struct sr_dev_inst *sdi; - struct drv_context *drvc; struct dev_context *devc; - GSList *devices; unsigned int i; int ret; (void)options; - drvc = di->context; - - devices = NULL; - /* Allocate memory for our private device context. */ devc = g_malloc0(sizeof(struct dev_context)); @@ -115,19 +106,15 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->status = SR_ST_INACTIVE; sdi->vendor = g_strdup(USB_VENDOR_NAME); sdi->model = g_strdup(USB_MODEL_NAME); - sdi->driver = di; sdi->priv = devc; for (i = 0; i < ARRAY_SIZE(channel_names); i++) sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_names[i]); - devices = g_slist_append(devices, sdi); - drvc->instances = g_slist_append(drvc->instances, sdi); - /* Close device. We'll reopen it again when we need it. */ scanaplus_close(devc); - return devices; + return std_scan_complete(di, g_slist_append(NULL, sdi)); scanaplus_close(devc); err_free_ftdic: @@ -156,7 +143,6 @@ static int dev_open(struct sr_dev_inst *sdi) ftdi_get_error_string(devc->ftdic)); return SR_ERR; } - sr_dbg("FTDI chip interface A set successfully."); /* Open the device. */ ret = ftdi_usb_open_desc(devc->ftdic, USB_VENDOR_ID, USB_DEVICE_ID, @@ -166,7 +152,6 @@ static int dev_open(struct sr_dev_inst *sdi) ftdi_get_error_string(devc->ftdic)); return SR_ERR; } - sr_dbg("FTDI device opened successfully."); /* Purge RX/TX buffers in the FTDI chip. */ if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) { @@ -174,7 +159,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip buffers purged successfully."); /* Reset the FTDI bitmode. */ ret = ftdi_set_bitmode(devc->ftdic, 0xff, BITMODE_RESET); @@ -183,7 +167,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip bitmode reset successfully."); /* Set FTDI bitmode to "sync FIFO". */ ret = ftdi_set_bitmode(devc->ftdic, 0xff, BITMODE_SYNCFF); @@ -192,7 +175,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip sync FIFO mode entered successfully."); /* Set the FTDI latency timer to 2. */ ret = ftdi_set_latency_timer(devc->ftdic, 2); @@ -201,7 +183,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip latency timer set successfully."); /* Set the FTDI read data chunk size to 64kB. */ ret = ftdi_read_data_set_chunksize(devc->ftdic, 64 * 1024); @@ -210,7 +191,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip read data chunk size set successfully."); /* Get the ScanaPLUS device ID from the FTDI EEPROM. */ if ((ret = scanaplus_get_device_id(devc)) < 0) { @@ -220,33 +200,21 @@ static int dev_open(struct sr_dev_inst *sdi) sr_dbg("Received ScanaPLUS device ID successfully: %02x %02x %02x.", devc->devid[0], devc->devid[1], devc->devid[2]); - sdi->status = SR_ST_ACTIVE; - return SR_OK; err_dev_open_close_ftdic: scanaplus_close(devc); + return SR_ERR; } static int dev_close(struct sr_dev_inst *sdi) { - int ret; struct dev_context *devc; - ret = SR_OK; devc = sdi->priv; - if (sdi->status == SR_ST_ACTIVE) { - sr_dbg("Status ACTIVE, closing device."); - ret = scanaplus_close(devc); - } else { - sr_spew("Status not ACTIVE, nothing to do."); - } - - sdi->status = SR_ST_INACTIVE; - - return ret; + return scanaplus_close(devc); } static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, @@ -274,9 +242,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd (void)cg; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - devc = sdi->priv; switch (key) { @@ -338,9 +303,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) int ret; struct dev_context *devc; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - devc = sdi->priv; if (!devc->ftdic) @@ -359,7 +321,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) if ((ret = scanaplus_start_acquisition(devc)) < 0) return ret; - std_session_send_df_header(sdi, LOG_PREFIX); + std_session_send_df_header(sdi); /* Hook up a dummy handler to receive data from the device. */ sr_session_source_add(sdi->session, -1, 0, 0, scanaplus_receive_data, (void *)sdi); @@ -369,9 +331,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - sr_dbg("Stopping acquisition."); sr_session_source_remove(sdi->session, -1); - std_session_send_df_end(sdi, LOG_PREFIX); + std_session_send_df_end(sdi); return SR_OK; }