]> sigrok.org Git - libsigrok.git/commitdiff
rdtech-um: address style nits (whitespace, braces)
authorGerhard Sittig <redacted>
Wed, 15 Mar 2023 15:36:01 +0000 (16:36 +0100)
committerGerhard Sittig <redacted>
Thu, 16 Mar 2023 13:29:30 +0000 (14:29 +0100)
Eliminate excessive indentation and other whitespace nits. Alignment of
tables wasn't working anyway. Put braces around complex statements that
span multiple lines, or trim line length differently where appropriate.

src/hardware/rdtech-um/api.c
src/hardware/rdtech-um/protocol.c

index fbc38b1aadcbd1570608a7456bcb8d1fdce61367..a35c038cfa830ac4f86ccdc40a62452630d41ffd 100644 (file)
@@ -47,14 +47,16 @@ static const uint32_t devopts[] = {
        SR_CONF_LIMIT_MSEC | SR_CONF_SET,
 };
 
        SR_CONF_LIMIT_MSEC | SR_CONF_SET,
 };
 
-static GSList *rdtech_um_scan(struct sr_dev_driver *di, const char *conn,
-                             const char *serialcomm)
+static GSList *rdtech_um_scan(struct sr_dev_driver *di,
+       const char *conn, const char *serialcomm)
 {
        struct sr_serial_dev_inst *serial;
        const struct rdtech_um_profile *p = NULL;
        GSList *devices = NULL;
        struct dev_context *devc = NULL;
        struct sr_dev_inst *sdi = NULL;
 {
        struct sr_serial_dev_inst *serial;
        const struct rdtech_um_profile *p = NULL;
        GSList *devices = NULL;
        struct dev_context *devc = NULL;
        struct sr_dev_inst *sdi = NULL;
+       size_t ch_idx;
+       const char *name;
 
        serial = sr_serial_dev_inst_new(conn, serialcomm);
        if (serial_open(serial, SERIAL_RDWR) != SR_OK)
 
        serial = sr_serial_dev_inst_new(conn, serialcomm);
        if (serial_open(serial, SERIAL_RDWR) != SR_OK)
@@ -80,9 +82,8 @@ static GSList *rdtech_um_scan(struct sr_dev_driver *di, const char *conn,
        sdi->conn = serial;
        sdi->priv = devc;
 
        sdi->conn = serial;
        sdi->priv = devc;
 
-       for (int i = 0; p->channels[i].name; i++)
-               sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
-                              p->channels[i].name);
+       for (ch_idx = 0; (name = p->channels[ch_idx].name); ch_idx++)
+               sr_channel_new(sdi, ch_idx, SR_CHANNEL_ANALOG, TRUE, name);
 
        devices = g_slist_append(devices, sdi);
        serial_close(serial);
 
        devices = g_slist_append(devices, sdi);
        serial_close(serial);
@@ -123,7 +124,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 }
 
 static int config_set(uint32_t key, GVariant *data,
 }
 
 static int config_set(uint32_t key, GVariant *data,
-                     const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
 
 {
        struct dev_context *devc;
 
@@ -135,7 +136,7 @@ static int config_set(uint32_t key, GVariant *data,
 }
 
 static int config_list(uint32_t key, GVariant **data,
 }
 
 static int config_list(uint32_t key, GVariant **data,
-                      const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
 }
 {
        return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
 }
@@ -149,7 +150,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        std_session_send_df_header(sdi);
 
        serial_source_add(sdi->session, serial, G_IO_IN, 50,
        std_session_send_df_header(sdi);
 
        serial_source_add(sdi->session, serial, G_IO_IN, 50,
-                         rdtech_um_receive_data, (void *)sdi);
+               rdtech_um_receive_data, (void *)sdi);
 
        return rdtech_um_poll(sdi);
 }
 
        return rdtech_um_poll(sdi);
 }
index dd254362a388da30472cb7f73eb6cf2d7e8205f6..54416f6c1456f6a477ce3356a8e6ffacbe58e13e 100644 (file)
 #define UM_CMD_POLL 0xf0
 
 static const struct binary_analog_channel rdtech_default_channels[] = {
 #define UM_CMD_POLL 0xf0
 
 static const struct binary_analog_channel rdtech_default_channels[] = {
-       { "V",  { 2, BVT_BE_UINT16, 0.01, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
-       { "I",  { 4, BVT_BE_UINT16, 0.001, }, 3, SR_MQ_CURRENT, SR_UNIT_AMPERE },
+       { "V", { 2, BVT_BE_UINT16, 0.01, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
+       { "I", { 4, BVT_BE_UINT16, 0.001, }, 3, SR_MQ_CURRENT, SR_UNIT_AMPERE },
        { "D+", { 96, BVT_BE_UINT16, 0.01, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
        { "D-", { 98, BVT_BE_UINT16, 0.01, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
        { "D+", { 96, BVT_BE_UINT16, 0.01, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
        { "D-", { 98, BVT_BE_UINT16, 0.01, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
-       { "T", { 10, BVT_BE_UINT16, 1.0, },  0, SR_MQ_TEMPERATURE, SR_UNIT_CELSIUS },
+       { "T", { 10, BVT_BE_UINT16, 1.0, }, 0, SR_MQ_TEMPERATURE, SR_UNIT_CELSIUS },
        /* Threshold-based recording (mWh) */
        { "E", { 106, BVT_BE_UINT32, 0.001, }, 3, SR_MQ_ENERGY, SR_UNIT_WATT_HOUR },
        ALL_ZERO,
        /* Threshold-based recording (mWh) */
        { "E", { 106, BVT_BE_UINT32, 0.001, }, 3, SR_MQ_ENERGY, SR_UNIT_WATT_HOUR },
        ALL_ZERO,
@@ -107,7 +107,7 @@ SR_PRIV const struct rdtech_um_profile *rdtech_um_probe(struct sr_serial_dev_ins
        int len;
 
        if (serial_write_blocking(serial, &request, sizeof(request),
        int len;
 
        if (serial_write_blocking(serial, &request, sizeof(request),
-                                  SERIAL_WRITE_TIMEOUT_MS) < 0) {
+                       SERIAL_WRITE_TIMEOUT_MS) < 0) {
                sr_err("Unable to send probe request.");
                return NULL;
        }
                sr_err("Unable to send probe request.");
                return NULL;
        }
@@ -139,7 +139,7 @@ SR_PRIV int rdtech_um_poll(const struct sr_dev_inst *sdi)
        static const uint8_t request = UM_CMD_POLL;
 
        if (serial_write_blocking(serial, &request, sizeof(request),
        static const uint8_t request = UM_CMD_POLL;
 
        if (serial_write_blocking(serial, &request, sizeof(request),
-                                  SERIAL_WRITE_TIMEOUT_MS) < 0) {
+                       SERIAL_WRITE_TIMEOUT_MS) < 0) {
                sr_err("Unable to send poll request.");
                return SR_ERR;
        }
                sr_err("Unable to send poll request.");
                return SR_ERR;
        }
@@ -161,10 +161,11 @@ static void handle_poll_data(const struct sr_dev_inst *sdi)
                return;
        }
 
                return;
        }
 
-       for (ch = sdi->channels, i = 0; ch; ch = g_slist_next(ch), i++)
+       for (ch = sdi->channels, i = 0; ch; ch = g_slist_next(ch), i++) {
                bv_send_analog_channel(sdi, ch->data,
                bv_send_analog_channel(sdi, ch->data,
-                                      &devc->profile->channels[i],
-                                      devc->buf, devc->buflen);
+                       &devc->profile->channels[i],
+                       devc->buf, devc->buflen);
+       }
 
        sr_sw_limits_update_samples_read(&devc->limits, 1);
 }
 
        sr_sw_limits_update_samples_read(&devc->limits, 1);
 }