]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/sysclk-lwla/protocol.c
Build: Include <config.h> first in all source files
[libsigrok.git] / src / hardware / sysclk-lwla / protocol.c
index 2fd4dffaa48bd46267d21d6dad3d57aae4b98bf6..ccabdddf4ca8d60faf3484a60ecf8a5e6f28515b 100644 (file)
@@ -17,8 +17,9 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "protocol.h"
+#include <config.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)
@@ -134,7 +135,7 @@ static int capture_setup(const struct sr_dev_inst *sdi)
        /* Fill remaining 64-bit words with zeroes. */
        memset(&command[27], 0, 16 * sizeof(uint16_t));
 
-       return lwla_send_command(sdi->conn, command, G_N_ELEMENTS(command));
+       return lwla_send_command(sdi->conn, command, ARRAY_SIZE(command));
 }
 
 /* Issue a register write command as an asynchronous USB transfer.
@@ -582,7 +583,7 @@ static void end_acquisition(struct sr_dev_inst *sdi)
        struct dev_context *devc;
        struct sr_datafeed_packet packet;
 
-       drvc = sdi->driver->priv;
+       drvc = sdi->driver->context;
        devc = sdi->priv;
 
        if (devc->state == STATE_IDLE)
@@ -604,7 +605,7 @@ static void end_acquisition(struct sr_dev_inst *sdi)
 
 /* USB output transfer completion callback.
  */
-static void receive_transfer_out(struct libusb_transfer *transfer)
+static void LIBUSB_CALL receive_transfer_out(struct libusb_transfer *transfer)
 {
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
@@ -658,7 +659,7 @@ static void receive_transfer_out(struct libusb_transfer *transfer)
 
 /* USB input transfer completion callback.
  */
-static void receive_transfer_in(struct libusb_transfer *transfer)
+static void LIBUSB_CALL receive_transfer_in(struct libusb_transfer *transfer)
 {
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
@@ -894,7 +895,7 @@ SR_PRIV int lwla_setup_acquisition(const struct sr_dev_inst *sdi)
        regvals[6].reg = REG_DIV_BYPASS;
        regvals[6].val = acq->bypass_clockdiv;
 
-       ret = lwla_write_regs(usb, regvals, G_N_ELEMENTS(regvals));
+       ret = lwla_write_regs(usb, regvals, ARRAY_SIZE(regvals));
        if (ret != SR_OK)
                return ret;
 
@@ -959,11 +960,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) {
@@ -1008,7 +1005,7 @@ SR_PRIV int lwla_receive_data(int fd, int revents, void *cb_data)
 
        sdi  = cb_data;
        devc = sdi->priv;
-       drvc = sdi->driver->priv;
+       drvc = sdi->driver->context;
 
        if (!devc || !drvc)
                return FALSE;