]> sigrok.org Git - libsigrok.git/commitdiff
rohde-schwarz-sme-0x: Coding style fixes
authorSoeren Apel <redacted>
Thu, 23 Feb 2017 16:33:47 +0000 (17:33 +0100)
committerSoeren Apel <redacted>
Sun, 26 Feb 2017 20:02:03 +0000 (21:02 +0100)
src/hardware/rohde-schwarz-sme-0x/api.c
src/hardware/rohde-schwarz-sme-0x/protocol.c
src/hardware/rohde-schwarz-sme-0x/protocol.h

index 59675c0cf1618b143b05537a1bc4872f5887ca9e..bc9f807349f29f7e5a5249ff20ead26723a397d0 100644 (file)
 
 SR_PRIV struct sr_dev_driver rohde_schwarz_sme_0x_driver_info;
 
-static const char * manufacturer = "Rohde&Schwarz";
-
-static const struct rs_device_model device_models[] = {{
-       .model_str = "SME02",
-       .freq_max = SR_GHZ(1.5),
-       .freq_min = SR_KHZ(5),
-       .power_max = 16,
-       .power_min = -144
-}, {
-       .model_str = "SME03E",
-       .freq_max = SR_GHZ(2.2),
-       .freq_min = SR_KHZ(5),
-       .power_max = 16,
-       .power_min = -144
-}, {
-       .model_str = "SME03A",
-       .freq_max = SR_GHZ(3),
-       .freq_min = SR_KHZ(5),
-       .power_max = 16,
-       .power_min = -144
-}, {
-       .model_str = "SME03",
-       .freq_max = SR_GHZ(3),
-       .freq_min = SR_KHZ(5),
-       .power_max = 16,
-       .power_min = -144
-}, {
-       .model_str = "SME06",
-       .freq_max = SR_GHZ(1.5),
-       .freq_min = SR_KHZ(5),
-       .power_max = 16,
-       .power_min = -144
-}};
+static const char *manufacturer = "Rohde&Schwarz";
+
+static const struct rs_device_model device_models[] = {
+       {
+               .model_str = "SME02",
+               .freq_max = SR_GHZ(1.5),
+               .freq_min = SR_KHZ(5),
+               .power_max = 16,
+               .power_min = -144
+       },
+       {
+               .model_str = "SME03E",
+               .freq_max = SR_GHZ(2.2),
+               .freq_min = SR_KHZ(5),
+               .power_max = 16,
+               .power_min = -144
+       },
+       {
+               .model_str = "SME03A",
+               .freq_max = SR_GHZ(3),
+               .freq_min = SR_KHZ(5),
+               .power_max = 16,
+               .power_min = -144
+       },
+       {
+               .model_str = "SME03",
+               .freq_max = SR_GHZ(3),
+               .freq_min = SR_KHZ(5),
+               .power_max = 16,
+               .power_min = -144
+       },
+       {
+               .model_str = "SME06",
+               .freq_max = SR_GHZ(1.5),
+               .freq_min = SR_KHZ(5),
+               .power_max = 16,
+               .power_min = -144
+       }
+};
 
 static const uint32_t scanopts[] = {
        SR_CONF_CONN,
@@ -70,15 +76,6 @@ static const uint32_t devopts[] = {
        SR_CONF_AMPLITUDE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
 };
 
-static int check_manufacturer(const char *str)
-{
-       if (!strcmp(str, manufacturer)) {
-               return SR_OK;
-       }
-
-       return SR_ERR;
-}
-
 static int rs_init_device(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
@@ -119,7 +116,7 @@ static struct sr_dev_inst *rs_probe_serial_device(struct sr_scpi_dev_inst *scpi)
                goto fail;
        }
 
-       if (check_manufacturer(hw_info->manufacturer) != SR_OK) {
+       if (strcmp(hw_info->manufacturer, manufacturer) != 0) {
                goto fail;
        }
 
@@ -169,7 +166,7 @@ static int dev_clear(const struct sr_dev_driver *di)
 
 static int dev_open(struct sr_dev_inst *sdi)
 {
-       if (sdi->status != SR_ST_ACTIVE && sr_scpi_open(sdi->conn) != SR_OK) {
+       if ((sdi->status != SR_ST_ACTIVE) && (sr_scpi_open(sdi->conn) != SR_OK)) {
                return SR_ERR;
        }
 
index 8a4a9b7157e368b12c45f88c11b33de828b5df6c..0235ce8a352cb4632e23d9e117f8605186355217 100644 (file)
@@ -31,7 +31,7 @@ enum {
        RS_CMD_GET_POWER
 };
 
-static char * commands[] = {
+static char *commands[] = {
        [RS_CMD_CONTROL_REMOTE] = "\n",
        [RS_CMD_SET_FREQ] = "FREQ %.1fHz",
        [RS_CMD_SET_POWER] = "POW %.1fdBm",
@@ -43,7 +43,7 @@ SR_PRIV int rs_sme0x_mode_remote(struct sr_scpi_dev_inst *scpi) {
        return sr_scpi_send(scpi, commands[RS_CMD_CONTROL_REMOTE]);
 }
 
-SR_PRIV int rs_sme0x_get_freq(const struct sr_dev_inst *sdi, double * freq) {
+SR_PRIV int rs_sme0x_get_freq(const struct sr_dev_inst *sdi, double *freq) {
        if (sr_scpi_get_double(sdi->conn, commands[RS_CMD_GET_FREQ], freq) != SR_OK) {
                return SR_ERR;
        }
@@ -51,7 +51,7 @@ SR_PRIV int rs_sme0x_get_freq(const struct sr_dev_inst *sdi, double * freq) {
        return SR_OK;
 }
 
-SR_PRIV int rs_sme0x_get_power(const struct sr_dev_inst *sdi, double * power) {
+SR_PRIV int rs_sme0x_get_power(const struct sr_dev_inst *sdi, double *power) {
        if (sr_scpi_get_double(sdi->conn, commands[RS_CMD_GET_POWER], power) != SR_OK) {
                return SR_ERR;
        }
@@ -66,7 +66,7 @@ SR_PRIV int rs_sme0x_set_freq(const struct sr_dev_inst *sdi, double freq) {
        devc = sdi->priv;
        config = devc->model_config;
 
-       if (freq > config->freq_max || freq < config->freq_min) {
+       if ((freq > config->freq_max) || (freq < config->freq_min)) {
                return SR_ERR_ARG;
        }
 
@@ -80,7 +80,7 @@ SR_PRIV int rs_sme0x_set_power(const struct sr_dev_inst *sdi, double power) {
        devc = sdi->priv;
        config = devc->model_config;
 
-       if (power > config->power_max || power < config->power_min) {
+       if ((power > config->power_max) || (power < config->power_min)) {
                return SR_ERR_ARG;
        }
 
index f3f4fb5119dc6caa4acf3c89e8a303978f88c13e..5310a2b0761d302e0038f6ea05d692d53200d176 100644 (file)
@@ -34,7 +34,7 @@ struct rs_sme0x_info {
 };
 
 struct rs_device_model {
-       const char * model_str;
+       const char *model_str;
        double freq_max;
        double freq_min;
        double power_max;
@@ -44,14 +44,14 @@ struct rs_device_model {
 /** Private, per-device-instance driver context. */
 struct dev_context {
        /* Model-specific information */
-       const struct rs_device_model * model_config;
+       const struct rs_device_model *model_config;
 };
 
 SR_PRIV int rs_sme0x_receive_data(int fd, int revents, void *cb_data);
 SR_PRIV int rs_sme0x_mode_remote(struct sr_scpi_dev_inst *scpi);
 SR_PRIV int rs_sme0x_close(struct sr_dev_inst *sdi);
-SR_PRIV int rs_sme0x_get_freq(const struct sr_dev_inst *sdi, double * freq);
-SR_PRIV int rs_sme0x_get_power(const struct sr_dev_inst *sdi, double * power);
+SR_PRIV int rs_sme0x_get_freq(const struct sr_dev_inst *sdi, double *freq);
+SR_PRIV int rs_sme0x_get_power(const struct sr_dev_inst *sdi, double *power);
 SR_PRIV int rs_sme0x_set_freq(const struct sr_dev_inst *sdi, double freq);
 SR_PRIV int rs_sme0x_set_power(const struct sr_dev_inst *sdi, double power);