Browse Source

BFG_REGISTER_DRIVER macro to commonly pre-define device_drv structures

Luke Dashjr 12 years ago
parent
commit
5cd4bcaa6c

+ 4 - 0
deviceapi.h

@@ -7,6 +7,10 @@
 
 
 #include "miner.h"
 #include "miner.h"
 
 
+#define BFG_REGISTER_DRIVER(drv)                \
+	struct device_drv drv;                      \
+// END BFG_REGISTER_DRIVER
+
 extern void request_work(struct thr_info *);
 extern void request_work(struct thr_info *);
 extern struct work *get_work(struct thr_info *);
 extern struct work *get_work(struct thr_info *);
 extern bool hashes_done(struct thr_info *, int64_t hashes, struct timeval *tvp_hashes, uint32_t *max_nonce);
 extern bool hashes_done(struct thr_info *, int64_t hashes, struct timeval *tvp_hashes, uint32_t *max_nonce);

+ 2 - 1
driver-avalon.c

@@ -42,8 +42,9 @@
 #include "logging.h"
 #include "logging.h"
 #include "util.h"
 #include "util.h"
 
 
+BFG_REGISTER_DRIVER(avalon_drv)
+
 static int option_offset = -1;
 static int option_offset = -1;
-struct device_drv avalon_drv;
 
 
 static int avalon_init_task(struct avalon_task *at,
 static int avalon_init_task(struct avalon_task *at,
 			    uint8_t reset, uint8_t ff, uint8_t fan,
 			    uint8_t reset, uint8_t ff, uint8_t fan,

+ 1 - 1
driver-bfsb.c

@@ -31,7 +31,7 @@
 #include "spidevc.h"
 #include "spidevc.h"
 #include "driver-bitfury.h"
 #include "driver-bitfury.h"
 
 
-struct device_drv bfsb_drv;
+BFG_REGISTER_DRIVER(bfsb_drv)
 
 
 static
 static
 bool bfsb_spi_txrx(struct spi_port *port)
 bool bfsb_spi_txrx(struct spi_port *port)

+ 1 - 1
driver-bigpic.c

@@ -29,7 +29,7 @@
 
 
 #include <stdio.h>
 #include <stdio.h>
 
 
-struct device_drv bigpic_drv;
+BFG_REGISTER_DRIVER(bigpic_drv)
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 static bool bigpic_detect_custom(const char *devpath, struct device_drv *api, struct bigpic_info *info)
 static bool bigpic_detect_custom(const char *devpath, struct device_drv *api, struct bigpic_info *info)

+ 2 - 2
driver-bitforce.c

@@ -61,8 +61,8 @@ static const char *protonames[] = {
 	"parallel queue",
 	"parallel queue",
 };
 };
 
 
-struct device_drv bitforce_drv;
-struct device_drv bitforce_queue_api;
+BFG_REGISTER_DRIVER(bitforce_drv)
+BFG_REGISTER_DRIVER(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)

+ 1 - 1
driver-bitfury.c

@@ -37,7 +37,7 @@
 #include "util.h"
 #include "util.h"
 #include "spidevc.h"
 #include "spidevc.h"
 
 
-struct device_drv bitfury_drv;
+BFG_REGISTER_DRIVER(bitfury_drv)
 
 
 static
 static
 int bitfury_autodetect()
 int bitfury_autodetect()

+ 1 - 1
driver-cairnsmore.c

@@ -27,7 +27,7 @@
 #define CAIRNSMORE1_DEFAULT_CLOCK  200
 #define CAIRNSMORE1_DEFAULT_CLOCK  200
 #define CAIRNSMORE1_MAXIMUM_CLOCK  210
 #define CAIRNSMORE1_MAXIMUM_CLOCK  210
 
 
-struct device_drv cairnsmore_drv;
+BFG_REGISTER_DRIVER(cairnsmore_drv)
 
 
 static void cairnsmore_drv_init();
 static void cairnsmore_drv_init();
 
 

+ 2 - 0
driver-cpu.c

@@ -42,6 +42,8 @@
 	#include <fcntl.h>
 	#include <fcntl.h>
 #endif
 #endif
 
 
+BFG_REGISTER_DRIVER(cpu_drv)
+
 #if defined(__linux) && defined(CPU_ZERO)  /* Linux specific policy and affinity management */
 #if defined(__linux) && defined(CPU_ZERO)  /* Linux specific policy and affinity management */
 #include <sched.h>
 #include <sched.h>
 static inline void drop_policy(void)
 static inline void drop_policy(void)

+ 2 - 2
driver-erupter.c

@@ -18,8 +18,8 @@
 #define ERUPTER_IO_SPEED 115200
 #define ERUPTER_IO_SPEED 115200
 #define ERUPTER_HASH_TIME 0.0000000029761
 #define ERUPTER_HASH_TIME 0.0000000029761
 
 
-extern struct device_drv erupter_drv;
-extern struct device_drv erupter_drv_emerald;
+BFG_REGISTER_DRIVER(erupter_drv)
+BFG_REGISTER_DRIVER(erupter_drv_emerald)
 
 
 static bool _erupter_detect_one(const char *devpath, struct device_drv *drv)
 static bool _erupter_detect_one(const char *devpath, struct device_drv *drv)
 {
 {

+ 1 - 1
driver-icarus.c

@@ -169,7 +169,7 @@ static const char *MODE_UNKNOWN_STR = "unknown";
 //
 //
 static int option_offset = -1;
 static int option_offset = -1;
 
 
-struct device_drv icarus_drv;
+BFG_REGISTER_DRIVER(icarus_drv)
 
 
 extern void convert_icarus_to_cairnsmore(struct cgpu_info *);
 extern void convert_icarus_to_cairnsmore(struct cgpu_info *);
 
 

+ 1 - 1
driver-knc.c

@@ -76,7 +76,7 @@ enum knc_i2c_core_status {
 	KNC_I2CSTATUS_ENABLED  = 3,
 	KNC_I2CSTATUS_ENABLED  = 3,
 };
 };
 
 
-struct device_drv knc_drv;
+BFG_REGISTER_DRIVER(knc_drv)
 
 
 struct knc_device {
 struct knc_device {
 	int i2c;
 	int i2c;

+ 1 - 1
driver-littlefury.c

@@ -35,7 +35,7 @@ enum littlefury_opcode {
 	LFOP_ADC     = 7,
 	LFOP_ADC     = 7,
 };
 };
 
 
-struct device_drv littlefury_drv;
+BFG_REGISTER_DRIVER(littlefury_drv)
 
 
 static uint16_t crc16tab[] = {
 static uint16_t crc16tab[] = {
 	0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,
 	0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,

+ 1 - 1
driver-metabank.c

@@ -32,7 +32,7 @@
 #include "spidevc.h"
 #include "spidevc.h"
 #include "tm_i2c.h"
 #include "tm_i2c.h"
 
 
-struct device_drv metabank_drv;
+BFG_REGISTER_DRIVER(metabank_drv)
 
 
 static
 static
 bool metabank_spi_txrx(struct spi_port *port)
 bool metabank_spi_txrx(struct spi_port *port)

+ 1 - 1
driver-modminer.c

@@ -48,7 +48,7 @@
 
 
 #define FPGAID_ALL 4
 #define FPGAID_ALL 4
 
 
-struct device_drv modminer_drv;
+BFG_REGISTER_DRIVER(modminer_drv)
 
 
 struct modminer_fpga_state {
 struct modminer_fpga_state {
 	bool work_running;
 	bool work_running;

+ 1 - 1
driver-nanofury.c

@@ -30,7 +30,7 @@
 
 
 #define NANOFURY_MAX_BYTES_PER_SPI_TRANSFER 60			// due to MCP2210 limitation
 #define NANOFURY_MAX_BYTES_PER_SPI_TRANSFER 60			// due to MCP2210 limitation
 
 
-struct device_drv nanofury_drv;
+BFG_REGISTER_DRIVER(nanofury_drv)
 
 
 // Bit-banging reset, to reset more chips in chain - toggle for longer period... Each 3 reset cycles reset first chip in chain
 // Bit-banging reset, to reset more chips in chain - toggle for longer period... Each 3 reset cycles reset first chip in chain
 static
 static

+ 1 - 1
driver-opencl.c

@@ -787,7 +787,7 @@ char *set_intensity(char *arg)
 
 
 
 
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
-struct device_drv opencl_api;
+BFG_REGISTER_DRIVER(opencl_drv)
 
 
 char *print_ndevs_and_exit(int *ndevs)
 char *print_ndevs_and_exit(int *ndevs)
 {
 {

+ 1 - 1
driver-proxy.c

@@ -18,7 +18,7 @@
 #include "miner.h"
 #include "miner.h"
 #include "util.h"
 #include "util.h"
 
 
-struct device_drv proxy_drv;
+BFG_REGISTER_DRIVER(proxy_drv)
 
 
 static
 static
 struct proxy_client *proxy_clients;
 struct proxy_client *proxy_clients;

+ 1 - 1
driver-x6500.c

@@ -40,7 +40,7 @@
 #define X6500_DEFAULT_CLOCK  190
 #define X6500_DEFAULT_CLOCK  190
 #define X6500_MAXIMUM_CLOCK  250
 #define X6500_MAXIMUM_CLOCK  250
 
 
-struct device_drv x6500_api;
+BFG_REGISTER_DRIVER(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))
 
 

+ 1 - 1
driver-ztex.c

@@ -31,7 +31,7 @@
 
 
 #define GOLDEN_BACKLOG 5
 #define GOLDEN_BACKLOG 5
 
 
-struct device_drv ztex_drv;
+BFG_REGISTER_DRIVER(ztex_drv)
 
 
 // Forward declarations
 // Forward declarations
 static void ztex_disable(struct thr_info* thr);
 static void ztex_disable(struct thr_info* thr);