]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/beaglelogic/api.c
drivers: Fix behaviour when trying to set an invalid capture ratio.
[libsigrok.git] / src / hardware / beaglelogic / api.c
index 12af5c1db6660891406128b93879f8409ced74fd..b974010468f38dfb440198c150fe6bcb7e486286 100644 (file)
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include "protocol.h"
 #include "beaglelogic.h"
 
@@ -165,6 +166,7 @@ static int dev_open(struct sr_dev_inst *sdi)
        /* Set fd and local attributes */
        devc->pollfd.fd = devc->fd;
        devc->pollfd.events = G_IO_IN;
+       devc->pollfd.revents = 0;
 
        /* Get the default attributes */
        beaglelogic_get_samplerate(devc);
@@ -282,10 +284,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                return beaglelogic_set_triggerflags(devc);
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
-               if (devc->capture_ratio > 100) {
-                       devc->capture_ratio = 0;
+               if (devc->capture_ratio > 100)
                        return SR_ERR;
-               }
                return SR_OK;
        default:
                return SR_ERR_NA;