Browse Source

DevAPI: Move device_proc_by_id out of bifury driver, since it is generically useful

Luke Dashjr 11 years ago
parent
commit
561a4974e9
3 changed files with 14 additions and 13 deletions
  1. 13 0
      deviceapi.c
  2. 1 0
      deviceapi.h
  3. 0 13
      driver-bifury.c

+ 13 - 0
deviceapi.c

@@ -1083,3 +1083,16 @@ void close_device_fd(struct thr_info * const thr)
 		applog(LOG_DEBUG, "%"PRIpreprv": Closed device fd", proc->proc_repr);
 	}
 }
+
+
+struct cgpu_info *device_proc_by_id(struct cgpu_info * const dev, const int procid)
+{
+	struct cgpu_info *proc = dev;
+	for (int i = 0; i < procid; ++i)
+	{
+		proc = proc->next_proc;
+		if (unlikely((!proc) || proc->device != dev))
+			return NULL;
+	}
+	return proc;
+}

+ 1 - 0
deviceapi.h

@@ -114,5 +114,6 @@ extern void close_device_fd(struct thr_info *);
 	for (struct cgpu_info *procvar = dev; procvar; procvar = procvar->next_proc)
 #define for_each_logical_proc(procvar, dev)  \
 	for (struct cgpu_info *procvar = dev; procvar->proc_id < dev->procs; procvar = procvar->next_proc)
+extern struct cgpu_info *device_proc_by_id(struct cgpu_info *dev, int procid);
 
 #endif

+ 0 - 13
driver-bifury.c

@@ -363,19 +363,6 @@ void bifury_queue_flush(struct thr_info * const thr)
 	bifury_set_queue_full(dev, dev->procs);
 }
 
-static
-const struct cgpu_info *device_proc_by_id(const struct cgpu_info * const dev, int procid)
-{
-	const struct cgpu_info *proc = dev;
-	for (int i = 0; i < procid; ++i)
-	{
-		proc = proc->next_proc;
-		if (unlikely(!proc))
-			return NULL;
-	}
-	return proc;
-}
-
 static
 void bifury_handle_cmd(struct cgpu_info * const dev, const char * const cmd)
 {