aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoeren Apel <soeren@apelpie.net>2017-02-23 17:33:47 +0100
committerSoeren Apel <soeren@apelpie.net>2017-02-26 21:02:03 +0100
commit9e50659470cb7a34fddeaf27a73a07e5f15e933d (patch)
treed8fe85d745d176cbc6e0036463b3bf76c9eca302
parenta28b3df111ce6b942d0904b7647b959a48f2b479 (diff)
rohde-schwarz-sme-0x: Coding style fixes
-rw-r--r--src/hardware/rohde-schwarz-sme-0x/api.c85
-rw-r--r--src/hardware/rohde-schwarz-sme-0x/protocol.c10
-rw-r--r--src/hardware/rohde-schwarz-sme-0x/protocol.h8
3 files changed, 50 insertions, 53 deletions
diff --git a/src/hardware/rohde-schwarz-sme-0x/api.c b/src/hardware/rohde-schwarz-sme-0x/api.c
index 59675c0..bc9f807 100644
--- a/src/hardware/rohde-schwarz-sme-0x/api.c
+++ b/src/hardware/rohde-schwarz-sme-0x/api.c
@@ -26,39 +26,45 @@
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;
}
diff --git a/src/hardware/rohde-schwarz-sme-0x/protocol.c b/src/hardware/rohde-schwarz-sme-0x/protocol.c
index 8a4a9b7..0235ce8 100644
--- a/src/hardware/rohde-schwarz-sme-0x/protocol.c
+++ b/src/hardware/rohde-schwarz-sme-0x/protocol.c
@@ -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;
}
diff --git a/src/hardware/rohde-schwarz-sme-0x/protocol.h b/src/hardware/rohde-schwarz-sme-0x/protocol.h
index f3f4fb5..5310a2b 100644
--- a/src/hardware/rohde-schwarz-sme-0x/protocol.h
+++ b/src/hardware/rohde-schwarz-sme-0x/protocol.h
@@ -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);