configure - set USE_USBUTILS when usbutils is required and use it in the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
diff --git a/api.c b/api.c
index 6acf601..241638b 100644
--- a/api.c
+++ b/api.c
@@ -577,7 +577,7 @@ struct CODES {
{ SEVERITY_ERR, MSG_ZERINV, PARAM_STR, "Invalid zero parameter '%s'" },
{ SEVERITY_SUCC, MSG_ZERSUM, PARAM_STR, "Zeroed %s stats with summary" },
{ SEVERITY_SUCC, MSG_ZERNOSUM, PARAM_STR, "Zeroed %s stats without summary" },
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
{ SEVERITY_ERR, MSG_USBNODEV, PARAM_PGA, "PGA%d has no device" },
#endif
{ SEVERITY_ERR, MSG_INVHPLG, PARAM_STR, "Invalid value for hotplug (%s) must be 0..9999" },
@@ -1440,7 +1440,7 @@ static void minerconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __
root = api_add_int(root, "ScanTime", &opt_scantime, false);
root = api_add_int(root, "Queue", &opt_queue, false);
root = api_add_int(root, "Expiry", &opt_expiry, false);
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
if (hotplug_time == 0)
root = api_add_const(root, "Hotplug", DISABLED, false);
else
@@ -1607,7 +1607,7 @@ static void pgastatus(struct io_data *io_data, int pga, bool isjson, bool precom
root = api_add_diff(root, "Difficulty Accepted", &(cgpu->diff_accepted), false);
root = api_add_diff(root, "Difficulty Rejected", &(cgpu->diff_rejected), false);
root = api_add_diff(root, "Last Share Difficulty", &(cgpu->last_share_diff), false);
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
root = api_add_bool(root, "No Device", &(cgpu->usbinfo.nodev), false);
#endif
root = api_add_time(root, "Last Valid Work", &(cgpu->last_device_valid_work), false);
@@ -1828,7 +1828,7 @@ static void pgaenable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char
}
#endif
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
if (cgpu->usbinfo.nodev) {
message(io_data, MSG_USBNODEV, id, NULL, isjson);
return;
@@ -3185,7 +3185,7 @@ static void usbstats(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __may
{
struct api_data *root = NULL;
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
char buf[TMPBUFSIZ];
bool io_open = false;
int count = 0;
@@ -3198,8 +3198,7 @@ static void usbstats(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __may
return;
}
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
-
+#ifdef USE_USBUTILS
message(io_data, MSG_USBSTA, 0, NULL, isjson);
if (isjson)
@@ -3332,7 +3331,7 @@ static void dozero(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *p
static void dohotplug(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
{
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
int value;
if (param == NULL || *param == '\0') {
diff --git a/cgminer.c b/cgminer.c
index e488592..a6f5fbb 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -157,7 +157,7 @@ static int input_thr_id;
#endif
int gpur_thr_id;
static int api_thr_id;
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
static int hotplug_thr_id;
#endif
static int total_control_threads;
@@ -987,7 +987,7 @@ static struct opt_table opt_config_table[] = {
#endif
OPT_WITH_ARG("--hotplug",
set_int_0_to_9999, NULL, &hotplug_time,
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
"Seconds between hotplug checks (0 means never check)"
#else
opt_hidden
@@ -2038,7 +2038,7 @@ static void curses_print_devstatus(int thr_id)
suffix_string(dh64, displayed_hashes, 4);
suffix_string(dr64, displayed_rolling, 4);
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
if (cgpu->usbinfo.nodev)
wprintw(statuswin, "ZOMBIE");
else
@@ -2806,7 +2806,7 @@ static void __kill_work(void)
applog(LOG_INFO, "Received kill message");
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
/* Best to get rid of it first so it doesn't
* try to create any new devices */
if (!opt_scrypt) {
@@ -2852,7 +2852,7 @@ static void __kill_work(void)
thr = &control_thr[api_thr_id];
thr_info_cancel(thr);
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
/* Release USB resources in case it's a restart
* and not a QUIT */
if (!opt_scrypt) {
@@ -6789,7 +6789,7 @@ struct device_drv *copy_drv(struct device_drv *drv)
return copy;
}
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
static void hotplug_process()
{
struct thr_info *thr;
@@ -7405,7 +7405,7 @@ begin_bench:
if (thr_info_create(thr, NULL, api_thread, thr))
quit(1, "API thread create failed");
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
if (!opt_scrypt) {
hotplug_thr_id = 6;
thr = &control_thr[hotplug_thr_id];
diff --git a/configure.ac b/configure.ac
index 05ea6f1..a14ef76 100644
--- a/configure.ac
+++ b/configure.ac
@@ -271,7 +271,6 @@ else
])
fi
-
AM_CONDITIONAL([NEED_FPGAUTILS], [test x$icarus$bitforce$modminer$ztex != xnononono])
AM_CONDITIONAL([NEED_USBUTILS_C], [test x$bitforce$modminer != xnono])
AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes])
@@ -279,6 +278,10 @@ AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue])
AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
AM_CONDITIONAL([HAVE_x86_64], [test x$have_x86_64 = xtrue])
+if test "x$bitforce$modminer" != xnono; then
+ AC_DEFINE([USE_USBUTILS], [1], [Defined to 1 if usbutils support required])
+fi
+
if test x$request_jansson = xtrue
then
JANSSON_LIBS="compat/jansson/libjansson.a"
diff --git a/miner.h b/miner.h
index 5520d87..4c34131 100644
--- a/miner.h
+++ b/miner.h
@@ -114,7 +114,7 @@ static inline int fsync (int fd)
#include "libztex.h"
#endif
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
#include "usbutils.h"
#endif
@@ -408,14 +408,14 @@ struct cgpu_info {
#ifdef USE_ZTEX
struct libztex_device *device_ztex;
#endif
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
struct cg_usb_device *usbdev;
#endif
#ifdef USE_ICARUS
int device_fd;
#endif
};
-#if defined(USE_MODMINER) || defined(USE_BITFORCE)
+#ifdef USE_USBUTILS
struct cg_usb_info usbinfo;
#endif
#ifdef USE_MODMINER