]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/sysclk-lwla/protocol.c
Various #include file cosmetic fixes.
[libsigrok.git] / src / hardware / sysclk-lwla / protocol.c
index f1ae8b3d5d1fe1c1b146fa5d41ddb3eeb0f7ad50..a8659a6b04082d98ba0801f72eff555c2fed3947 100644 (file)
@@ -17,8 +17,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "protocol.h"
 #include <string.h>
+#include "protocol.h"
 
 /* Bit mask for the RLE repeat-count-follows flag. */
 #define RLE_FLAG_LEN_FOLLOWS ((uint64_t)1 << 35)
@@ -65,7 +65,7 @@ static int capture_setup(const struct sr_dev_inst *sdi)
        uint64_t divider_count;
        uint64_t trigger_mask;
        uint64_t memory_limit;
-       uint16_t command[3 + 10*4];
+       uint16_t command[3 + (10 * 4)];
 
        devc = sdi->priv;
        acq  = devc->acquisition;
@@ -107,8 +107,12 @@ static int capture_setup(const struct sr_dev_inst *sdi)
        /* Set bits to select external TRG input edge. */
        if (devc->cfg_trigger_source == TRIGGER_EXT_TRG)
                switch (devc->cfg_trigger_slope) {
-               case EDGE_POSITIVE: trigger_mask |= (uint64_t)1 << 35; break; 
-               case EDGE_NEGATIVE: trigger_mask |= (uint64_t)1 << 34; break; 
+               case EDGE_POSITIVE:
+                       trigger_mask |= (uint64_t)1 << 35;
+                       break; 
+               case EDGE_NEGATIVE:
+                       trigger_mask |= (uint64_t)1 << 34;
+                       break; 
                }
 
        command[19] = LWLA_WORD_0(trigger_mask);
@@ -279,7 +283,7 @@ static void issue_read_end(const struct sr_dev_inst *sdi)
                devc->state = STATE_READ_END;
 }
 
-/* Decode an incoming reponse to a buffer fill level request and act on it
+/* Decode an incoming response to a buffer fill level request and act on it
  * as appropriate.  Note that this function changes the device context state.
  */
 static void process_capture_length(const struct sr_dev_inst *sdi)
@@ -346,7 +350,7 @@ static void issue_stop_capture(const struct sr_dev_inst *sdi)
        }
 }
 
-/* Decode an incoming capture status reponse and act on it as appropriate.
+/* Decode an incoming capture status response and act on it as appropriate.
  * Note that this function changes the device state.
  */
 static void process_capture_status(const struct sr_dev_inst *sdi)
@@ -768,7 +772,7 @@ SR_PRIV int lwla_convert_trigger(const struct sr_dev_inst *sdi)
                        if (!match->channel->enabled)
                                /* Ignore disabled channels with a trigger. */
                                continue;
-                       channel_index = 1 << match->channel->index;
+                       channel_index = (uint64_t)1 << match->channel->index;
                        devc->trigger_mask |= channel_index;
                        switch (match->match) {
                        case SR_TRIGGER_ONE:
@@ -919,13 +923,13 @@ SR_PRIV int lwla_start_acquisition(const struct sr_dev_inst *sdi)
        libusb_fill_bulk_transfer(acq->xfer_out, usb->devhdl, EP_COMMAND,
                                  (unsigned char *)acq->xfer_buf_out, 0,
                                  &receive_transfer_out,
-                                 (struct sr_dev_inst *)sdi, USB_TIMEOUT);
+                                 (struct sr_dev_inst *)sdi, USB_TIMEOUT_MS);
 
        libusb_fill_bulk_transfer(acq->xfer_in, usb->devhdl, EP_REPLY,
                                  (unsigned char *)acq->xfer_buf_in,
                                  sizeof acq->xfer_buf_in,
                                  &receive_transfer_in,
-                                 (struct sr_dev_inst *)sdi, USB_TIMEOUT);
+                                 (struct sr_dev_inst *)sdi, USB_TIMEOUT_MS);
 
        regvals = devc->reg_write_seq;
 
@@ -955,11 +959,7 @@ SR_PRIV struct acquisition_state *lwla_alloc_acquisition_state(void)
 {
        struct acquisition_state *acq;
 
-       acq = g_try_new0(struct acquisition_state, 1);
-       if (!acq) {
-               sr_err("Acquisition state malloc failed.");
-               return NULL;
-       }
+       acq = g_malloc0(sizeof(struct acquisition_state));
 
        acq->xfer_in = libusb_alloc_transfer(0);
        if (!acq->xfer_in) {