X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fsysclk-lwla%2Fprotocol.c;h=f22d80adea47ab7c8f22928e23423297fcea94f2;hb=025f6ed862b3a1dc8aa5deb3e44b4c2230ef3aa6;hp=c8434049a738e6736e2869e8a3a4aa0fd19ecfa5;hpb=f3f19d1131025b68d29a11273b627c83d748e7ea;p=libsigrok.git
diff --git a/src/hardware/sysclk-lwla/protocol.c b/src/hardware/sysclk-lwla/protocol.c
index c8434049..f22d80ad 100644
--- a/src/hardware/sysclk-lwla/protocol.c
+++ b/src/hardware/sysclk-lwla/protocol.c
@@ -17,8 +17,8 @@
* along with this program. If not, see .
*/
-#include "protocol.h"
#include
+#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;
@@ -134,7 +134,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 +582,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 +604,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 +658,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 +894,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;
@@ -923,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;
@@ -959,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) {
@@ -1008,7 +1004,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;