X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fsaleae-logic%2Fsaleae-logic.c;h=07491fa085427889112e05bcb12b5e22a9773959;hb=38ba2522516b481fa3619bdec56d1e2a4b7a5f45;hp=423e1d3441cf114ee21e8f5d04b235ef447a1de8;hpb=5e59f476152a343619f473c37f2b06e2b6ef15d3;p=libsigrok.git diff --git a/hardware/saleae-logic/saleae-logic.c b/hardware/saleae-logic/saleae-logic.c index 423e1d34..07491fa0 100644 --- a/hardware/saleae-logic/saleae-logic.c +++ b/hardware/saleae-logic/saleae-logic.c @@ -164,75 +164,6 @@ int check_conf_profile(libusb_device *dev) return ret; } -static int opendev2(int device_index, struct sigrok_device_instance **sdi, - libusb_device *dev, struct libusb_device_descriptor *des, - int *skip, uint16_t vid, uint16_t pid, int interface) -{ - int err; - - if ((err = libusb_get_device_descriptor(dev, des))) { - g_warning("failed to get device descriptor: %d", err); - return -1; - } - - if (des->idVendor != vid || des->idProduct != pid) - return 0; - - if (*skip != device_index) { - /* Skip devices of this type that aren't the one we want. */ - *skip += 1; - return 0; - } - - /* - * Should check the bus here, since we know that already. But what are - * we going to do if it doesn't match after the right number of skips? - */ - if (!(err = libusb_open(dev, &((*sdi)->usb->devhdl)))) { - (*sdi)->usb->address = libusb_get_device_address(dev); - (*sdi)->status = ST_ACTIVE; - g_message("opened device %d on %d.%d interface %d", - (*sdi)->index, (*sdi)->usb->bus, - (*sdi)->usb->address, interface); - } else { - g_warning("failed to open device: %d", err); - *sdi = NULL; - } - - return 0; -} - -static int opendev3(struct sigrok_device_instance **sdi, libusb_device *dev, - struct libusb_device_descriptor *des, - uint16_t vid, uint16_t pid, int interface) -{ - int err; - - if ((err = libusb_get_device_descriptor(dev, des))) { - g_warning("failed to get device descriptor: %d", err); - return -1; - } - - if (des->idVendor != vid || des->idProduct != pid) - return 0; - - if (libusb_get_bus_number(dev) == (*sdi)->usb->bus - && libusb_get_device_address(dev) == (*sdi)->usb->address) { - /* Found it. */ - if (!(err = libusb_open(dev, &((*sdi)->usb->devhdl)))) { - (*sdi)->status = ST_ACTIVE; - g_message("opened device %d on %d.%d interface %d", - (*sdi)->index, (*sdi)->usb->bus, - (*sdi)->usb->address, interface); - } else { - g_warning("failed to open device: %d", err); - *sdi = NULL; - } - } - - return 0; -} - struct sigrok_device_instance *sl_open_device(int device_index) { struct sigrok_device_instance *sdi; @@ -328,16 +259,17 @@ static int configure_probes(GSList *probes) continue; probe_bit = 1 << (probe->index - 1); probe_mask |= probe_bit; - if (probe->trigger) { - stage = 0; - for (tc = probe->trigger; *tc; tc++) { - trigger_mask[stage] |= probe_bit; - if (*tc == '1') - trigger_value[stage] |= probe_bit; - stage++; - if (stage > NUM_TRIGGER_STAGES) - return SIGROK_ERR; - } + if (!(probe->trigger)) + continue; + + stage = 0; + for (tc = probe->trigger; *tc; tc++) { + trigger_mask[stage] |= probe_bit; + if (*tc == '1') + trigger_value[stage] |= probe_bit; + stage++; + if (stage > NUM_TRIGGER_STAGES) + return SIGROK_ERR; } } @@ -579,7 +511,8 @@ static int hw_set_configuration(int device_index, int capability, void *value) } else if (capability == HWCAP_PROBECONFIG) { ret = configure_probes((GSList *) value); } else if (capability == HWCAP_LIMIT_SAMPLES) { - limit_samples = strtoull(value, NULL, 10); + tmp_u64 = value; + limit_samples = *tmp_u64; ret = SIGROK_OK; } else { ret = SIGROK_ERR;