X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fpipistrello-ols%2Fprotocol.c;h=1d0c9f208839200ee97c5de38fc66d479b55f187;hb=16aca7661b7ab34a399c323bb9214721e2b1be0c;hp=750303d019eba164cb3fb608d3691a0851c96bf2;hpb=acc885c7553d12ce18d45fc603ebf7d0c188db09;p=libsigrok.git diff --git a/src/hardware/pipistrello-ols/protocol.c b/src/hardware/pipistrello-ols/protocol.c index 750303d0..1d0c9f20 100644 --- a/src/hardware/pipistrello-ols/protocol.c +++ b/src/hardware/pipistrello-ols/protocol.c @@ -219,14 +219,14 @@ SR_PRIV int pols_convert_trigger(const struct sr_dev_inst *sdi) SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, struct dev_context *devc) { struct sr_dev_inst *sdi; - struct sr_channel *ch; uint32_t tmp_int, ui; uint8_t key, type, token; GString *tmp_str, *devname, *version; guchar tmp_c; int index, i; - sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, NULL, NULL, NULL); + sdi = g_malloc0(sizeof(struct sr_dev_inst)); + sdi->status = SR_ST_INACTIVE; sdi->driver = di; sdi->priv = devc; @@ -287,12 +287,9 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str switch (token) { case 0x00: /* Number of usable channels */ - for (ui = 0; ui < tmp_int; ui++) { - if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE, - p_ols_channel_names[ui]))) - return 0; - sdi->channels = g_slist_append(sdi->channels, ch); - } + for (ui = 0; ui < tmp_int; ui++) + sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE, + p_ols_channel_names[ui]); break; case 0x01: /* Amount of sample memory available (bytes) */ @@ -324,12 +321,9 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str switch (token) { case 0x00: /* Number of usable channels */ - for (ui = 0; ui < tmp_c; ui++) { - if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE, - p_ols_channel_names[ui]))) - return 0; - sdi->channels = g_slist_append(sdi->channels, ch); - } + for (ui = 0; ui < tmp_c; ui++) + sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE, + p_ols_channel_names[ui]); break; case 0x01: /* protocol version */ @@ -428,7 +422,6 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) num_channels++; } } - sr_dbg("num_channels = %d", num_channels); /* Get a block of data. */ bytes_read = ftdi_read_data(devc->ftdic, devc->ftdi_buf, FTDI_BUF_SIZE);