Browse Source

hashbuster: Convert to lowl_probe

Luke Dashjr 12 years ago
parent
commit
6ff9b53638
1 changed files with 10 additions and 18 deletions
  1. 10 18
      driver-hashbuster.c

+ 10 - 18
driver-hashbuster.c

@@ -142,7 +142,13 @@ bool hashbuster_spi_txrx(struct spi_port * const port)
 }
 
 static
-bool hashbuster_foundlowl(struct lowlevel_device_info * const info, __maybe_unused void *userp)
+bool hashbuster_lowl_match(const struct lowlevel_device_info * const info)
+{
+	return lowlevel_match_lowlproduct(info, &lowl_hid, HASHBUSTER_USB_PRODUCT);
+}
+
+static
+bool hashbuster_lowl_probe(const struct lowlevel_device_info * const info)
 {
 	const char * const product = info->product;
 	const char * const serial = info->serial;
@@ -185,7 +191,7 @@ bool hashbuster_foundlowl(struct lowlevel_device_info * const info, __maybe_unus
 	cgpu = malloc(sizeof(*cgpu));
 	*cgpu = (struct cgpu_info){
 		.drv = &hashbuster_drv,
-		.device_data = info,
+		.device_data = lowlevel_ref(info),
 		.threads = 1,
 		.procs = chip_n,
 		.device_path = strdup(info->path),
@@ -198,21 +204,6 @@ bool hashbuster_foundlowl(struct lowlevel_device_info * const info, __maybe_unus
 	return add_cgpu(cgpu);
 }
 
-static bool hashbuster_detect_one(const char *serial)
-{
-	return lowlevel_detect_serial(hashbuster_foundlowl, serial);
-}
-
-static int hashbuster_detect_auto()
-{
-	return lowlevel_detect(hashbuster_foundlowl, HASHBUSTER_USB_PRODUCT);
-}
-
-static void hashbuster_detect()
-{
-	serial_detect_auto(&hashbuster_drv, hashbuster_detect_one, hashbuster_detect_auto);
-}
-
 static
 bool hashbuster_init(struct thr_info * const thr)
 {
@@ -291,7 +282,8 @@ bool hashbuster_get_stats(struct cgpu_info * const cgpu)
 struct device_drv hashbuster_drv = {
 	.dname = "hashbuster",
 	.name = "HBR",
-	.drv_detect = hashbuster_detect,
+	.lowl_match = hashbuster_lowl_match,
+	.lowl_probe = hashbuster_lowl_probe,
 	
 	.thread_init = hashbuster_init,
 	.thread_disable = bitfury_disable,