Browse Source

rename device_api -> device_drv and all related api -> drv

Kano 13 years ago
parent
commit
e0994aa9fa
19 changed files with 188 additions and 188 deletions
  1. 5 5
      HACKING
  2. 23 23
      api.c
  3. 18 18
      deviceapi.c
  4. 8 8
      driver-avalon.c
  5. 13 13
      driver-bitforce.c
  6. 19 19
      driver-cairnsmore.c
  7. 3 3
      driver-cpu.c
  8. 1 1
      driver-cpu.h
  9. 10 10
      driver-icarus.c
  10. 8 8
      driver-modminer.c
  11. 7 7
      driver-opencl.c
  12. 1 1
      driver-opencl.h
  13. 5 5
      driver-x6500.c
  14. 7 7
      driver-ztex.c
  15. 6 6
      fpgautils.c
  16. 3 3
      fpgautils.h
  17. 1 1
      icarus-common.h
  18. 46 46
      miner.c
  19. 4 4
      miner.h

+ 5 - 5
HACKING

@@ -22,21 +22,21 @@ for the Processor, and is maintained by the managing Thread in addition to its
 own `struct thr_info`. New drivers are encouraged to use an asynchronous model
 own `struct thr_info`. New drivers are encouraged to use an asynchronous model
 to manage as many Processors as possible within a single Thread.
 to manage as many Processors as possible within a single Thread.
 
 
-struct device_api basics
+struct device_drv basics
 ------------------------
 ------------------------
 
 
-Every driver defines a `struct device_api`. The `dname` field contains a
+Every driver defines a `struct device_drv`. The `dname` field contains a
 short name of the driver. This should be the same name used in the source file:
 short name of the driver. This should be the same name used in the source file:
 driver-foobar.c defines `dname` "foobar". The `name` field contains a three-
 driver-foobar.c defines `dname` "foobar". The `name` field contains a three-
 letter abbreviation for the device, used in the representation of devices. For
 letter abbreviation for the device, used in the representation of devices. For
 example, `dname` "FOO" would result in devices represented as "FOO 0", "FOO 1",
 example, `dname` "FOO" would result in devices represented as "FOO 0", "FOO 1",
 etc and processors represented as "FOO 0a", "FOO 0b", etc.
 etc and processors represented as "FOO 0a", "FOO 0b", etc.
 
 
-Drivers must define a function `api_detect`, which is run at startup to detect
+Drivers must define a function `drv_detect`, which is run at startup to detect
 devices. For each device (note: NOT each processor), it should allocate a
 devices. For each device (note: NOT each processor), it should allocate a
 `struct cgpu_info`, set some basic parameters on it, and call the `add_cgpu`
 `struct cgpu_info`, set some basic parameters on it, and call the `add_cgpu`
 function with it as an argument. Various values you can initialize are:
 function with it as an argument. Various values you can initialize are:
-	.api         This MUST be set to your driver's `struct driver_api`!
+	.drv         This MUST be set to your driver's `struct device_drv`!
 	.deven       Should be set to DEV_ENABLED
 	.deven       Should be set to DEV_ENABLED
 	.procs       Number of Processors for this device
 	.procs       Number of Processors for this device
 	.threads     Number of threads your device needs - should be either a
 	.threads     Number of threads your device needs - should be either a
@@ -44,7 +44,7 @@ function with it as an argument. Various values you can initialize are:
 	             Processor), or one (a single thread will be allocated only to
 	             Processor), or one (a single thread will be allocated only to
 	             the Device, to manage all Processors)
 	             the Device, to manage all Processors)
 	.name        Null-terminated name of the device itself
 	.name        Null-terminated name of the device itself
-`api_detect` should return the total number of devices created. It should leave
+`drv_detect` should return the total number of devices created. It should leave
 the device in an unused state, as the user may opt to delete it outright.
 the device in an unused state, as the user may opt to delete it outright.
 
 
 Threads
 Threads

+ 23 - 23
api.c

@@ -609,11 +609,11 @@ static struct IP4ACCESS *ipaccess = NULL;
 static int ips = 0;
 static int ips = 0;
 
 
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
-extern struct device_api opencl_api;
+extern struct device_drv opencl_api;
 #endif
 #endif
 
 
 #ifdef WANT_CPUMINE
 #ifdef WANT_CPUMINE
