Browse Source

cairnsmore/erupter/icarus: Convert to lowl_probe

Luke Dashjr 12 years ago
parent
commit
fd592db8fb
3 changed files with 42 additions and 27 deletions
  1. 12 9
      driver-cairnsmore.c
  2. 26 15
      driver-erupter.c
  3. 4 3
      driver-icarus.c

+ 12 - 9
driver-cairnsmore.c

@@ -16,6 +16,7 @@
 #include "dynclock.h"
 #include "fpgautils.h"
 #include "icarus-common.h"
+#include "lowlevel.h"
 #include "miner.h"
 
 #define CAIRNSMORE1_IO_SPEED 115200
@@ -29,6 +30,12 @@
 
 BFG_REGISTER_DRIVER(cairnsmore_drv)
 
+static
+bool cairnsmore_lowl_match(const struct lowlevel_device_info * const info)
+{
+	return lowlevel_match_lowlproduct(info, &lowl_vcom, "Cairnsmore1");
+}
+
 static bool cairnsmore_detect_one(const char *devpath)
 {
 	struct ICARUS_INFO *info = calloc(1, sizeof(struct ICARUS_INFO));
@@ -50,15 +57,10 @@ static bool cairnsmore_detect_one(const char *devpath)
 	return true;
 }
 
-static int cairnsmore_detect_auto(void)
-{
-	return serial_autodetect(cairnsmore_detect_one, "Cairnsmore1");
-}
-
-static void cairnsmore_detect()
+static
+bool cairnsmore_lowl_probe(const struct lowlevel_device_info * const info)
 {
-	// Actual serial detection is handled by Icarus driver
-	serial_detect_auto_byname(&cairnsmore_drv, cairnsmore_detect_one, cairnsmore_detect_auto);
+	return vcom_lowl_probe_wrapper(info, cairnsmore_detect_one);
 }
 
 static bool cairnsmore_send_cmd(int fd, uint8_t cmd, uint8_t data, bool probe)
@@ -204,7 +206,8 @@ static void cairnsmore_drv_init()
 	cairnsmore_drv = icarus_drv;
 	cairnsmore_drv.dname = "cairnsmore";
 	cairnsmore_drv.name = "ECM";
-	cairnsmore_drv.drv_detect = cairnsmore_detect;
+	cairnsmore_drv.lowl_match = cairnsmore_lowl_match;
+	cairnsmore_drv.lowl_probe = cairnsmore_lowl_probe;
 	cairnsmore_drv.thread_init = cairnsmore_init;
 	cairnsmore_drv.identify_device = cairnsmore_identify;
 	cairnsmore_drv.get_api_extra_device_status = cairnsmore_drv_extra_device_status;

+ 26 - 15
driver-erupter.c

@@ -14,6 +14,7 @@
 #include "miner.h"
 #include "fpgautils.h"
 #include "icarus-common.h"
+#include "lowlevel.h"
 
 #define ERUPTER_IO_SPEED 115200
 #define ERUPTER_HASH_TIME 0.0000000029761
@@ -41,12 +42,30 @@ static bool _erupter_detect_one(const char *devpath, struct device_drv *drv)
 	return true;
 }
 
+static
+bool erupter_emerald_lowl_match(const struct lowlevel_device_info * const info)
+{
+	return lowlevel_match_lowlproduct(info, &lowl_vcom, "Block", "Erupter", "Emerald");
+}
+
 static bool erupter_emerald_detect_one(const char *devpath)
 {
 	// For detection via BEE:*
 	return _erupter_detect_one(devpath, &erupter_drv_emerald);
 }
 
+static
+bool erupter_emerald_lowl_probe(const struct lowlevel_device_info * const info)
+{
+	return vcom_lowl_probe_wrapper(info, erupter_emerald_detect_one);
+}
+
+static
+bool erupter_lowl_match(const struct lowlevel_device_info * const info)
+{
+	return lowlevel_match_lowlproduct(info, &lowl_vcom, "Block", "Erupter");
+}
+
 static bool erupter_detect_one(const char *devpath)
 {
 	struct device_drv *drv = &erupter_drv;
@@ -58,21 +77,10 @@ static bool erupter_detect_one(const char *devpath)
 	return _erupter_detect_one(devpath, drv);
 }
 
-static int erupter_emerald_detect_auto(void)
-{
-	return serial_autodetect(erupter_emerald_detect_one, "Block", "Erupter", "Emerald");
-}
-
-static int erupter_detect_auto(void)
-{
-	return serial_autodetect(erupter_detect_one, "Block", "Erupter");
-}
-
-static void erupter_detect()
+static
+bool erupter_lowl_probe(const struct lowlevel_device_info * const info)
 {
-	// Actual serial detection is handled by Icarus driver
-	serial_detect_auto_byname(&erupter_drv, erupter_detect_one, erupter_detect_auto);
-	serial_detect_auto_byname(&erupter_drv_emerald, erupter_emerald_detect_one, erupter_emerald_detect_auto);
+	return vcom_lowl_probe_wrapper(info, erupter_detect_one);
 }
 
 static bool erupter_identify(struct cgpu_info *erupter)
@@ -88,12 +96,15 @@ static void erupter_drv_init()
 	erupter_drv = icarus_drv;
 	erupter_drv.dname = "erupter";
 	erupter_drv.name = "BES";
-	erupter_drv.drv_detect = erupter_detect;
+	erupter_drv.lowl_match = erupter_lowl_match;
+	erupter_drv.lowl_probe = erupter_lowl_probe;
 	erupter_drv.identify_device = erupter_identify;
 	++erupter_drv.probe_priority;
 	
 	erupter_drv_emerald = erupter_drv;
 	erupter_drv_emerald.name = "BEE";
+	erupter_drv.lowl_match = erupter_emerald_lowl_match;
+	erupter_drv.lowl_probe = erupter_emerald_lowl_probe;
 }
 
 struct device_drv erupter_drv = {

+ 4 - 3
driver-icarus.c

@@ -675,9 +675,10 @@ static bool icarus_detect_one(const char *devpath)
 	return true;
 }
 
-static void icarus_detect()
+static
+bool icarus_lowl_probe(const struct lowlevel_device_info * const info)
 {
-	serial_detect(&icarus_drv, icarus_detect_one);
+	return vcom_lowl_probe_wrapper(info, icarus_detect_one);
 }
 
 static bool icarus_prepare(struct thr_info *thr)
@@ -1310,7 +1311,7 @@ struct device_drv icarus_drv = {
 	.dname = "icarus",
 	.name = "ICA",
 	.probe_priority = -120,
-	.drv_detect = icarus_detect,
+	.lowl_probe = icarus_lowl_probe,
 	.get_api_stats = icarus_drv_stats,
 	.thread_prepare = icarus_prepare,
 	.thread_init = icarus_init,