X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhantek-dso%2Fdso.c;h=8561ac3ded1494474bd48564cee18cc15e734874;hb=32ba0d80054df01767ec323c621ab1c6bc5f310c;hp=7a2d2379dd736f01b837d70f0ccf23a823a83f1c;hpb=515ab0889ebde4b373d620044a1a98da37153056;p=libsigrok.git
diff --git a/src/hardware/hantek-dso/dso.c b/src/hardware/hantek-dso/dso.c
index 7a2d2379..8561ac3d 100644
--- a/src/hardware/hantek-dso/dso.c
+++ b/src/hardware/hantek-dso/dso.c
@@ -19,13 +19,16 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include
-#include "libsigrok.h"
+#include
#include "libsigrok-internal.h"
#include "dso.h"
+#define NUM_CHANNELS 2
+
extern struct sr_dev_driver hantek_dso_driver_info;
static int send_begin(const struct sr_dev_inst *sdi)
@@ -73,8 +76,7 @@ static int dso_getmps(libusb_device *dev)
const struct libusb_interface_descriptor *intf_dsc;
int mps;
- if (libusb_get_device_descriptor(dev, &des) != 0)
- return 0;
+ libusb_get_device_descriptor(dev, &des);
if (des.bNumConfigurations != 1)
return 0;
@@ -109,7 +111,7 @@ err:
SR_PRIV int dso_open(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- struct drv_context *drvc = hantek_dso_driver_info.priv;
+ struct drv_context *drvc = hantek_dso_driver_info.context;
struct sr_usb_dev_inst *usb;
struct libusb_device_descriptor des;
libusb_device **devlist;
@@ -125,11 +127,7 @@ SR_PRIV int dso_open(struct sr_dev_inst *sdi)
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
for (i = 0; devlist[i]; i++) {
- if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("Failed to get device descriptor: %s.",
- libusb_error_name(err));
- continue;
- }
+ libusb_get_device_descriptor(devlist[i], &des);
if (des.idVendor != devc->profile->fw_vid
|| des.idProduct != devc->profile->fw_pid)
@@ -225,7 +223,7 @@ static int get_channel_offsets(const struct sr_dev_inst *sdi)
* since that's how voltage offsets are submitted back to the DSO.
* Convert to host order now, so we can use them natively.
*/
- for (chan = 0; chan < 2; chan++) {
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
for (v = 0; v < 9; v++) {
devc->channel_levels[chan][v][0] =
g_ntohs(devc->channel_levels[chan][v][0]);
@@ -236,7 +234,7 @@ static int get_channel_offsets(const struct sr_dev_inst *sdi)
if (sr_log_loglevel_get() >= SR_LOG_DBG) {
gs = g_string_sized_new(128);
- for (chan = 0; chan < 2; chan++) {
+ for (chan = 0; chan < NUM_CHANNELS; chan++) {
g_string_printf(gs, "CH%d:", chan + 1);
for (v = 0; v < 9; v++) {
g_string_append_printf(gs, " %.4x-%.4x",