Commit 1c04d140672d7db115aacb44888f11c850787efb

Kano 2013-03-13T23:24:34

cgminer -n to include a USB device list

diff --git a/cgminer.c b/cgminer.c
index 5a9b8c9..1ff06e6 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1363,6 +1363,20 @@ static char *opt_verusage_and_exit(const char *extra)
 	exit(0);
 }
 
+#if defined(HAVE_OPENCL) || defined(USE_USBUTILS)
+char *display_devs(int *ndevs)
+{
+	*ndevs = 0;
+#ifdef HAVE_OPENCL
+	print_ndevs(ndevs);
+#endif
+#ifdef USE_USBUTILS
+	usb_all(0);
+#endif
+	exit(*ndevs);
+}
+#endif
+
 /* These options are available from commandline only */
 static struct opt_table opt_cmdline_table[] = {
 	OPT_WITH_ARG("--config|-c",
@@ -1376,10 +1390,17 @@ static struct opt_table opt_cmdline_table[] = {
 	OPT_WITHOUT_ARG("--help|-h",
 			opt_verusage_and_exit, NULL,
 			"Print this message"),
-#ifdef HAVE_OPENCL
+#if defined(HAVE_OPENCL) || defined(USE_USBUTILS)
 	OPT_WITHOUT_ARG("--ndevs|-n",
-			print_ndevs_and_exit, &nDevs,
-			"Display number of detected GPUs, OpenCL platform information, and exit"),
+			display_devs, &nDevs,
+			"Display "
+#ifdef HAVE_OPENCL
+			"number of detected GPUs, OpenCL platform information, "
+#endif
+#ifdef USE_USBUTILS
+			"all USB devices, "
+#endif
+			"and exit"),
 #endif
 	OPT_WITHOUT_ARG("--version|-V",
 			opt_version_and_exit, packagename,
diff --git a/driver-opencl.c b/driver-opencl.c
index 8580b22..5b83349 100644
--- a/driver-opencl.c
+++ b/driver-opencl.c
@@ -592,13 +592,12 @@ char *set_intensity(char *arg)
 	return NULL;
 }
 
-char *print_ndevs_and_exit(int *ndevs)
+void print_ndevs(int *ndevs)
 {
 	opt_log_output = true;
 	opencl_drv.drv_detect();
 	clear_adl(*ndevs);
 	applog(LOG_INFO, "%i GPU devices max detected", *ndevs);
-	exit(*ndevs);
 }
 #endif
 
diff --git a/driver-opencl.h b/driver-opencl.h
index 22bd9ec..1cb8807 100644
--- a/driver-opencl.h
+++ b/driver-opencl.h
@@ -4,7 +4,7 @@
 #include "miner.h"
 
 
-extern char *print_ndevs_and_exit(int *ndevs);
+extern void print_ndevs(int *ndevs);
 extern void *reinit_gpu(void *userdata);
 extern char *set_gpu_map(char *arg);
 extern char *set_gpu_engine(char *arg);