]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/ikalogic-scanaplus/api.c
sr_dev_close(): Set status to SR_ST_INACTIVE.
[libsigrok.git] / src / hardware / ikalogic-scanaplus / api.c
index 30b62e3ca82fce1109639fe6cfe0cb91049b90de..79585f060dfc86f9d71209cd27f2567611bd7f82 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
  */
 
 #include <config.h>
@@ -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));
 
@@ -120,12 +111,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        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);
-
        /* Close device. We'll reopen it again when we need it. */
        scanaplus_close(devc);
 
-       return std_scan_complete(di, devices);
+       return std_scan_complete(di, g_slist_append(NULL, sdi));
 
        scanaplus_close(devc);
 err_free_ftdic:
@@ -218,33 +207,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,
@@ -272,9 +249,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) {
@@ -336,9 +310,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)
@@ -357,7 +328,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);
@@ -367,9 +338,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;
 }