From: Uwe Hermann Date: Sun, 18 Feb 2018 22:14:51 +0000 (+0100) Subject: hp-3478a: Shorten some functions. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=04c4a6776fe6abe3dc8138d273b0caf4e72237f8;p=libsigrok.git hp-3478a: Shorten some functions. --- diff --git a/src/hardware/hp-3478a/api.c b/src/hardware/hp-3478a/api.c index 84db3180..edc16fc8 100644 --- a/src/hardware/hp-3478a/api.c +++ b/src/hardware/hp-3478a/api.c @@ -104,25 +104,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) static int dev_open(struct sr_dev_inst *sdi) { - struct sr_scpi_dev_inst *scpi; - - scpi = sdi->conn; - - if (sr_scpi_open(scpi) != SR_OK) - return SR_ERR; - - return SR_OK; + return sr_scpi_open(sdi->conn); } static int dev_close(struct sr_dev_inst *sdi) { - struct sr_scpi_dev_inst *scpi; - - scpi = sdi->conn; - - sr_scpi_close(scpi); - - return SR_OK; + return sr_scpi_close(sdi->conn); } static int config_get(uint32_t key, GVariant **data, @@ -241,12 +228,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) /* Get device status. */ hp_3478a_get_status_bytes(sdi); - ret = sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 100, + return sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 100, hp_3478a_receive_data, (void *)sdi); - if (ret != SR_OK) - return ret; - - return SR_OK; } static int dev_acquisition_stop(struct sr_dev_inst *sdi) diff --git a/src/hardware/hp-3478a/protocol.c b/src/hardware/hp-3478a/protocol.c index 2871db76..de384219 100644 --- a/src/hardware/hp-3478a/protocol.c +++ b/src/hardware/hp-3478a/protocol.c @@ -38,46 +38,27 @@ static const struct { static int set_mq_volt(struct sr_scpi_dev_inst *scpi, enum sr_mqflag flags) { - const char *cmd; - if ((flags & SR_MQFLAG_AC) != SR_MQFLAG_AC && (flags & SR_MQFLAG_DC) != SR_MQFLAG_DC) return SR_ERR_NA; - if ((flags & SR_MQFLAG_AC) == SR_MQFLAG_AC) - cmd = "F2"; - else - cmd = "F1"; - - return sr_scpi_send(scpi, "%s", cmd); + return sr_scpi_send(scpi, "%s", + ((flags & SR_MQFLAG_AC) == SR_MQFLAG_AC) ? "F2" : "F1"); } static int set_mq_amp(struct sr_scpi_dev_inst *scpi, enum sr_mqflag flags) { - const char *cmd; - if ((flags & SR_MQFLAG_AC) != SR_MQFLAG_AC && (flags & SR_MQFLAG_DC) != SR_MQFLAG_DC) return SR_ERR_NA; - if (flags & SR_MQFLAG_AC) - cmd = "F6"; - else - cmd = "F5"; - - return sr_scpi_send(scpi, "%s", cmd); + return sr_scpi_send(scpi, "%s", (flags & SR_MQFLAG_AC) ? "F6" : "F5"); } static int set_mq_ohm(struct sr_scpi_dev_inst *scpi, enum sr_mqflag flags) { - const char *cmd; - - if (flags & SR_MQFLAG_FOUR_WIRE) - cmd = "F4"; - else - cmd = "F3"; - - return sr_scpi_send(scpi, "%s", cmd); + return sr_scpi_send(scpi, "%s", + (flags & SR_MQFLAG_FOUR_WIRE) ? "F4" : "F3"); } SR_PRIV int hp_3478a_set_mq(const struct sr_dev_inst *sdi, enum sr_mq mq,