X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fikalogic-scanaplus%2Fapi.c;h=dd5d09ffef51342acb8a26a7af226387c2859310;hb=8bf18daabbf3cb0fec6c178b4bc7f6283a314e45;hp=520bf6fe94da19b3f29010a23ef555401daf88fa;hpb=43376f3324cddd257a0260b06d9db8180c35fdf3;p=libsigrok.git
diff --git a/src/hardware/ikalogic-scanaplus/api.c b/src/hardware/ikalogic-scanaplus/api.c
index 520bf6fe..dd5d09ff 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;
@@ -55,26 +52,22 @@ static void clear_helper(void *priv)
ftdi_free(devc->ftdic);
g_free(devc->compressed_buf);
g_free(devc->sample_buf);
- g_free(devc);
}
static int dev_clear(const struct sr_dev_driver *di)
{
- return std_dev_clear(di, clear_helper);
+ return std_dev_clear_with_callback(di, clear_helper);
}
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_dev_inst *sdi;
- struct drv_context *drvc;
struct dev_context *devc;
unsigned int i;
int ret;
(void)options;
- drvc = di->context;
-
/* Allocate memory for our private device context. */
devc = g_malloc0(sizeof(struct dev_context));
@@ -149,7 +142,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,
@@ -159,7 +151,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) {
@@ -167,7 +158,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);
@@ -176,7 +166,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);
@@ -185,7 +174,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);
@@ -194,7 +182,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);
@@ -203,7 +190,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) {
@@ -213,33 +199,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,
@@ -267,9 +241,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) {
@@ -331,9 +302,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)
@@ -352,7 +320,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);
@@ -362,9 +330,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;
}