]> sigrok.org Git - libsigrok.git/commitdiff
ftdi-la: Use the standard connection_id field for the device address
authorLars-Peter Clausen <redacted>
Sat, 14 May 2016 15:24:27 +0000 (17:24 +0200)
committerLars-Peter Clausen <redacted>
Wed, 18 May 2016 16:15:33 +0000 (18:15 +0200)
Use the standard connection_id field from the struct sr_dev_inst for
storing the device address rather than using the custom address field in
the driver state struct. This makes things more consistent with the
framework.

Signed-off-by: Lars-Peter Clausen <redacted>
src/hardware/ftdi-la/api.c
src/hardware/ftdi-la/protocol.h

index c3c3891fc500f16d662f30292ba5929c029316cc..7bf0e13d5a3b077cd57a2e0b2f6d1509fe9fe23a 100644 (file)
@@ -116,9 +116,6 @@ static void scan_device(struct sr_dev_driver *di, struct ftdi_context *ftdic,
        /* Allocate memory for the incoming data. */
        devc->data_buf = g_malloc0(DATA_BUF_SIZE);
 
-       snprintf(devc->address, sizeof(devc->address), "d:%u/%u",
-               libusb_get_bus_number(dev), libusb_get_device_address(dev));
-
        devc->desc = desc;
 
        vendor = g_malloc(32);
@@ -148,6 +145,8 @@ static void scan_device(struct sr_dev_driver *di, struct ftdi_context *ftdic,
        sdi->serial_num = serial_num;
        sdi->driver = di;
        sdi->priv = devc;
+       sdi->connection_id = g_strdup_printf("d:%u/%u",
+               libusb_get_bus_number(dev), libusb_get_device_address(dev));
 
        for (char *const *chan = &(desc->channel_names[0]); *chan; chan++)
                sr_channel_new(sdi, chan - &(desc->channel_names[0]),
@@ -274,7 +273,7 @@ static int dev_open(struct sr_dev_inst *sdi)
        if (!devc->ftdic)
                return SR_ERR;
 
-       ret = ftdi_usb_open_string(devc->ftdic, devc->address);
+       ret = ftdi_usb_open_string(devc->ftdic, sdi->connection_id);
        if (ret < 0) {
                /* Log errors, except for -3 ("device not found"). */
                if (ret != -3)
index ab8ac5c3de8b69a9d8832343022c98a9f785ef6f..d5ba9b09cbb0149e1115d17034788fc27345d7b6 100644 (file)
@@ -40,7 +40,6 @@ struct ftdi_chip_desc {
 struct dev_context {
        struct ftdi_context *ftdic;
        const struct ftdi_chip_desc *desc;
-       char address[sizeof("d:000:000")];
 
        uint64_t limit_samples;
        uint32_t cur_samplerate;