-extern struct device_api cpu_api;
+extern struct device_drv cpu_drv;
 #endif
 #endif
 
 
 struct io_data {
 struct io_data {
@@ -1175,11 +1175,11 @@ static int numpgas()
 	mutex_lock(&devices_lock);
 	mutex_lock(&devices_lock);
 	for (i = 0; i < total_devices; i++) {
 	for (i = 0; i < total_devices; i++) {
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
-		if (devices[i]->api == &opencl_api)
+		if (devices[i]->drv == &opencl_api)
 			continue;
 			continue;
 #endif
 #endif
 #ifdef WANT_CPUMINE
 #ifdef WANT_CPUMINE
-		if (devices[i]->api == &cpu_api)
+		if (devices[i]->drv == &cpu_drv)
 			continue;
 			continue;
 #endif
 #endif
 		++count;
 		++count;
@@ -1196,11 +1196,11 @@ static int pgadevice(int pgaid)
 	mutex_lock(&devices_lock);
 	mutex_lock(&devices_lock);
 	for (i = 0; i < total_devices; i++) {
 	for (i = 0; i < total_devices; i++) {
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
-		if (devices[i]->api == &opencl_api)
+		if (devices[i]->drv == &opencl_api)
 			continue;
 			continue;
 #endif
 #endif
 #ifdef WANT_CPUMINE
 #ifdef WANT_CPUMINE
-		if (devices[i]->api == &cpu_api)
+		if (devices[i]->drv == &cpu_drv)
 			continue;
 			continue;
 #endif
 #endif
 		++count;
 		++count;
@@ -1473,7 +1473,7 @@ static const char *status2str(enum alive status)
 static
 static
 struct api_data *api_add_device_identifier(struct api_data *root, struct cgpu_info *cgpu)
 struct api_data *api_add_device_identifier(struct api_data *root, struct cgpu_info *cgpu)
 {
 {
-	root = api_add_string(root, "Name", cgpu->api->name, false);
+	root = api_add_string(root, "Name", cgpu->drv->name, false);
 	root = api_add_int(root, "ID", &(cgpu->device_id), false);
 	root = api_add_int(root, "ID", &(cgpu->device_id), false);
 	root = api_add_int(root, "ProcID", &(cgpu->proc_id), false);
 	root = api_add_int(root, "ProcID", &(cgpu->proc_id), false);
 	return root;
 	return root;
@@ -1498,7 +1498,7 @@ static void devdetail_an(struct io_data *io_data, struct cgpu_info *cgpu, bool i
 
 
 	root = api_add_int(root, (char*)cgpu->devtype, &n, true);
 	root = api_add_int(root, (char*)cgpu->devtype, &n, true);
 	root = api_add_device_identifier(root, cgpu);
 	root = api_add_device_identifier(root, cgpu);
-	root = api_add_string(root, "Driver", cgpu->api->dname, false);
+	root = api_add_string(root, "Driver", cgpu->drv->dname, false);
 	if (cgpu->kname)
 	if (cgpu->kname)
 		root = api_add_string(root, "Kernel", cgpu->kname, false);
 		root = api_add_string(root, "Kernel", cgpu->kname, false);
 	if (cgpu->name)
 	if (cgpu->name)
@@ -1506,8 +1506,8 @@ static void devdetail_an(struct io_data *io_data, struct cgpu_info *cgpu, bool i
 	if (cgpu->device_path)
 	if (cgpu->device_path)
 		root = api_add_string(root, "Device Path", cgpu->device_path, false);
 		root = api_add_string(root, "Device Path", cgpu->device_path, false);
 
 
-	if (cgpu->api->get_api_extra_device_detail)
-		root = api_add_extra(root, cgpu->api->get_api_extra_device_detail(cgpu));
+	if (cgpu->drv->get_api_extra_device_detail)
+		root = api_add_extra(root, cgpu->drv->get_api_extra_device_detail(cgpu));
 
 
 	root = print_data(root, buf, isjson, precom);
 	root = print_data(root, buf, isjson, precom);
 	io_add(io_data, buf);
 	io_add(io_data, buf);
@@ -1556,8 +1556,8 @@ static void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool i
 	root = api_add_diff(root, "Last Share Difficulty", &(cgpu->last_share_diff), false);
 	root = api_add_diff(root, "Last Share Difficulty", &(cgpu->last_share_diff), false);
 	root = api_add_time(root, "Last Valid Work", &(cgpu->last_device_valid_work), false);
 	root = api_add_time(root, "Last Valid Work", &(cgpu->last_device_valid_work), false);
 
 
-	if (cgpu->api->get_api_extra_device_status)
-		root = api_add_extra(root, cgpu->api->get_api_extra_device_status(cgpu));
+	if (cgpu->drv->get_api_extra_device_status)
+		root = api_add_extra(root, cgpu->drv->get_api_extra_device_status(cgpu));
 
 
 	root = print_data(root, buf, isjson, precom);
 	root = print_data(root, buf, isjson, precom);
 	io_add(io_data, buf);
 	io_add(io_data, buf);
@@ -1789,7 +1789,7 @@ static void pgadisable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, cha
 static void pgaidentify(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
 static void pgaidentify(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
 {
 {
 	struct cgpu_info *cgpu;
 	struct cgpu_info *cgpu;
-	const struct device_api *api;
+	const struct device_drv *drv;
 	int numpga = numpgas();
 	int numpga = numpgas();
 	int id;
 	int id;
 
 
@@ -1816,9 +1816,9 @@ static void pgaidentify(struct io_data *io_data, __maybe_unused SOCKETTYPE c, ch
 	}
 	}
 
 
 	cgpu = get_devices(dev);
 	cgpu = get_devices(dev);
-	api = cgpu->api;
+	drv = cgpu->drv;
 
 
-	if (api->identify_device && api->identify_device(cgpu))
+	if (drv->identify_device && drv->identify_device(cgpu))
 		message(io_data, MSG_PGAIDENT, id, NULL, isjson);
 		message(io_data, MSG_PGAIDENT, id, NULL, isjson);
 	else
 	else
 		message(io_data, MSG_PGANOID, id, NULL, isjson);
 		message(io_data, MSG_PGANOID, id, NULL, isjson);
@@ -2717,7 +2717,7 @@ static void devdetails(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
 
 
 		root = api_add_int(root, "DEVDETAILS", &i, false);
 		root = api_add_int(root, "DEVDETAILS", &i, false);
 		root = api_add_device_identifier(root, cgpu);
 		root = api_add_device_identifier(root, cgpu);
-		root = api_add_string(root, "Driver", cgpu->api->dname, false);
+		root = api_add_string(root, "Driver", cgpu->drv->dname, false);
 		root = api_add_const(root, "Kernel", cgpu->kname ? : BLANK, false);
 		root = api_add_const(root, "Kernel", cgpu->kname ? : BLANK, false);
 		root = api_add_const(root, "Model", cgpu->name ? : BLANK, false);
 		root = api_add_const(root, "Model", cgpu->name ? : BLANK, false);
 		root = api_add_const(root, "Device Path", cgpu->device_path ? : BLANK, false);
 		root = api_add_const(root, "Device Path", cgpu->device_path ? : BLANK, false);
@@ -2824,9 +2824,9 @@ static void minerstats(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
 	for (j = 0; j < total_devices; j++) {
 	for (j = 0; j < total_devices; j++) {
 		cgpu = get_devices(j);
 		cgpu = get_devices(j);
 
 
-		if (cgpu && cgpu->api) {
-			if (cgpu->api->get_api_stats)
-				extra = cgpu->api->get_api_stats(cgpu);
+		if (cgpu && cgpu->drv) {
+			if (cgpu->drv->get_api_stats)
+				extra = cgpu->drv->get_api_stats(cgpu);
 			else
 			else
 				extra = NULL;
 				extra = NULL;
 
 
@@ -3030,7 +3030,7 @@ static void setconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char
 static void pgaset(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
 static void pgaset(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
 {
 {
 	struct cgpu_info *cgpu;
 	struct cgpu_info *cgpu;
-	const struct device_api *api;
+	const struct device_drv *drv;
 	char buf[TMPBUFSIZ];
 	char buf[TMPBUFSIZ];
 	int numpga = numpgas();
 	int numpga = numpgas();
 
 
@@ -3065,16 +3065,16 @@ static void pgaset(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe
 	}
 	}
 
 
 	cgpu = get_devices(dev);
 	cgpu = get_devices(dev);
-	api = cgpu->api;
+	drv = cgpu->drv;
 
 
 	char *set = strchr(opt, ',');
 	char *set = strchr(opt, ',');
 	if (set)
 	if (set)
 		*(set++) = '\0';
 		*(set++) = '\0';
 
 
-	if (!api->set_device)
+	if (!drv->set_device)
 		message(io_data, MSG_PGANOSET, id, NULL, isjson);
 		message(io_data, MSG_PGANOSET, id, NULL, isjson);
 	else {
 	else {
-		char *ret = api->set_device(cgpu, opt, set, buf);
+		char *ret = drv->set_device(cgpu, opt, set, buf);
 		if (ret) {
 		if (ret) {
 			if (strcasecmp(opt, "help") == 0)
 			if (strcasecmp(opt, "help") == 0)
 				message(io_data, MSG_PGAHELP, id, ret, isjson);
 				message(io_data, MSG_PGAHELP, id, ret, isjson);

+ 18 - 18
deviceapi.c

@@ -126,7 +126,7 @@ static
 struct work *get_and_prepare_work(struct thr_info *thr)
 struct work *get_and_prepare_work(struct thr_info *thr)
 {
 {
 	struct cgpu_info *proc = thr->cgpu;
 	struct cgpu_info *proc = thr->cgpu;
-	const struct device_api *api = proc->api;
+	const struct device_drv *api = proc->drv;
 	struct work *work;
 	struct work *work;
 	
 	
 	work = get_work(thr);
 	work = get_work(thr);
@@ -145,7 +145,7 @@ struct work *get_and_prepare_work(struct thr_info *thr)
 void minerloop_scanhash(struct thr_info *mythr)
 void minerloop_scanhash(struct thr_info *mythr)
 {
 {
 	struct cgpu_info *cgpu = mythr->cgpu;
 	struct cgpu_info *cgpu = mythr->cgpu;
-	const struct device_api *api = cgpu->api;
+	const struct device_drv *api = cgpu->drv;
 	struct timeval tv_start, tv_end;
 	struct timeval tv_start, tv_end;
 	struct timeval tv_hashes, tv_worktime;
 	struct timeval tv_hashes, tv_worktime;
 	uint32_t max_nonce = api->can_limit_work ? api->can_limit_work(mythr) : 0xffffffff;
 	uint32_t max_nonce = api->can_limit_work ? api->can_limit_work(mythr) : 0xffffffff;
@@ -200,7 +200,7 @@ disabled:
 bool do_job_prepare(struct thr_info *mythr, struct timeval *tvp_now)
 bool do_job_prepare(struct thr_info *mythr, struct timeval *tvp_now)
 {
 {
 	struct cgpu_info *proc = mythr->cgpu;
 	struct cgpu_info *proc = mythr->cgpu;
-	const struct device_api *api = proc->api;
+	const struct device_drv *api = proc->drv;
 	struct timeval tv_worktime;
 	struct timeval tv_worktime;
 	
 	
 	mythr->tv_morework.tv_sec = -1;
 	mythr->tv_morework.tv_sec = -1;
@@ -247,7 +247,7 @@ void job_prepare_complete(struct thr_info *mythr)
 void do_get_results(struct thr_info *mythr, bool proceed_with_new_job)
 void do_get_results(struct thr_info *mythr, bool proceed_with_new_job)
 {
 {
 	struct cgpu_info *proc = mythr->cgpu;
 	struct cgpu_info *proc = mythr->cgpu;
-	const struct device_api *api = proc->api;
+	const struct device_drv *api = proc->drv;
 	struct work *work = mythr->work;
 	struct work *work = mythr->work;
 	
 	
 	mythr->_job_transition_in_progress = true;
 	mythr->_job_transition_in_progress = true;
@@ -276,7 +276,7 @@ void job_results_fetched(struct thr_info *mythr)
 void do_job_start(struct thr_info *mythr)
 void do_job_start(struct thr_info *mythr)
 {
 {
 	struct cgpu_info *proc = mythr->cgpu;
 	struct cgpu_info *proc = mythr->cgpu;
-	const struct device_api *api = proc->api;
+	const struct device_drv *api = proc->drv;
 	
 	
 	thread_reportin(mythr);
 	thread_reportin(mythr);
 	api->job_start(mythr);
 	api->job_start(mythr);
@@ -323,7 +323,7 @@ void job_start_abort(struct thr_info *mythr, bool failure)
 bool do_process_results(struct thr_info *mythr, struct timeval *tvp_now, struct work *work, bool stopping)
 bool do_process_results(struct thr_info *mythr, struct timeval *tvp_now, struct work *work, bool stopping)
 {
 {
 	struct cgpu_info *proc = mythr->cgpu;
 	struct cgpu_info *proc = mythr->cgpu;
-	const struct device_api *api = proc->api;
+	const struct device_drv *api = proc->drv;
 	struct timeval tv_hashes;
 	struct timeval tv_hashes;
 	int64_t hashes = 0;
 	int64_t hashes = 0;
 	
 	
@@ -383,7 +383,7 @@ void minerloop_async(struct thr_info *mythr)
 {
 {
 	struct thr_info *thr = mythr;
 	struct thr_info *thr = mythr;
 	struct cgpu_info *cgpu = mythr->cgpu;
 	struct cgpu_info *cgpu = mythr->cgpu;
-	const struct device_api *api = cgpu->api;
+	const struct device_drv *api = cgpu->drv;
 	struct timeval tv_now;
 	struct timeval tv_now;
 	struct timeval tv_timeout;
 	struct timeval tv_timeout;
 	struct cgpu_info *proc;
 	struct cgpu_info *proc;
@@ -453,7 +453,7 @@ static
 void do_queue_flush(struct thr_info *mythr)
 void do_queue_flush(struct thr_info *mythr)
 {
 {
 	struct cgpu_info *proc = mythr->cgpu;
 	struct cgpu_info *proc = mythr->cgpu;
-	const struct device_api *api = proc->api;
+	const struct device_drv *api = proc->drv;
 	
 	
 	api->queue_flush(mythr);
 	api->queue_flush(mythr);
 	if (mythr->next_work)
 	if (mythr->next_work)
@@ -467,7 +467,7 @@ void minerloop_queue(struct thr_info *thr)
 {
 {
 	struct thr_info *mythr;
 	struct thr_info *mythr;
 	struct cgpu_info *cgpu = thr->cgpu;
 	struct cgpu_info *cgpu = thr->cgpu;
-	const struct device_api *api = cgpu->api;
+	const struct device_drv *api = cgpu->drv;
 	struct timeval tv_now;
 	struct timeval tv_now;
 	struct timeval tv_timeout;
 	struct timeval tv_timeout;
 	struct cgpu_info *proc;
 	struct cgpu_info *proc;
@@ -545,7 +545,7 @@ void *miner_thread(void *userdata)
 	struct thr_info *mythr = userdata;
 	struct thr_info *mythr = userdata;
 	const int thr_id = mythr->id;
 	const int thr_id = mythr->id;
 	struct cgpu_info *cgpu = mythr->cgpu;
 	struct cgpu_info *cgpu = mythr->cgpu;
-	const struct device_api *api = cgpu->api;
+	const struct device_drv *drv = cgpu->drv;
 
 
 	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
 	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
 
 
@@ -553,7 +553,7 @@ void *miner_thread(void *userdata)
 	snprintf(threadname, 20, "miner_%s", cgpu->proc_repr_ns);
 	snprintf(threadname, 20, "miner_%s", cgpu->proc_repr_ns);
 	RenameThread(threadname);
 	RenameThread(threadname);
 
 
-	if (api->thread_init && !api->thread_init(mythr)) {
+	if (drv->thread_init && !drv->thread_init(mythr)) {
 		dev_error(cgpu, REASON_THREAD_FAIL_INIT);
 		dev_error(cgpu, REASON_THREAD_FAIL_INIT);
 		for (struct cgpu_info *slave = cgpu->next_proc; slave && !slave->threads; slave = slave->next_proc)
 		for (struct cgpu_info *slave = cgpu->next_proc; slave && !slave->threads; slave = slave->next_proc)
 			dev_error(slave, REASON_THREAD_FAIL_INIT);
 			dev_error(slave, REASON_THREAD_FAIL_INIT);
@@ -564,14 +564,14 @@ void *miner_thread(void *userdata)
 	applog(LOG_DEBUG, "Popping ping in miner thread");
 	applog(LOG_DEBUG, "Popping ping in miner thread");
 	notifier_read(mythr->notifier);  // Wait for a notification to start
 	notifier_read(mythr->notifier);  // Wait for a notification to start
 
 
-	if (api->minerloop)
-		api->minerloop(mythr);
+	if (drv->minerloop)
+		drv->minerloop(mythr);
 	else
 	else
 		minerloop_scanhash(mythr);
 		minerloop_scanhash(mythr);
 
 
 out:
 out:
-	if (api->thread_shutdown)
-		api->thread_shutdown(mythr);
+	if (drv->thread_shutdown)
+		drv->thread_shutdown(mythr);
 
 
 	thread_reportin(mythr);
 	thread_reportin(mythr);
 	applog(LOG_ERR, "Thread %d failure, exiting", thr_id);
 	applog(LOG_ERR, "Thread %d failure, exiting", thr_id);
@@ -591,11 +591,11 @@ bool add_cgpu(struct cgpu_info*cgpu)
 	cgpu->device = cgpu;
 	cgpu->device = cgpu;
 	
 	
 	cgpu->dev_repr = malloc(6);
 	cgpu->dev_repr = malloc(6);
-	sprintf(cgpu->dev_repr, "%s%2u", cgpu->api->name, cgpu->device_id % 100);
+	sprintf(cgpu->dev_repr, "%s%2u", cgpu->drv->name, cgpu->device_id % 100);
 	cgpu->dev_repr_ns = malloc(6);
 	cgpu->dev_repr_ns = malloc(6);
-	sprintf(cgpu->dev_repr_ns, "%s%u", cgpu->api->name, cgpu->device_id % 100);
+	sprintf(cgpu->dev_repr_ns, "%s%u", cgpu->drv->name, cgpu->device_id % 100);
 	strcpy(cgpu->proc_repr, cgpu->dev_repr);
 	strcpy(cgpu->proc_repr, cgpu->dev_repr);
-	sprintf(cgpu->proc_repr_ns, "%s%u", cgpu->api->name, cgpu->device_id);
+	sprintf(cgpu->proc_repr_ns, "%s%u", cgpu->drv->name, cgpu->device_id);
 	
 	
 	mutex_lock(&devices_lock);
 	mutex_lock(&devices_lock);
 	
 	

+ 8 - 8
driver-avalon.c

@@ -39,7 +39,7 @@
 
 
 static int option_offset = -1;
 static int option_offset = -1;
 struct avalon_info **avalon_info;
 struct avalon_info **avalon_info;
-struct device_api avalon_api;
+struct device_drv avalon_drv;
 
 
 static inline uint8_t rev8(uint8_t d)
 static inline uint8_t rev8(uint8_t d)
 {
 {
@@ -560,7 +560,7 @@ static bool avalon_detect_one(const char *devpath)
 	/* We have a real Avalon! */
 	/* We have a real Avalon! */
 	struct cgpu_info *avalon;
 	struct cgpu_info *avalon;
 	avalon = calloc(1, sizeof(struct cgpu_info));
 	avalon = calloc(1, sizeof(struct cgpu_info));
-	avalon->api = &avalon_api;
+	avalon->drv = &avalon_drv;
 	avalon->device_path = strdup(devpath);
 	avalon->device_path = strdup(devpath);
 	avalon->device_fd = fd;
 	avalon->device_fd = fd;
 	avalon->threads = AVALON_MINER_THREADS;
 	avalon->threads = AVALON_MINER_THREADS;
@@ -610,7 +610,7 @@ static bool avalon_detect_one(const char *devpath)
 
 
 static inline void avalon_detect()
 static inline void avalon_detect()
 {
 {
-	serial_detect(&avalon_api, avalon_detect_one);
+	serial_detect(&avalon_drv, avalon_detect_one);
 }
 }
 
 
 static void avalon_init(struct cgpu_info *avalon)
 static void avalon_init(struct cgpu_info *avalon)
@@ -961,7 +961,7 @@ void minerloop_avalon(struct thr_info *mythr)
 {
 {
 	const int thr_id = mythr->id;
 	const int thr_id = mythr->id;
 	struct cgpu_info *cgpu = mythr->cgpu;
 	struct cgpu_info *cgpu = mythr->cgpu;
-	const struct device_api *api = cgpu->api;
+	const struct device_drv *api = cgpu->drv;
 	struct timeval tv_start, tv_end;
 	struct timeval tv_start, tv_end;
 	struct timeval tv_hashes;
 	struct timeval tv_hashes;
 	uint32_t max_nonce = api->can_limit_work ? api->can_limit_work(mythr) : 0xffffffff;
 	uint32_t max_nonce = api->can_limit_work ? api->can_limit_work(mythr) : 0xffffffff;
@@ -1026,7 +1026,7 @@ disabled:
 	free(work);
 	free(work);
 }
 }
 
 
-static struct api_data *avalon_api_stats(struct cgpu_info *cgpu)
+static struct api_data *avalon_drv_stats(struct cgpu_info *cgpu)
 {
 {
 	struct api_data *root = NULL;
 	struct api_data *root = NULL;
 	struct avalon_info *info = avalon_info[cgpu->device_id];
 	struct avalon_info *info = avalon_info[cgpu->device_id];
@@ -1081,14 +1081,14 @@ static void avalon_shutdown(struct thr_info *thr)
 	do_avalon_close(thr);
 	do_avalon_close(thr);
 }
 }
 
 
-struct device_api avalon_api = {
+struct device_drv avalon_drv = {
 	.dname = "avalon",
 	.dname = "avalon",
 	.name = "AVA",
 	.name = "AVA",
-	.api_detect = avalon_detect,
+	.drv_detect = avalon_detect,
 	.thread_prepare = avalon_prepare,
 	.thread_prepare = avalon_prepare,
 	.minerloop = minerloop_avalon,
 	.minerloop = minerloop_avalon,
 	.scanhash_queue = avalon_scanhash,
 	.scanhash_queue = avalon_scanhash,
-	.get_api_stats = avalon_api_stats,
+	.get_api_stats = avalon_drv_stats,
 	.reinit_device = avalon_init,
 	.reinit_device = avalon_init,
 	.thread_shutdown = avalon_shutdown,
 	.thread_shutdown = avalon_shutdown,
 };
 };

+ 13 - 13
driver-bitforce.c

@@ -53,8 +53,8 @@ static const char *protonames[] = {
 	"bulk queue",
 	"bulk queue",
 };
 };
 
 
-struct device_api bitforce_api;
-struct device_api bitforce_queue_api;
+struct device_drv bitforce_drv;
+struct device_drv bitforce_queue_api;
 
 
 // Code must deal with a timeout
 // Code must deal with a timeout
 #define BFopen(devpath)  serial_open(devpath, 0, 250, true)
 #define BFopen(devpath)  serial_open(devpath, 0, 250, true)
@@ -183,9 +183,9 @@ static bool bitforce_detect_one(const char *devpath)
 	
 	
 	// We have a real BitForce!
 	// We have a real BitForce!
 	bitforce = calloc(1, sizeof(*bitforce));
 	bitforce = calloc(1, sizeof(*bitforce));
-	bitforce->api = &bitforce_api;
+	bitforce->drv = &bitforce_drv;
 	if (initdata->sc)
 	if (initdata->sc)
-		bitforce->api = &bitforce_queue_api;
+		bitforce->drv = &bitforce_queue_api;
 	bitforce->device_path = strdup(devpath);
 	bitforce->device_path = strdup(devpath);
 	bitforce->deven = DEV_ENABLED;
 	bitforce->deven = DEV_ENABLED;
 	bitforce->procs = procs;
 	bitforce->procs = procs;
@@ -209,7 +209,7 @@ static int bitforce_detect_auto(void)
 
 
 static void bitforce_detect(void)
 static void bitforce_detect(void)
 {
 {
-	serial_detect_auto(&bitforce_api, bitforce_detect_one, bitforce_detect_auto);
+	serial_detect_auto(&bitforce_drv, bitforce_detect_one, bitforce_detect_auto);
 }
 }
 
 
 struct bitforce_data {
 struct bitforce_data {
@@ -378,7 +378,7 @@ void bitforce_reinit(struct cgpu_info *bitforce)
 
 
 	bitforce->sleep_ms = data->sleep_ms_default;
 	bitforce->sleep_ms = data->sleep_ms_default;
 	
 	
-	if (bitforce->api == &bitforce_queue_api)
+	if (bitforce->drv == &bitforce_queue_api)
 	{
 	{
 		struct list_head *pos, *npos;
 		struct list_head *pos, *npos;
 		struct work *work;
 		struct work *work;
@@ -1171,7 +1171,7 @@ static bool bitforce_thread_init(struct thr_info *thr)
 			data->next_work_ob[8+32+12+8] = '\xAA';
 			data->next_work_ob[8+32+12+8] = '\xAA';
 			data->next_work_obs = &data->next_work_ob[7];
 			data->next_work_obs = &data->next_work_ob[7];
 			
 			
-			if (bitforce->api == &bitforce_queue_api)
+			if (bitforce->drv == &bitforce_queue_api)
 			{
 			{
 				INIT_LIST_HEAD(&thr->work_list);
 				INIT_LIST_HEAD(&thr->work_list);
 				bitforce_change_mode(bitforce, BFP_BQUEUE);
 				bitforce_change_mode(bitforce, BFP_BQUEUE);
@@ -1210,7 +1210,7 @@ static bool bitforce_thread_init(struct thr_info *thr)
 	return true;
 	return true;
 }
 }
 
 
-static struct api_data *bitforce_api_stats(struct cgpu_info *cgpu)
+static struct api_data *bitforce_drv_stats(struct cgpu_info *cgpu)
 {
 {
 	struct bitforce_data *data = cgpu->cgpu_data;
 	struct bitforce_data *data = cgpu->cgpu_data;
 	struct api_data *root = NULL;
 	struct api_data *root = NULL;
@@ -1290,11 +1290,11 @@ char *bitforce_set_device(struct cgpu_info *proc, char *option, char *setting, c
 	return replybuf;
 	return replybuf;
 }
 }
 
 
-struct device_api bitforce_api = {
+struct device_drv bitforce_drv = {
 	.dname = "bitforce",
 	.dname = "bitforce",
 	.name = "BFL",
 	.name = "BFL",
-	.api_detect = bitforce_detect,
-	.get_api_stats = bitforce_api_stats,
+	.drv_detect = bitforce_detect,
+	.get_api_stats = bitforce_drv_stats,
 	.minerloop = minerloop_async,
 	.minerloop = minerloop_async,
 	.reinit_device = bitforce_reinit,
 	.reinit_device = bitforce_reinit,
 	.get_statline_before = get_bitforce_statline_before,
 	.get_statline_before = get_bitforce_statline_before,
@@ -1585,13 +1585,13 @@ void bitforce_queue_poll(struct thr_info *thr)
 	timer_set_delay_from_now(&thr->tv_poll, bitforce->sleep_ms * 1000);
 	timer_set_delay_from_now(&thr->tv_poll, bitforce->sleep_ms * 1000);
 }
 }
 
 
-struct device_api bitforce_queue_api = {
+struct device_drv bitforce_queue_api = {
 	.dname = "bitforce_queue",
 	.dname = "bitforce_queue",
 	.name = "BFL",
 	.name = "BFL",
 	.minerloop = minerloop_queue,
 	.minerloop = minerloop_queue,
 	.reinit_device = bitforce_reinit,
 	.reinit_device = bitforce_reinit,
 	.get_statline_before = get_bitforce_statline_before,
 	.get_statline_before = get_bitforce_statline_before,
-	.get_api_stats = bitforce_api_stats,
+	.get_api_stats = bitforce_drv_stats,
 	.get_stats = bitforce_get_stats,
 	.get_stats = bitforce_get_stats,
 	.set_device = bitforce_set_device,
 	.set_device = bitforce_set_device,
 	.identify_device = bitforce_identify,
 	.identify_device = bitforce_identify,

+ 19 - 19
driver-cairnsmore.c

@@ -22,9 +22,9 @@
 #define CAIRNSMORE1_DEFAULT_CLOCK  200
 #define CAIRNSMORE1_DEFAULT_CLOCK  200
 #define CAIRNSMORE1_MAXIMUM_CLOCK  210
 #define CAIRNSMORE1_MAXIMUM_CLOCK  210
 
 
-struct device_api cairnsmore_api;
+struct device_drv cairnsmore_drv;
 
 
-static void cairnsmore_api_init();
+static void cairnsmore_drv_init();
 
 
 static bool cairnsmore_detect_one(const char *devpath)
 static bool cairnsmore_detect_one(const char *devpath)
 {
 {
@@ -40,7 +40,7 @@ static bool cairnsmore_detect_one(const char *devpath)
 	info->timing_mode = MODE_LONG;
 	info->timing_mode = MODE_LONG;
 	info->do_icarus_timing = true;
 	info->do_icarus_timing = true;
 
 
-	if (!icarus_detect_custom(devpath, &cairnsmore_api, info)) {
+	if (!icarus_detect_custom(devpath, &cairnsmore_drv, info)) {
 		free(info);
 		free(info);
 		return false;
 		return false;
 	}
 	}
@@ -54,9 +54,9 @@ static int cairnsmore_detect_auto(void)
 
 
 static void cairnsmore_detect()
 static void cairnsmore_detect()
 {
 {
-	cairnsmore_api_init();
+	cairnsmore_drv_init();
 	// Actual serial detection is handled by Icarus driver
 	// Actual serial detection is handled by Icarus driver
-	serial_detect_auto_byname(&cairnsmore_api, cairnsmore_detect_one, cairnsmore_detect_auto);
+	serial_detect_auto_byname(&cairnsmore_drv, cairnsmore_detect_one, cairnsmore_detect_auto);
 }
 }
 
 
 static bool cairnsmore_send_cmd(int fd, uint8_t cmd, uint8_t data, bool probe)
 static bool cairnsmore_send_cmd(int fd, uint8_t cmd, uint8_t data, bool probe)
@@ -165,12 +165,12 @@ void convert_icarus_to_cairnsmore(struct cgpu_info *cm1)
 	info->fullnonce = info->Hs * (((double)0xffffffff) + 1);
 	info->fullnonce = info->Hs * (((double)0xffffffff) + 1);
 	info->timing_mode = MODE_LONG;
 	info->timing_mode = MODE_LONG;
 	info->do_icarus_timing = true;
 	info->do_icarus_timing = true;
-	cm1->api = &cairnsmore_api;
+	cm1->drv = &cairnsmore_drv;
 	renumber_cgpu(cm1);
 	renumber_cgpu(cm1);
 	cairnsmore_init(cm1->thr[0]);
 	cairnsmore_init(cm1->thr[0]);
 }
 }
 
 
-static struct api_data *cairnsmore_api_extra_device_status(struct cgpu_info *cm1)
+static struct api_data *cairnsmore_drv_extra_device_status(struct cgpu_info *cm1)
 {
 {
 	struct ICARUS_INFO *info = cm1->cgpu_data;
 	struct ICARUS_INFO *info = cm1->cgpu_data;
 	struct api_data*root = NULL;
 	struct api_data*root = NULL;
@@ -196,20 +196,20 @@ static bool cairnsmore_identify(struct cgpu_info *cm1)
 	return true;
 	return true;
 }
 }
 
 
-extern struct device_api icarus_api;
+extern struct device_drv icarus_drv;
 
 
-static void cairnsmore_api_init()
+static void cairnsmore_drv_init()
 {
 {
-	cairnsmore_api = icarus_api;
-	cairnsmore_api.dname = "cairnsmore";
-	cairnsmore_api.name = "ECM";
-	cairnsmore_api.api_detect = cairnsmore_detect;
-	cairnsmore_api.thread_init = cairnsmore_init;
-	cairnsmore_api.identify_device = cairnsmore_identify;
-	cairnsmore_api.get_api_extra_device_status = cairnsmore_api_extra_device_status;
+	cairnsmore_drv = icarus_drv;
+	cairnsmore_drv.dname = "cairnsmore";
+	cairnsmore_drv.name = "ECM";
+	cairnsmore_drv.drv_detect = cairnsmore_detect;
+	cairnsmore_drv.thread_init = cairnsmore_init;
+	cairnsmore_drv.identify_device = cairnsmore_identify;
+	cairnsmore_drv.get_api_extra_device_status = cairnsmore_drv_extra_device_status;
 }
 }
 
 
-struct device_api cairnsmore_api = {
-	// Needed to get to cairnsmore_api_init at all
-	.api_detect = cairnsmore_detect,
+struct device_drv cairnsmore_drv = {
+	// Needed to get to cairnsmore_drv_init at all
+	.drv_detect = cairnsmore_detect,
 };
 };

+ 3 - 3
driver-cpu.c

@@ -770,7 +770,7 @@ static void cpu_detect()
 		struct cgpu_info *cgpu;
 		struct cgpu_info *cgpu;
 
 
 		cgpu = &cpus[i];
 		cgpu = &cpus[i];
-		cgpu->api = &cpu_api;
+		cgpu->drv = &cpu_drv;
 		cgpu->devtype = "CPU";
 		cgpu->devtype = "CPU";
 		cgpu->deven = DEV_ENABLED;
 		cgpu->deven = DEV_ENABLED;
 		cgpu->threads = 1;
 		cgpu->threads = 1;
@@ -850,10 +850,10 @@ CPUSearch:
 	return last_nonce - first_nonce + 1;
 	return last_nonce - first_nonce + 1;
 }
 }
 
 
-struct device_api cpu_api = {
+struct device_drv cpu_drv = {
 	.dname = "cpu",
 	.dname = "cpu",
 	.name = "CPU",
 	.name = "CPU",
-	.api_detect = cpu_detect,
+	.drv_detect = cpu_detect,
 	.thread_prepare = cpu_thread_prepare,
 	.thread_prepare = cpu_thread_prepare,
 	.can_limit_work = cpu_can_limit_work,
 	.can_limit_work = cpu_can_limit_work,
 	.thread_init = cpu_thread_init,
 	.thread_init = cpu_thread_init,

+ 1 - 1
driver-cpu.h

@@ -53,7 +53,7 @@ enum sha256_algos {
 
 
 extern const char *algo_names[];
 extern const char *algo_names[];
 extern bool opt_usecpu;
 extern bool opt_usecpu;
-extern struct device_api cpu_api;
+extern struct device_drv cpu_drv;
 
 
 extern char *set_algo(const char *arg, enum sha256_algos *algo);
 extern char *set_algo(const char *arg, enum sha256_algos *algo);
 extern void show_algo(char buf[OPT_SHOW_LEN], const enum sha256_algos *algo);
 extern void show_algo(char buf[OPT_SHOW_LEN], const enum sha256_algos *algo);

+ 10 - 10
driver-icarus.c

@@ -159,7 +159,7 @@ static const char *MODE_UNKNOWN_STR = "unknown";
 //
 //
 static int option_offset = -1;
 static int option_offset = -1;
 
 
-struct device_api icarus_api;
+struct device_drv icarus_drv;
 
 
 extern void convert_icarus_to_cairnsmore(struct cgpu_info *);
 extern void convert_icarus_to_cairnsmore(struct cgpu_info *);
 
 
@@ -389,7 +389,7 @@ static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus)
 		int def_read_count = ICARUS_READ_COUNT_TIMING;
 		int def_read_count = ICARUS_READ_COUNT_TIMING;
 
 
 		if (info->timing_mode == MODE_DEFAULT) {
 		if (info->timing_mode == MODE_DEFAULT) {
-			if (icarus->api == &icarus_api) {
+			if (icarus->drv == &icarus_drv) {
 				info->do_default_detection = 0x10;
 				info->do_default_detection = 0x10;
 			} else {
 			} else {
 				def_read_count = (int)(info->fullnonce * TIME_FACTOR) - 1;
 				def_read_count = (int)(info->fullnonce * TIME_FACTOR) - 1;
@@ -531,7 +531,7 @@ static void get_options(int this_option_offset, struct ICARUS_INFO *info)
 	}
 	}
 }
 }
 
 
-bool icarus_detect_custom(const char *devpath, struct device_api *api, struct ICARUS_INFO *info)
+bool icarus_detect_custom(const char *devpath, struct device_drv *api, struct ICARUS_INFO *info)
 {
 {
 	int this_option_offset = ++option_offset;
 	int this_option_offset = ++option_offset;
 
 
@@ -607,7 +607,7 @@ bool icarus_detect_custom(const char *devpath, struct device_api *api, struct IC
 	/* We have a real Icarus! */
 	/* We have a real Icarus! */
 	struct cgpu_info *icarus;
 	struct cgpu_info *icarus;
 	icarus = calloc(1, sizeof(struct cgpu_info));
 	icarus = calloc(1, sizeof(struct cgpu_info));
-	icarus->api = api;
+	icarus->drv = api;
 	icarus->device_path = strdup(devpath);
 	icarus->device_path = strdup(devpath);
 	icarus->device_fd = -1;
 	icarus->device_fd = -1;
 	icarus->threads = 1;
 	icarus->threads = 1;
@@ -646,7 +646,7 @@ static bool icarus_detect_one(const char *devpath)
 	info->Hs = ICARUS_REV3_HASH_TIME;
 	info->Hs = ICARUS_REV3_HASH_TIME;
 	info->timing_mode = MODE_DEFAULT;
 	info->timing_mode = MODE_DEFAULT;
 
 
-	if (!icarus_detect_custom(devpath, &icarus_api, info)) {
+	if (!icarus_detect_custom(devpath, &icarus_drv, info)) {
 		free(info);
 		free(info);
 		return false;
 		return false;
 	}
 	}
@@ -655,7 +655,7 @@ static bool icarus_detect_one(const char *devpath)
 
 
 static void icarus_detect()
 static void icarus_detect()
 {
 {
-	serial_detect(&icarus_api, icarus_detect_one);
+	serial_detect(&icarus_drv, icarus_detect_one);
 }
 }
 
 
 static bool icarus_prepare(struct thr_info *thr)
 static bool icarus_prepare(struct thr_info *thr)
@@ -1048,7 +1048,7 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 	return hash_count;
 	return hash_count;
 }
 }
 
 
-static struct api_data *icarus_api_stats(struct cgpu_info *cgpu)
+static struct api_data *icarus_drv_stats(struct cgpu_info *cgpu)
 {
 {
 	struct api_data *root = NULL;
 	struct api_data *root = NULL;
 	struct ICARUS_INFO *info = cgpu->cgpu_data;
 	struct ICARUS_INFO *info = cgpu->cgpu_data;
@@ -1083,11 +1083,11 @@ static void icarus_shutdown(struct thr_info *thr)
 	free(thr->cgpu_data);
 	free(thr->cgpu_data);
 }
 }
 
 
-struct device_api icarus_api = {
+struct device_drv icarus_drv = {
 	.dname = "icarus",
 	.dname = "icarus",
 	.name = "ICA",
 	.name = "ICA",
-	.api_detect = icarus_detect,
-	.get_api_stats = icarus_api_stats,
+	.drv_detect = icarus_detect,
+	.get_api_stats = icarus_drv_stats,
 	.thread_prepare = icarus_prepare,
 	.thread_prepare = icarus_prepare,
 	.scanhash = icarus_scanhash,
 	.scanhash = icarus_scanhash,
 	.thread_shutdown = icarus_shutdown,
 	.thread_shutdown = icarus_shutdown,

+ 8 - 8
driver-modminer.c

@@ -46,7 +46,7 @@
 
 
 #define FPGAID_ALL 4
 #define FPGAID_ALL 4
 
 
-struct device_api modminer_api;
+struct device_drv modminer_drv;
 
 
 struct modminer_fpga_state {
 struct modminer_fpga_state {
 	bool work_running;
 	bool work_running;
@@ -133,7 +133,7 @@ modminer_detect_one(const char *devpath)
 
 
 	struct cgpu_info *modminer;
 	struct cgpu_info *modminer;
 	modminer = calloc(1, sizeof(*modminer));
 	modminer = calloc(1, sizeof(*modminer));
-	modminer->api = &modminer_api;
+	modminer->drv = &modminer_drv;
 	mutex_init(&modminer->device_mutex);
 	mutex_init(&modminer->device_mutex);
 	modminer->device_path = strdup(devpath);
 	modminer->device_path = strdup(devpath);
 	modminer->device_fd = -1;
 	modminer->device_fd = -1;
@@ -157,7 +157,7 @@ modminer_detect_auto()
 static void
 static void
 modminer_detect()
 modminer_detect()
 {
 {
-	serial_detect_auto(&modminer_api, modminer_detect_one, modminer_detect_auto);
+	serial_detect_auto(&modminer_drv, modminer_detect_one, modminer_detect_auto);
 }
 }
 
 
 #define bailout(...)  return _bailout(-1, modminer, __VA_ARGS__);
 #define bailout(...)  return _bailout(-1, modminer, __VA_ARGS__);
@@ -220,7 +220,7 @@ modminer_fpga_upload_bitstream(struct cgpu_info*modminer)
 	char buf[0x100];
 	char buf[0x100];
 	unsigned long len, flen;
 	unsigned long len, flen;
 	char fpgaid = FPGAID_ALL;
 	char fpgaid = FPGAID_ALL;
-	FILE *f = open_xilinx_bitstream(modminer->api->dname, modminer->dev_repr, BITSTREAM_FILENAME, &len);
+	FILE *f = open_xilinx_bitstream(modminer->drv->dname, modminer->dev_repr, BITSTREAM_FILENAME, &len);
 	if (!f)
 	if (!f)
 		return false;
 		return false;
 
 
@@ -587,7 +587,7 @@ static bool modminer_get_stats(struct cgpu_info *modminer)
 }
 }
 
 
 static struct api_data*
 static struct api_data*
-get_modminer_api_extra_device_status(struct cgpu_info*modminer)
+get_modminer_drv_extra_device_status(struct cgpu_info*modminer)
 {
 {
 	struct api_data*root = NULL;
 	struct api_data*root = NULL;
 	struct thr_info*thr = modminer->thr[0];
 	struct thr_info*thr = modminer->thr[0];
@@ -840,14 +840,14 @@ static char *modminer_set_device(struct cgpu_info *modminer, char *option, char
 	return replybuf;
 	return replybuf;
 }
 }
 
 
-struct device_api modminer_api = {
+struct device_drv modminer_drv = {
 	.dname = "modminer",
 	.dname = "modminer",
 	.name = "MMQ",
 	.name = "MMQ",
-	.api_detect = modminer_detect,
+	.drv_detect = modminer_detect,
 	.get_dev_statline_before = get_modminer_dev_statline_before,
 	.get_dev_statline_before = get_modminer_dev_statline_before,
 	.get_statline_before = get_modminer_statline_before,
 	.get_statline_before = get_modminer_statline_before,
 	.get_stats = modminer_get_stats,
 	.get_stats = modminer_get_stats,
-	.get_api_extra_device_status = get_modminer_api_extra_device_status,
+	.get_api_extra_device_status = get_modminer_drv_extra_device_status,
 	.set_device = modminer_set_device,
 	.set_device = modminer_set_device,
 	.thread_prepare = modminer_fpga_prepare,
 	.thread_prepare = modminer_fpga_prepare,
 	.thread_init = modminer_fpga_init,
 	.thread_init = modminer_fpga_init,

+ 7 - 7
driver-opencl.c

@@ -793,12 +793,12 @@ char *set_intensity(char *arg)
 
 
 
 
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
-struct device_api opencl_api;
+struct device_drv opencl_api;
 
 
 char *print_ndevs_and_exit(int *ndevs)
 char *print_ndevs_and_exit(int *ndevs)
 {
 {
 	opt_log_output = true;
 	opt_log_output = true;
-	opencl_api.api_detect();
+	opencl_api.drv_detect();
 	clear_adl(*ndevs);
 	clear_adl(*ndevs);
 	applog(LOG_INFO, "%i GPU devices max detected", *ndevs);
 	applog(LOG_INFO, "%i GPU devices max detected", *ndevs);
 	exit(*ndevs);
 	exit(*ndevs);
@@ -837,7 +837,7 @@ void pause_dynamic_threads(int gpu)
 }
 }
 
 
 
 
-struct device_api opencl_api;
+struct device_drv opencl_api;
 
 
 #endif /* HAVE_OPENCL */
 #endif /* HAVE_OPENCL */
 
 
@@ -1413,7 +1413,7 @@ void *reinit_gpu(__maybe_unused void *userdata)
 
 
 
 
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
-struct device_api opencl_api;
+struct device_drv opencl_api;
 
 
 static void opencl_detect()
 static void opencl_detect()
 {
 {
@@ -1461,7 +1461,7 @@ static void opencl_detect()
 		cgpu = &gpus[i];
 		cgpu = &gpus[i];
 		cgpu->devtype = "GPU";
 		cgpu->devtype = "GPU";
 		cgpu->deven = DEV_ENABLED;
 		cgpu->deven = DEV_ENABLED;
-		cgpu->api = &opencl_api;
+		cgpu->drv = &opencl_api;
 		cgpu->device_id = i;
 		cgpu->device_id = i;
 		cgpu->threads = opt_g_threads;
 		cgpu->threads = opt_g_threads;
 		cgpu->virtual_gpu = i;
 		cgpu->virtual_gpu = i;
@@ -1827,10 +1827,10 @@ static void opencl_thread_shutdown(struct thr_info *thr)
 	clReleaseContext(clState->context);
 	clReleaseContext(clState->context);
 }
 }
 
 
-struct device_api opencl_api = {
+struct device_drv opencl_api = {
 	.dname = "opencl",
 	.dname = "opencl",
 	.name = "OCL",
 	.name = "OCL",
-	.api_detect = opencl_detect,
+	.drv_detect = opencl_detect,
 	.reinit_device = reinit_opencl_device,
 	.reinit_device = reinit_opencl_device,
 	.get_statline_before = get_opencl_statline_before,
 	.get_statline_before = get_opencl_statline_before,
 	.get_api_extra_device_status = get_opencl_api_extra_device_status,
 	.get_api_extra_device_status = get_opencl_api_extra_device_status,

+ 1 - 1
driver-opencl.h

@@ -32,6 +32,6 @@ extern bool have_opencl;
 extern int opt_platform_id;
 extern int opt_platform_id;
 extern bool opt_opencl_binaries;
 extern bool opt_opencl_binaries;
 
 
-extern struct device_api opencl_api;
+extern struct device_drv opencl_api;
 
 
 #endif /* __DEVICE_GPU_H__ */
 #endif /* __DEVICE_GPU_H__ */

+ 5 - 5
driver-x6500.c

@@ -35,7 +35,7 @@
 #define X6500_DEFAULT_CLOCK  200
 #define X6500_DEFAULT_CLOCK  200
 #define X6500_MAXIMUM_CLOCK  250
 #define X6500_MAXIMUM_CLOCK  250
 
 
-struct device_api x6500_api;
+struct device_drv x6500_api;
 
 
 #define fromlebytes(ca, j)  (ca[j] | (((uint16_t)ca[j+1])<<8) | (((uint32_t)ca[j+2])<<16) | (((uint32_t)ca[j+3])<<24))
 #define fromlebytes(ca, j)  (ca[j] | (((uint16_t)ca[j+1])<<8) | (((uint32_t)ca[j+2])<<16) | (((uint32_t)ca[j+3])<<24))
 
 
@@ -126,7 +126,7 @@ static bool x6500_foundusb(libusb_device *dev, const char *product, const char *
 {
 {
 	struct cgpu_info *x6500;
 	struct cgpu_info *x6500;
 	x6500 = calloc(1, sizeof(*x6500));
 	x6500 = calloc(1, sizeof(*x6500));
-	x6500->api = &x6500_api;
+	x6500->drv = &x6500_api;
 	mutex_init(&x6500->device_mutex);
 	mutex_init(&x6500->device_mutex);
 	x6500->device_path = strdup(serial);
 	x6500->device_path = strdup(serial);
 	x6500->deven = DEV_ENABLED;
 	x6500->deven = DEV_ENABLED;
@@ -216,7 +216,7 @@ x6500_fpga_upload_bitstream(struct cgpu_info *x6500, struct jtag_port *jp1)
 	unsigned char *pdone = (unsigned char*)x6500->cgpu_data - 1;
 	unsigned char *pdone = (unsigned char*)x6500->cgpu_data - 1;
 	struct ft232r_device_handle *ftdi = jp1->a->ftdi;
 	struct ft232r_device_handle *ftdi = jp1->a->ftdi;
 
 
-	FILE *f = open_xilinx_bitstream(x6500->api->dname, x6500->dev_repr, X6500_BITSTREAM_FILENAME, &len);
+	FILE *f = open_xilinx_bitstream(x6500->drv->dname, x6500->dev_repr, X6500_BITSTREAM_FILENAME, &len);
 	if (!f)
 	if (!f)
 		return false;
 		return false;
 
 
@@ -782,10 +782,10 @@ void x6500_fpga_poll(struct thr_info *thr)
 		timer_set_delay_from_now(&thr->tv_poll, 10000);
 		timer_set_delay_from_now(&thr->tv_poll, 10000);
 }
 }
 
 
-struct device_api x6500_api = {
+struct device_drv x6500_api = {
 	.dname = "x6500",
 	.dname = "x6500",
 	.name = "XBS",
 	.name = "XBS",
-	.api_detect = x6500_detect,
+	.drv_detect = x6500_detect,
 	.get_dev_statline_before = get_x6500_dev_statline_before,
 	.get_dev_statline_before = get_x6500_dev_statline_before,
 	.thread_prepare = x6500_prepare,
 	.thread_prepare = x6500_prepare,
 	.thread_init = x6500_thread_init,
 	.thread_init = x6500_thread_init,

+ 7 - 7
driver-ztex.c

@@ -36,7 +36,7 @@
 
 
 #define GOLDEN_BACKLOG 5
 #define GOLDEN_BACKLOG 5
 
 
-struct device_api ztex_api;
+struct device_drv ztex_drv;
 
 
 // Forward declarations
 // Forward declarations
 static void ztex_disable(struct thr_info* thr);
 static void ztex_disable(struct thr_info* thr);
@@ -65,7 +65,7 @@ static struct cgpu_info *ztex_setup(struct libztex_device *dev, int j, int fpgac
 	char *fpganame = (char*)dev->snString;
 	char *fpganame = (char*)dev->snString;
 
 
 	ztex = calloc(1, sizeof(struct cgpu_info));
 	ztex = calloc(1, sizeof(struct cgpu_info));
-	ztex->api = &ztex_api;
+	ztex->drv = &ztex_drv;
 	ztex->device_ztex = dev;
 	ztex->device_ztex = dev;
 	ztex->procs = fpgacount;
 	ztex->procs = fpgacount;
 	ztex->threads = fpgacount;
 	ztex->threads = fpgacount;
@@ -113,7 +113,7 @@ static int ztex_autodetect(void)
 static void ztex_detect()
 static void ztex_detect()
 {
 {
 	// This wrapper ensures users can specify -S ztex:noauto to disable it
 	// This wrapper ensures users can specify -S ztex:noauto to disable it
-	noserial_detect(&ztex_api, ztex_autodetect);
+	noserial_detect(&ztex_drv, ztex_autodetect);
 }
 }
 
 
 static bool ztex_change_clock_func(struct thr_info *thr, int bestM)
 static bool ztex_change_clock_func(struct thr_info *thr, int bestM)
@@ -338,7 +338,7 @@ static void ztex_statline_before(char *buf, struct cgpu_info *cgpu)
 }
 }
 
 
 static struct api_data*
 static struct api_data*
-get_ztex_api_extra_device_status(struct cgpu_info *ztex)
+get_ztex_drv_extra_device_status(struct cgpu_info *ztex)
 {
 {
 	struct api_data*root = NULL;
 	struct api_data*root = NULL;
 	struct libztex_device *ztexr = ztex->device_ztex;
 	struct libztex_device *ztexr = ztex->device_ztex;
@@ -416,12 +416,12 @@ static void ztex_disable(struct thr_info *thr)
 	ztex_shutdown(thr);
 	ztex_shutdown(thr);
 }
 }
 
 
-struct device_api ztex_api = {
+struct device_drv ztex_drv = {
 	.dname = "ztex",
 	.dname = "ztex",
 	.name = "ZTX",
 	.name = "ZTX",
-	.api_detect = ztex_detect,
+	.drv_detect = ztex_detect,
 	.get_statline_before = ztex_statline_before,
 	.get_statline_before = ztex_statline_before,
-	.get_api_extra_device_status = get_ztex_api_extra_device_status,
+	.get_api_extra_device_status = get_ztex_drv_extra_device_status,
 	.thread_init = ztex_prepare,
 	.thread_init = ztex_prepare,
 	.scanhash = ztex_scanhash,
 	.scanhash = ztex_scanhash,
 	.thread_shutdown = ztex_shutdown,
 	.thread_shutdown = ztex_shutdown,

+ 6 - 6
fpgautils.c

@@ -346,9 +346,9 @@ int _serial_autodetect(detectone_func_t detectone, ...)
 	return rv;
 	return rv;
 }
 }
 
 
-struct device_api *serial_claim(const char *devpath, struct device_api *api);
+struct device_drv *serial_claim(const char *devpath, struct device_drv *api);
 
 
-int _serial_detect(struct device_api *api, detectone_func_t detectone, autoscan_func_t autoscan, int flags)
+int _serial_detect(struct device_drv *api, detectone_func_t detectone, autoscan_func_t autoscan, int flags)
 {
 {
 	struct string_elist *iter, *tmp;
 	struct string_elist *iter, *tmp;
 	const char *dev, *colon;
 	const char *dev, *colon;
@@ -410,12 +410,12 @@ typedef int my_dev_t;
 #endif
 #endif
 
 
 struct _device_claim {
 struct _device_claim {
-	struct device_api *api;
+	struct device_drv *drv;
 	my_dev_t dev;
 	my_dev_t dev;
 	UT_hash_handle hh;
 	UT_hash_handle hh;
 };
 };
 
 
-struct device_api *serial_claim(const char *devpath, struct device_api *api)
+struct device_drv *serial_claim(const char *devpath, struct device_drv *api)
 {
 {
 	static struct _device_claim *claims = NULL;
 	static struct _device_claim *claims = NULL;
 	struct _device_claim *c;
 	struct _device_claim *c;
@@ -441,14 +441,14 @@ struct device_api *serial_claim(const char *devpath, struct device_api *api)
 
 
 	HASH_FIND(hh, claims, &dev, sizeof(dev), c);
 	HASH_FIND(hh, claims, &dev, sizeof(dev), c);
 	if (c)
 	if (c)
-		return c->api;
+		return c->drv;
 
 
 	if (!api)
 	if (!api)
 		return NULL;
 		return NULL;
 
 
 	c = malloc(sizeof(*c));
 	c = malloc(sizeof(*c));
 	c->dev = dev;
 	c->dev = dev;
-	c->api = api;
+	c->drv = api;
 	HASH_ADD(hh, claims, dev, sizeof(dev), c);
 	HASH_ADD(hh, claims, dev, sizeof(dev), c);
 	return NULL;
 	return NULL;
 }
 }

+ 3 - 3
fpgautils.h

@@ -6,13 +6,13 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <unistd.h>
 
 
-struct device_api;
+struct device_drv;
 struct cgpu_info;
 struct cgpu_info;
 
 
 typedef bool(*detectone_func_t)(const char*);
 typedef bool(*detectone_func_t)(const char*);
 typedef int(*autoscan_func_t)();
 typedef int(*autoscan_func_t)();
 
 
-extern int _serial_detect(struct device_api *api, detectone_func_t, autoscan_func_t, int flags);
+extern int _serial_detect(struct device_drv *api, detectone_func_t, autoscan_func_t, int flags);
 #define serial_detect_fauto(api, detectone, autoscan)  \
 #define serial_detect_fauto(api, detectone, autoscan)  \
 	_serial_detect(api, detectone, autoscan, 1)
 	_serial_detect(api, detectone, autoscan, 1)
 #define serial_detect_auto(api, detectone, autoscan)  \
 #define serial_detect_auto(api, detectone, autoscan)  \
@@ -26,7 +26,7 @@ extern int _serial_detect(struct device_api *api, detectone_func_t, autoscan_fun
 extern int _serial_autodetect(detectone_func_t, ...);
 extern int _serial_autodetect(detectone_func_t, ...);
 #define serial_autodetect(...)  _serial_autodetect(__VA_ARGS__, NULL)
 #define serial_autodetect(...)  _serial_autodetect(__VA_ARGS__, NULL)
 
 
-extern struct device_api *serial_claim(const char *devpath, struct device_api *);
+extern struct device_drv *serial_claim(const char *devpath, struct device_drv *);
 
 
 extern int serial_open(const char *devpath, unsigned long baud, uint8_t timeout, bool purge);
 extern int serial_open(const char *devpath, unsigned long baud, uint8_t timeout, bool purge);
 extern ssize_t _serial_read(int fd, char *buf, size_t buflen, char *eol);
 extern ssize_t _serial_read(int fd, char *buf, size_t buflen, char *eol);

+ 1 - 1
icarus-common.h

@@ -84,7 +84,7 @@ struct icarus_state {
 	bool changework;
 	bool changework;
 };
 };
 
 
-bool icarus_detect_custom(const char *devpath, struct device_api *, struct ICARUS_INFO *);
+bool icarus_detect_custom(const char *devpath, struct device_drv *, struct ICARUS_INFO *);
 extern int icarus_gets(unsigned char *, int fd, struct timeval *tv_finish, struct thr_info *, int read_count);
 extern int icarus_gets(unsigned char *, int fd, struct timeval *tv_finish, struct thr_info *, int read_count);
 
 
 #endif
 #endif

+ 46 - 46
miner.c

@@ -2275,7 +2275,7 @@ static void get_statline2(char *buf, struct cgpu_info *cgpu, bool for_curses)
 #else
 #else
 	assert(for_curses == false);
 	assert(for_curses == false);
 #endif
 #endif
-	const struct device_api *api = cgpu->api;
+	const struct device_drv *drv = cgpu->drv;
 	void (*statline_func)(char *, struct cgpu_info *);
 	void (*statline_func)(char *, struct cgpu_info *);
 	enum h2bs_fmt hashrate_style = for_curses ? H2B_SHORT : H2B_SPACED;
 	enum h2bs_fmt hashrate_style = for_curses ? H2B_SHORT : H2B_SPACED;
 	char cHr[h2bs_fmt_size[H2B_NOUNIT]], aHr[h2bs_fmt_size[H2B_NOUNIT]], uHr[h2bs_fmt_size[hashrate_style]];
 	char cHr[h2bs_fmt_size[H2B_NOUNIT]], aHr[h2bs_fmt_size[H2B_NOUNIT]], uHr[h2bs_fmt_size[hashrate_style]];
@@ -2329,12 +2329,12 @@ static void get_statline2(char *buf, struct cgpu_info *cgpu, bool for_curses)
 #endif
 #endif
 		sprintf(buf, "%s ", opt_show_procs ? cgpu->proc_repr_ns : cgpu->dev_repr_ns);
 		sprintf(buf, "%s ", opt_show_procs ? cgpu->proc_repr_ns : cgpu->dev_repr_ns);
 	
 	
-	if (api->get_dev_statline_before || api->get_statline_before)
+	if (drv->get_dev_statline_before || drv->get_statline_before)
 	{
 	{
-		if (api->get_dev_statline_before && api->get_statline_before)
-			statline_func = opt_show_procs ? api->get_statline_before : api->get_dev_statline_before;
+		if (drv->get_dev_statline_before && drv->get_statline_before)
+			statline_func = opt_show_procs ? drv->get_statline_before : drv->get_dev_statline_before;
 		else
 		else
-			statline_func = api->get_statline_before ?: api->get_dev_statline_before;
+			statline_func = drv->get_statline_before ?: drv->get_dev_statline_before;
 		statline_func(buf, cgpu);
 		statline_func(buf, cgpu);
 	}
 	}
 	else
 	else
@@ -2407,12 +2407,12 @@ static void get_statline2(char *buf, struct cgpu_info *cgpu, bool for_curses)
 			util);
 			util);
 	}
 	}
 	
 	
-	if (api->get_dev_statline_after || api->get_statline)
+	if (drv->get_dev_statline_after || drv->get_statline)
 	{
 	{
-		if (api->get_dev_statline_after && api->get_statline)
-			statline_func = opt_show_procs ? api->get_statline : api->get_dev_statline_after;
+		if (drv->get_dev_statline_after && drv->get_statline)
+			statline_func = opt_show_procs ? drv->get_statline : drv->get_dev_statline_after;
 		else
 		else
-			statline_func = api->get_statline ?: api->get_dev_statline_after;
+			statline_func = drv->get_statline ?: drv->get_dev_statline_after;
 		statline_func(buf, cgpu);
 		statline_func(buf, cgpu);
 	}
 	}
 }
 }
@@ -6893,8 +6893,8 @@ void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
 			++thr->cgpu->hw_errors;
 			++thr->cgpu->hw_errors;
 			mutex_unlock(&stats_lock);
 			mutex_unlock(&stats_lock);
 
 
-			if (thr->cgpu->api->hw_error)
-				thr->cgpu->api->hw_error(thr);
+			if (thr->cgpu->drv->hw_error)
+				thr->cgpu->drv->hw_error(thr);
 			goto out;
 			goto out;
 		}
 		}
 	
 	
@@ -6950,12 +6950,12 @@ void mt_disable_start(struct thr_info *mythr)
 
 
 void mt_disable_finish(struct thr_info *mythr)
 void mt_disable_finish(struct thr_info *mythr)
 {
 {
-	const struct device_api *api = mythr->cgpu->api;
+	const struct device_drv *drv = mythr->cgpu->drv;
 	
 	
 	thread_reportin(mythr);
 	thread_reportin(mythr);
 	__thr_being_msg(mythr, "re-enabled");
 	__thr_being_msg(mythr, "re-enabled");
-	if (api->thread_enable)
-		api->thread_enable(mythr);
+	if (drv->thread_enable)
+		drv->thread_enable(mythr);
 }
 }
 
 
 void mt_disable(struct thr_info *mythr)
 void mt_disable(struct thr_info *mythr)
@@ -7235,8 +7235,8 @@ static void start_longpoll(void)
 
 
 void reinit_device(struct cgpu_info *cgpu)
 void reinit_device(struct cgpu_info *cgpu)
 {
 {
-	if (cgpu->api->reinit_device)
-		cgpu->api->reinit_device(cgpu);
+	if (cgpu->drv->reinit_device)
+		cgpu->drv->reinit_device(cgpu);
 }
 }
 
 
 static struct timeval rotate_tv;
 static struct timeval rotate_tv;
@@ -7436,8 +7436,8 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 			char *dev_str = cgpu->proc_repr;
 			char *dev_str = cgpu->proc_repr;
 			int gpu;
 			int gpu;
 
 
-			if (cgpu->api->get_stats)
-			  cgpu->api->get_stats(cgpu);
+			if (cgpu->drv->get_stats)
+			  cgpu->drv->get_stats(cgpu);
 
 
 			gpu = cgpu->device_id;
 			gpu = cgpu->device_id;
 			denable = &cgpu->deven;
 			denable = &cgpu->deven;
@@ -7509,7 +7509,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 				cgpu->status = LIFE_WELL;
 				cgpu->status = LIFE_WELL;
 
 
 #ifdef WANT_CPUMINE
 #ifdef WANT_CPUMINE
-			if (!strcmp(cgpu->api->dname, "cpu"))
+			if (!strcmp(cgpu->drv->dname, "cpu"))
 				continue;
 				continue;
 #endif
 #endif
 			if (cgpu->status != LIFE_WELL && (now.tv_sec - thr->last.tv_sec < WATCHDOG_SICK_TIME)) {
 			if (cgpu->status != LIFE_WELL && (now.tv_sec - thr->last.tv_sec < WATCHDOG_SICK_TIME)) {
@@ -7910,37 +7910,37 @@ void enable_curses(void) {
 }
 }
 #endif
 #endif
 
 
-/* TODO: fix need a dummy CPU device_api even if no support for CPU mining */
+/* TODO: fix need a dummy CPU device_drv even if no support for CPU mining */
 #ifndef WANT_CPUMINE
 #ifndef WANT_CPUMINE
-struct device_api cpu_api;
-struct device_api cpu_api = {
+struct device_drv cpu_drv;
+struct device_drv cpu_drv = {
 	.name = "CPU",
 	.name = "CPU",
 };
 };
 #endif
 #endif
 
 
 #ifdef USE_BITFORCE
 #ifdef USE_BITFORCE
-extern struct device_api bitforce_api;
+extern struct device_drv bitforce_drv;
 #endif
 #endif
 
 
 #ifdef USE_ICARUS
 #ifdef USE_ICARUS
-extern struct device_api cairnsmore_api;
-extern struct device_api icarus_api;
+extern struct device_drv cairnsmore_drv;
+extern struct device_drv icarus_drv;
 #endif
 #endif
 
 
 #ifdef USE_AVALON
 #ifdef USE_AVALON
-extern struct device_api avalon_api;
+extern struct device_drv avalon_drv;
 #endif
 #endif
 
 
 #ifdef USE_MODMINER
 #ifdef USE_MODMINER
-extern struct device_api modminer_api;
+extern struct device_drv modminer_drv;
 #endif
 #endif
 
 
 #ifdef USE_X6500
 #ifdef USE_X6500
-extern struct device_api x6500_api;
+extern struct device_drv x6500_api;
 #endif
 #endif
 
 
 #ifdef USE_ZTEX
 #ifdef USE_ZTEX
-extern struct device_api ztex_api;
+extern struct device_drv ztex_drv;
 #endif
 #endif
 
 
 
 
@@ -7960,7 +7960,7 @@ void register_device(struct cgpu_info *cgpu)
 	adj_width(mining_threads, &dev_width);
 	adj_width(mining_threads, &dev_width);
 #endif
 #endif
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
-	if (cgpu->api == &opencl_api) {
+	if (cgpu->drv == &opencl_api) {
 		gpu_threads += cgpu->threads;
 		gpu_threads += cgpu->threads;
 	}
 	}
 #endif
 #endif
@@ -7977,12 +7977,12 @@ void renumber_cgpu(struct cgpu_info *cgpu)
 	static struct _cgpu_devid_counter *devids = NULL;
 	static struct _cgpu_devid_counter *devids = NULL;
 	struct _cgpu_devid_counter *d;
 	struct _cgpu_devid_counter *d;
 	
 	
-	HASH_FIND_STR(devids, cgpu->api->name, d);
+	HASH_FIND_STR(devids, cgpu->drv->name, d);
 	if (d)
 	if (d)
 		cgpu->device_id = ++d->lastid;
 		cgpu->device_id = ++d->lastid;
 	else {
 	else {
 		d = malloc(sizeof(*d));
 		d = malloc(sizeof(*d));
-		memcpy(d->name, cgpu->api->name, sizeof(d->name));
+		memcpy(d->name, cgpu->drv->name, sizeof(d->name));
 		cgpu->device_id = d->lastid = 0;
 		cgpu->device_id = d->lastid = 0;
 		HASH_ADD_STR(devids, name, d);
 		HASH_ADD_STR(devids, name, d);
 	}
 	}
@@ -8237,45 +8237,45 @@ int main(int argc, char *argv[])
 
 
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
 	if (!opt_nogpu)
 	if (!opt_nogpu)
-		opencl_api.api_detect();
+		opencl_api.drv_detect();
 	gpu_threads = 0;
 	gpu_threads = 0;
 #endif
 #endif
 
 
 #ifdef USE_ICARUS
 #ifdef USE_ICARUS
 	if (!opt_scrypt)
 	if (!opt_scrypt)
 	{
 	{
-		cairnsmore_api.api_detect();
-		icarus_api.api_detect();
+		cairnsmore_drv.drv_detect();
+		icarus_drv.drv_detect();
 	}
 	}
 #endif
 #endif
 
 
 #ifdef USE_AVALON
 #ifdef USE_AVALON
 	if (!opt_scrypt)
 	if (!opt_scrypt)
-		avalon_api.api_detect();
+		avalon_drv.drv_detect();
 #endif
 #endif
 
 
 #ifdef USE_BITFORCE
 #ifdef USE_BITFORCE
 	if (!opt_scrypt)
 	if (!opt_scrypt)
-		bitforce_api.api_detect();
+		bitforce_drv.drv_detect();
 #endif
 #endif
 
 
 #ifdef USE_MODMINER
 #ifdef USE_MODMINER
 	if (!opt_scrypt)
 	if (!opt_scrypt)
-		modminer_api.api_detect();
+		modminer_drv.drv_detect();
 #endif
 #endif
 
 
 #ifdef USE_X6500
 #ifdef USE_X6500
 	if (!opt_scrypt)
 	if (!opt_scrypt)
-		x6500_api.api_detect();
+		x6500_api.drv_detect();
 #endif
 #endif
 
 
 #ifdef USE_ZTEX
 #ifdef USE_ZTEX
 	if (!opt_scrypt)
 	if (!opt_scrypt)
-		ztex_api.api_detect();
+		ztex_drv.drv_detect();
 #endif
 #endif
 
 
 #ifdef WANT_CPUMINE
 #ifdef WANT_CPUMINE
-	cpu_api.api_detect();
+	cpu_drv.drv_detect();
 #endif
 #endif
 
 
 #ifdef USE_X6500
 #ifdef USE_X6500
@@ -8291,9 +8291,9 @@ int main(int argc, char *argv[])
 		for (i = 0; i < total_devices; ++i) {
 		for (i = 0; i < total_devices; ++i) {
 			struct cgpu_info *cgpu = devices[i];
 			struct cgpu_info *cgpu = devices[i];
 			if (cgpu->name)
 			if (cgpu->name)
-				applog(LOG_ERR, " %2d. %"PRIprepr": %s (driver: %s)", i, cgpu->proc_repr, cgpu->name, cgpu->api->dname);
+				applog(LOG_ERR, " %2d. %"PRIprepr": %s (driver: %s)", i, cgpu->proc_repr, cgpu->name, cgpu->drv->dname);
 			else
 			else
-				applog(LOG_ERR, " %2d. %"PRIprepr" (driver: %s)", i, cgpu->proc_repr, cgpu->api->dname);
+				applog(LOG_ERR, " %2d. %"PRIprepr" (driver: %s)", i, cgpu->proc_repr, cgpu->drv->dname);
 		}
 		}
 		quit(0, "%d devices listed", total_devices);
 		quit(0, "%d devices listed", total_devices);
 	}
 	}
@@ -8307,7 +8307,7 @@ int main(int argc, char *argv[])
 				register_device(devices[i]);
 				register_device(devices[i]);
 			} else if (i < total_devices) {
 			} else if (i < total_devices) {
 				if (opt_removedisabled) {
 				if (opt_removedisabled) {
-					if (devices[i]->api == &cpu_api)
+					if (devices[i]->drv == &cpu_drv)
 						--opt_n_threads;
 						--opt_n_threads;
 				} else {
 				} else {
 					register_device(devices[i]);
 					register_device(devices[i]);
@@ -8500,7 +8500,7 @@ begin_bench:
 	k = 0;
 	k = 0;
 	for (i = 0; i < total_devices; ++i) {
 	for (i = 0; i < total_devices; ++i) {
 		struct cgpu_info *cgpu = devices[i];
 		struct cgpu_info *cgpu = devices[i];
-		const struct device_api *api = cgpu->api;
+		const struct device_drv *api = cgpu->drv;
 		int threadobj = cgpu->threads;
 		int threadobj = cgpu->threads;
 		if (!threadobj)
 		if (!threadobj)
 			// Create a fake thread object to handle hashmeter etc
 			// Create a fake thread object to handle hashmeter etc
@@ -8546,7 +8546,7 @@ begin_bench:
 
 
 			/* Enable threads for devices set not to mine but disable
 			/* Enable threads for devices set not to mine but disable
 			 * their queue in case we wish to enable them later */
 			 * their queue in case we wish to enable them later */
-			if (cgpu->api->thread_prepare && !cgpu->api->thread_prepare(thr))
+			if (cgpu->drv->thread_prepare && !cgpu->drv->thread_prepare(thr))
 				continue;
 				continue;
 
 
 			thread_reportout(thr);
 			thread_reportout(thr);

+ 4 - 4
miner.h

@@ -261,12 +261,12 @@ struct api_data;
 struct thr_info;
 struct thr_info;
 struct work;
 struct work;
 
 
-struct device_api {
+struct device_drv {
 	const char *dname;
 	const char *dname;
 	const char *name;
 	const char *name;
 
 
-	// API-global functions
-	void (*api_detect)();
+	// DRV-global functions
+	void (*drv_detect)();
 
 
 	// Device-specific functions
 	// Device-specific functions
 	void (*get_dev_statline_before)(char *, struct cgpu_info *);
 	void (*get_dev_statline_before)(char *, struct cgpu_info *);
@@ -403,7 +403,7 @@ struct cgminer_pool_stats {
 struct cgpu_info {
 struct cgpu_info {
 	int cgminer_id;
 	int cgminer_id;
 	int device_line_id;
 	int device_line_id;
-	const struct device_api *api;
+	const struct device_drv *drv;
 	const char *devtype;
 	const char *devtype;
 	int device_id;
 	int device_id;
 	char *dev_repr;
 	char *dev_repr;