rohde-schwarz-sme-0x: Coding style fixes

This commit is contained in:
Soeren Apel 2017-02-23 17:33:47 +01:00
parent a28b3df111
commit 9e50659470
3 changed files with 49 additions and 52 deletions

View File

@ -26,39 +26,45 @@
SR_PRIV struct sr_dev_driver rohde_schwarz_sme_0x_driver_info; SR_PRIV struct sr_dev_driver rohde_schwarz_sme_0x_driver_info;
static const char * manufacturer = "Rohde&Schwarz"; static const char *manufacturer = "Rohde&Schwarz";
static const struct rs_device_model device_models[] = {{ static const struct rs_device_model device_models[] = {
.model_str = "SME02", {
.freq_max = SR_GHZ(1.5), .model_str = "SME02",
.freq_min = SR_KHZ(5), .freq_max = SR_GHZ(1.5),
.power_max = 16, .freq_min = SR_KHZ(5),
.power_min = -144 .power_max = 16,
}, { .power_min = -144
.model_str = "SME03E", },
.freq_max = SR_GHZ(2.2), {
.freq_min = SR_KHZ(5), .model_str = "SME03E",
.power_max = 16, .freq_max = SR_GHZ(2.2),
.power_min = -144 .freq_min = SR_KHZ(5),
}, { .power_max = 16,
.model_str = "SME03A", .power_min = -144
.freq_max = SR_GHZ(3), },
.freq_min = SR_KHZ(5), {
.power_max = 16, .model_str = "SME03A",
.power_min = -144 .freq_max = SR_GHZ(3),
}, { .freq_min = SR_KHZ(5),
.model_str = "SME03", .power_max = 16,
.freq_max = SR_GHZ(3), .power_min = -144
.freq_min = SR_KHZ(5), },
.power_max = 16, {
.power_min = -144 .model_str = "SME03",
}, { .freq_max = SR_GHZ(3),
.model_str = "SME06", .freq_min = SR_KHZ(5),
.freq_max = SR_GHZ(1.5), .power_max = 16,
.freq_min = SR_KHZ(5), .power_min = -144
.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[] = { static const uint32_t scanopts[] = {
SR_CONF_CONN, SR_CONF_CONN,
@ -70,15 +76,6 @@ static const uint32_t devopts[] = {
SR_CONF_AMPLITUDE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, 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) static int rs_init_device(struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; 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; goto fail;
} }
if (check_manufacturer(hw_info->manufacturer) != SR_OK) { if (strcmp(hw_info->manufacturer, manufacturer) != 0) {
goto fail; 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) 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; return SR_ERR;
} }

View File

@ -31,7 +31,7 @@ enum {
RS_CMD_GET_POWER RS_CMD_GET_POWER
}; };
static char * commands[] = { static char *commands[] = {
[RS_CMD_CONTROL_REMOTE] = "\n", [RS_CMD_CONTROL_REMOTE] = "\n",
[RS_CMD_SET_FREQ] = "FREQ %.1fHz", [RS_CMD_SET_FREQ] = "FREQ %.1fHz",
[RS_CMD_SET_POWER] = "POW %.1fdBm", [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]); 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) { if (sr_scpi_get_double(sdi->conn, commands[RS_CMD_GET_FREQ], freq) != SR_OK) {
return SR_ERR; 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; 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) { if (sr_scpi_get_double(sdi->conn, commands[RS_CMD_GET_POWER], power) != SR_OK) {
return SR_ERR; 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; devc = sdi->priv;
config = devc->model_config; 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; 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; devc = sdi->priv;
config = devc->model_config; 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; return SR_ERR_ARG;
} }

View File

@ -34,7 +34,7 @@ struct rs_sme0x_info {
}; };
struct rs_device_model { struct rs_device_model {
const char * model_str; const char *model_str;
double freq_max; double freq_max;
double freq_min; double freq_min;
double power_max; double power_max;
@ -44,14 +44,14 @@ struct rs_device_model {
/** Private, per-device-instance driver context. */ /** Private, per-device-instance driver context. */
struct dev_context { struct dev_context {
/* Model-specific information */ /* 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_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_mode_remote(struct sr_scpi_dev_inst *scpi);
SR_PRIV int rs_sme0x_close(struct sr_dev_inst *sdi); 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_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_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_freq(const struct sr_dev_inst *sdi, double freq);
SR_PRIV int rs_sme0x_set_power(const struct sr_dev_inst *sdi, double power); SR_PRIV int rs_sme0x_set_power(const struct sr_dev_inst *sdi, double power);