]> sigrok.org Git - libsigrok.git/commitdiff
std: Factor out std_dummy_set_params().
authorUwe Hermann <redacted>
Thu, 20 Jun 2019 15:50:35 +0000 (17:50 +0200)
committerUwe Hermann <redacted>
Thu, 20 Jun 2019 15:56:29 +0000 (17:56 +0200)
src/libsigrok-internal.h
src/serial_bt.c
src/serial_hid_bu86x.c
src/serial_hid_victor.c
src/std.c

index 20674cdfedfe3b30d5109e287319520ee033c648..adbc79f26c75b0fdec77247c4917a8c560adc06c 100644 (file)
@@ -1087,6 +1087,10 @@ SR_PRIV int std_double_tuple_idx_d0(const double d, const double a[][2], unsigne
 
 SR_PRIV int std_cg_idx(const struct sr_channel_group *cg, struct sr_channel_group *a[], unsigned int n);
 
+SR_PRIV int std_dummy_set_params(struct sr_serial_dev_inst *serial,
+       int baudrate, int bits, int parity, int stopbits,
+       int flowcontrol, int rts, int dtr);
+
 /*--- resource.c ------------------------------------------------------------*/
 
 SR_PRIV int64_t sr_file_get_size(FILE *file);
index 8ed4523b8167ee1f42686d1ff9309f3b0f9c8c8f..678a0ce22c2c17568b26c2661bffe416efc2cc4b 100644 (file)
@@ -574,28 +574,6 @@ static int ser_bt_read(struct sr_serial_dev_inst *serial,
        return sr_ser_unqueue_rx_data(serial, buf, dlen);
 }
 
-static int ser_bt_set_params(struct sr_serial_dev_inst *serial,
-               int baudrate, int bits, int parity, int stopbits,
-               int flowcontrol, int rts, int dtr)
-{
-       /*
-        * Bluetooth communication has no concept of bitrate, so ignore
-        * these arguments silently. Neither need we pass the frame format
-        * down to internal BT comm routines, nor need we keep the values
-        * here, since the caller will cache/register them already.
-        */
-       (void)serial;
-       (void)baudrate;
-       (void)bits;
-       (void)parity;
-       (void)stopbits;
-       (void)flowcontrol;
-       (void)rts;
-       (void)dtr;
-
-       return SR_OK;
-}
-
 struct bt_source_args_t {
        /* The application callback. */
        sr_receive_data_callback cb;
@@ -835,7 +813,13 @@ static struct ser_lib_functions serlib_bt = {
        .drain = ser_bt_drain,
        .write = ser_bt_write,
        .read = ser_bt_read,
-       .set_params = ser_bt_set_params,
+       /*
+        * Bluetooth communication has no concept of bitrate, so ignore
+        * these arguments silently. Neither need we pass the frame format
+        * down to internal BT comm routines, nor need we keep the values
+        * here, since the caller will cache/register them already.
+        */
+       .set_params = std_dummy_set_params,
        .setup_source_add = ser_bt_setup_source_add,
        .setup_source_remove = ser_bt_setup_source_remove,
        .list = ser_bt_list,
index 32fa8f216b7742f6bbdf9052123ef5b556a68ce8..4009c3347a1ba84cdc84387adfbecfab53a4b130 100644 (file)
@@ -60,26 +60,6 @@ static const struct vid_pid_item vid_pid_items_bu86x[] = {
        ALL_ZERO
 };
 
-static int bu86x_set_params(struct sr_serial_dev_inst *serial,
-       int baudrate, int bits, int parity, int stopbits,
-       int flowcontrol, int rts, int dtr)
-{
-       /*
-        * The IR adapter's communication parameters are fixed and need
-        * not get configured. Just silently ignore the caller's spec.
-        */
-       (void)serial;
-       (void)baudrate;
-       (void)bits;
-       (void)parity;
-       (void)stopbits;
-       (void)flowcontrol;
-       (void)rts;
-       (void)dtr;
-
-       return SR_OK;
-}
-
 static int bu86x_read_bytes(struct sr_serial_dev_inst *serial,
        uint8_t *data, int space, unsigned int timeout)
 {
@@ -108,7 +88,11 @@ static struct ser_hid_chip_functions chip_bu86x = {
        .chipdesc = "Brymen BU-86X",
        .vid_pid_items = vid_pid_items_bu86x,
        .max_bytes_per_request = BU86X_MAX_BYTES_PER_REQUEST,
-       .set_params = bu86x_set_params,
+       /*
+        * The IR adapter's communication parameters are fixed and need
+        * not get configured. Just silently ignore the caller's spec.
+        */
+       .set_params = std_dummy_set_params,
        .read_bytes = bu86x_read_bytes,
        .write_bytes = bu86x_write_bytes,
 };
index 694cef27423b602301efddb0805d2a18fe19cf51..a304980eb853d2a2d4035d0f5da945c8189be68c 100644 (file)
@@ -60,26 +60,6 @@ static const struct vid_pid_item vid_pid_items_victor[] = {
        ALL_ZERO
 };
 
-static int victor_set_params(struct sr_serial_dev_inst *serial,
-       int baudrate, int bits, int parity, int stopbits,
-       int flowcontrol, int rts, int dtr)
-{
-       /*
-        * The USB HID connection has no concept of UART bitrate or
-        * frame format. Silently ignore the parameters.
-        */
-       (void)serial;
-       (void)baudrate;
-       (void)bits;
-       (void)parity;
-       (void)stopbits;
-       (void)flowcontrol;
-       (void)rts;
-       (void)dtr;
-
-       return SR_OK;
-}
-
 /* Reverse bits within a byte. */
 static uint8_t bit_reverse(uint8_t b)
 {
@@ -193,7 +173,11 @@ static struct ser_hid_chip_functions chip_victor = {
        .chipdesc = "Victor DMM scrambler",
        .vid_pid_items = vid_pid_items_victor,
        .max_bytes_per_request = VICTOR_DMM_PACKET_LENGTH,
-       .set_params = victor_set_params,
+       /*
+        * The USB HID connection has no concept of UART bitrate or
+        * frame format. Silently ignore the parameters.
+        */
+       .set_params = std_dummy_set_params,
        .read_bytes = victor_read_bytes,
        .write_bytes = victor_write_bytes,
 };
index b6a0fc9c768e4071f7505743cdccf27fb9813159..cd3bdd0b33de3f4ec296d1e84e7ca18d8bafa3be 100644 (file)
--- a/src/std.c
+++ b/src/std.c
@@ -937,3 +937,20 @@ SR_PRIV int std_cg_idx(const struct sr_channel_group *cg, struct sr_channel_grou
 
        return -1;
 }
+
+SR_PRIV int std_dummy_set_params(struct sr_serial_dev_inst *serial,
+       int baudrate, int bits, int parity, int stopbits,
+       int flowcontrol, int rts, int dtr)
+{
+       (void)serial;
+       (void)baudrate;
+       (void)bits;
+       (void)parity;
+       (void)stopbits;
+       (void)flowcontrol;
+       (void)rts;
+       (void)dtr;
+
+       return SR_OK;
+}
+