]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/sysclk-lwla/protocol.c
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / hardware / sysclk-lwla / protocol.c
index 986aa6121d55a57877ef71c99371811193ab487a..45c0795210629e812f25981425a95b9666795447 100644 (file)
@@ -22,8 +22,7 @@
 #include "protocol.h"
 #include "lwla.h"
 
-/* Submit an already filled-in USB transfer.
- */
+/* Submit an already filled-in USB transfer. */
 static int submit_transfer(struct dev_context *devc,
                           struct libusb_transfer *xfer)
 {
@@ -40,8 +39,7 @@ static int submit_transfer(struct dev_context *devc,
        return SR_OK;
 }
 
-/* Set up transfer for the next register in a write sequence.
- */
+/* Set up transfer for the next register in a write sequence. */
 static void next_reg_write(struct acquisition_state *acq)
 {
        struct regval *regval;
@@ -56,8 +54,7 @@ static void next_reg_write(struct acquisition_state *acq)
        acq->xfer_out->length = 4 * sizeof(acq->xfer_buf_out[0]);
 }
 
-/* Set up transfer for the next register in a read sequence.
- */
+/* Set up transfer for the next register in a read sequence. */
 static void next_reg_read(struct acquisition_state *acq)
 {
        unsigned int addr;
@@ -70,8 +67,7 @@ static void next_reg_read(struct acquisition_state *acq)
        acq->xfer_out->length = 2 * sizeof(acq->xfer_buf_out[0]);
 }
 
-/* Decode the response to a register read request.
- */
+/* Decode the response to a register read request. */
 static int read_reg_response(struct acquisition_state *acq)
 {
        uint32_t value;
@@ -87,8 +83,7 @@ static int read_reg_response(struct acquisition_state *acq)
        return SR_OK;
 }
 
-/* Enter a new state and submit the corresponding request to the device.
- */
+/* Enter a new state and submit the corresponding request to the device. */
 static int submit_request(const struct sr_dev_inst *sdi,
                          enum protocol_state state)
 {
@@ -97,7 +92,7 @@ static int submit_request(const struct sr_dev_inst *sdi,
        int ret;
 
        devc = sdi->priv;
-       acq  = devc->acquisition;
+       acq = devc->acquisition;
 
        devc->state = state;
 
@@ -123,8 +118,7 @@ static int submit_request(const struct sr_dev_inst *sdi,
        return submit_transfer(devc, acq->xfer_out);
 }
 
-/* Evaluate and act on the response to a capture status request.
- */
+/* Evaluate and act on the response to a capture status request. */
 static void handle_status_response(const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
@@ -132,7 +126,7 @@ static void handle_status_response(const struct sr_dev_inst *sdi)
        unsigned int old_status;
 
        devc = sdi->priv;
-       acq  = devc->acquisition;
+       acq = devc->acquisition;
        old_status = acq->status;
 
        if ((*devc->model->handle_response)(sdi) != SR_OK) {
@@ -160,15 +154,14 @@ static void handle_status_response(const struct sr_dev_inst *sdi)
        }
 }
 
-/* Evaluate and act on the response to a capture length request.
- */
+/* Evaluate and act on the response to a capture length request. */
 static void handle_length_response(const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
        struct acquisition_state *acq;
 
        devc = sdi->priv;
-       acq  = devc->acquisition;
+       acq = devc->acquisition;
 
        if ((*devc->model->handle_response)(sdi) != SR_OK) {
                devc->transfer_error = TRUE;
@@ -191,8 +184,7 @@ static void handle_length_response(const struct sr_dev_inst *sdi)
        submit_request(sdi, STATE_READ_PREPARE);
 }
 
-/* Evaluate and act on the response to a capture memory read request.
- */
+/* Evaluate and act on the response to a capture memory read request. */
 static void handle_read_response(const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
@@ -202,13 +194,13 @@ static void handle_read_response(const struct sr_dev_inst *sdi)
        unsigned int end_addr;
 
        devc = sdi->priv;
-       acq  = devc->acquisition;
+       acq = devc->acquisition;
 
        /* Prepare session packet. */
-       packet.type    = SR_DF_LOGIC;
+       packet.type = SR_DF_LOGIC;
        packet.payload = &logic;
        logic.unitsize = (devc->model->num_channels + 7) / 8;
-       logic.data     = acq->out_packet;
+       logic.data = acq->out_packet;
 
        end_addr = MIN(acq->mem_addr_next, acq->mem_addr_stop);
        acq->in_index = 0;
@@ -250,15 +242,14 @@ static void handle_read_response(const struct sr_dev_inst *sdi)
        submit_request(sdi, STATE_READ_FINISH);
 }
 
-/* Destroy and unset the acquisition state record.
- */
+/* Destroy and unset the acquisition state record. */
 static void clear_acquisition_state(const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
        struct acquisition_state *acq;
 
        devc = sdi->priv;
-       acq  = devc->acquisition;
+       acq = devc->acquisition;
 
        devc->acquisition = NULL;
 
@@ -269,8 +260,7 @@ static void clear_acquisition_state(const struct sr_dev_inst *sdi)
        }
 }
 
-/* USB I/O source callback.
- */
+/* USB I/O source callback. */
 static int transfer_event(int fd, int revents, void *cb_data)
 {
        const struct sr_dev_inst *sdi;
@@ -281,7 +271,7 @@ static int transfer_event(int fd, int revents, void *cb_data)
 
        (void)fd;
 
-       sdi  = cb_data;
+       sdi = cb_data;
        devc = sdi->priv;
        drvc = sdi->driver->context;
 
@@ -289,7 +279,7 @@ static int transfer_event(int fd, int revents, void *cb_data)
                return G_SOURCE_REMOVE;
 
        /* Handle pending USB events without blocking. */
-       tv.tv_sec  = 0;
+       tv.tv_sec = 0;
        tv.tv_usec = 0;
        ret = libusb_handle_events_timeout_completed(drvc->sr_ctx->libusb_ctx,
                                                     &tv, NULL);
@@ -321,17 +311,16 @@ static int transfer_event(int fd, int revents, void *cb_data)
        return G_SOURCE_REMOVE;
 }
 
-/* USB output transfer completion callback.
- */
+/* USB output transfer completion callback. */
 static void LIBUSB_CALL transfer_out_completed(struct libusb_transfer *transfer)
 {
        const struct sr_dev_inst *sdi;
        struct dev_context *devc;
        struct acquisition_state *acq;
 
-       sdi  = transfer->user_data;
+       sdi = transfer->user_data;
        devc = sdi->priv;
-       acq  = devc->acquisition;
+       acq = devc->acquisition;
 
        if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
                sr_err("Transfer to device failed (state %d): %s.",
@@ -386,17 +375,16 @@ static void LIBUSB_CALL transfer_out_completed(struct libusb_transfer *transfer)
        }
 }
 
-/* USB input transfer completion callback.
- */
+/* USB input transfer completion callback. */
 static void LIBUSB_CALL transfer_in_completed(struct libusb_transfer *transfer)
 {
        const struct sr_dev_inst *sdi;
        struct dev_context *devc;
        struct acquisition_state *acq;
 
-       sdi  = transfer->user_data;
+       sdi = transfer->user_data;
        devc = sdi->priv;
-       acq  = devc->acquisition;
+       acq = devc->acquisition;
 
        if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
                sr_err("Transfer from device failed (state %d): %s.",
@@ -448,8 +436,7 @@ static void LIBUSB_CALL transfer_in_completed(struct libusb_transfer *transfer)
        }
 }
 
-/* Set up the acquisition state record.
- */
+/* Set up the acquisition state record. */
 static int init_acquisition_state(const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
@@ -457,7 +444,7 @@ static int init_acquisition_state(const struct sr_dev_inst *sdi)
        struct acquisition_state *acq;
 
        devc = sdi->priv;
-       usb  = sdi->conn;
+       usb = sdi->conn;
 
        if (devc->acquisition) {
                sr_err("Acquisition still in progress?");