Browse Source

Rename cgpu_data to use new device_data

Luke Dashjr 12 years ago
parent
commit
0d81426147
6 changed files with 46 additions and 47 deletions
  1. 25 25
      driver-bitforce.c
  2. 5 5
      driver-cairnsmore.c
  3. 7 7
      driver-icarus.c
  4. 2 2
      driver-opencl.c
  5. 7 7
      driver-x6500.c
  6. 0 1
      miner.h

+ 25 - 25
driver-bitforce.c

@@ -197,7 +197,7 @@ static bool bitforce_detect_one(const char *devpath)
 		s[0] = '\0';
 		bitforce->name = strdup(pdevbuf + 7);
 	}
-	bitforce->cgpu_data = initdata;
+	bitforce->device_data = initdata;
 
 	mutex_init(&bitforce->device_mutex);
 
@@ -241,7 +241,7 @@ static
 void bitforce_comm_error(struct thr_info *thr)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	int *p_fdDev = &bitforce->device->device_fd;
 	
 	data->noncebuf[0] = '\0';
@@ -262,7 +262,7 @@ void bitforce_comm_error(struct thr_info *thr)
 
 static void get_bitforce_statline_before(char *buf, struct cgpu_info *bitforce)
 {
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 
 	if (data->temp[0] > 0 && data->temp[1] > 0)
 		tailsprintf(buf, "%5.1fC/%4.1fC   | ", data->temp[0], data->temp[1]);
@@ -322,7 +322,7 @@ static void bitforce_clear_buffer(struct cgpu_info *bitforce)
 
 void bitforce_reinit(struct cgpu_info *bitforce)
 {
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	struct thr_info *thr = bitforce->thr[0];
 	const char *devpath = bitforce->device_path;
 	pthread_mutex_t *mutexp = &bitforce->device->device_mutex;
@@ -407,7 +407,7 @@ void bitforce_reinit(struct cgpu_info *bitforce)
 
 static void bitforce_flash_led(struct cgpu_info *bitforce)
 {
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	pthread_mutex_t *mutexp = &bitforce->device->device_mutex;
 	int fdDev = bitforce->device->device_fd;
 
@@ -461,7 +461,7 @@ void set_float_if_gt_zero(float *var, float value)
 
 static bool bitforce_get_temp(struct cgpu_info *bitforce)
 {
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	pthread_mutex_t *mutexp = &bitforce->device->device_mutex;
 	int fdDev = bitforce->device->device_fd;
 	char pdevbuf[0x100];
@@ -534,7 +534,7 @@ void dbg_block_data(struct cgpu_info *bitforce)
 	if (!opt_debug)
 		return;
 	
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	char *s;
 	s = bin2hex(&data->next_work_ob[8], 44);
 	applog(LOG_DEBUG, "%"PRIpreprv": block data: %s", bitforce->proc_repr, s);
@@ -547,7 +547,7 @@ static
 bool bitforce_job_prepare(struct thr_info *thr, struct work *work, __maybe_unused uint64_t max_nonce)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	int fdDev = bitforce->device->device_fd;
 	unsigned char *ob_ms = &data->next_work_ob[8];
 	unsigned char *ob_dt = &ob_ms[32];
@@ -609,7 +609,7 @@ bool bitforce_job_prepare(struct thr_info *thr, struct work *work, __maybe_unuse
 static
 void bitforce_change_mode(struct cgpu_info *bitforce, enum bitforce_proto proto)
 {
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	
 	if (data->proto == proto)
 		return;
@@ -666,7 +666,7 @@ static
 void bitforce_job_start(struct thr_info *thr)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	pthread_mutex_t *mutexp = &bitforce->device->device_mutex;
 	int fdDev = bitforce->device->device_fd;
 	unsigned char *ob = data->next_work_obs;
@@ -744,7 +744,7 @@ static
 int bitforce_zox(struct thr_info *thr, const char *cmd)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	pthread_mutex_t *mutexp = &bitforce->device->device_mutex;
 	int fd = bitforce->device->device_fd;
 	char *pdevbuf = &data->noncebuf[0];
@@ -802,7 +802,7 @@ static
 void bitforce_job_get_results(struct thr_info *thr, struct work *work)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	int fdDev = bitforce->device->device_fd;
 	unsigned int delay_time_ms;
 	struct timeval elapsed;
@@ -1007,7 +1007,7 @@ static
 void bitforce_process_result_nonces(struct thr_info *thr, struct work *work, char *pnoncebuf)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	uint32_t nonce;
 	
 	while (1) {
@@ -1076,7 +1076,7 @@ static
 int64_t bitforce_job_process_results(struct thr_info *thr, struct work *work, __maybe_unused bool stopping)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	char *pnoncebuf = &data->noncebuf[0];
 	int count;
 	
@@ -1139,7 +1139,7 @@ static bool bitforce_thread_init(struct thr_info *thr)
 	struct cgpu_info *bitforce = thr->cgpu;
 	unsigned int wait;
 	struct bitforce_data *data;
-	struct bitforce_init_data *initdata = bitforce->cgpu_data;
+	struct bitforce_init_data *initdata = bitforce->device_data;
 	bool sc = initdata->sc;
 	int xlink_id = 0;
 	
@@ -1156,7 +1156,7 @@ static bool bitforce_thread_init(struct thr_info *thr)
 		}
 		
 		bitforce->sleep_ms = BITFORCE_SLEEP_MS;
-		bitforce->cgpu_data = data = malloc(sizeof(*data));
+		bitforce->device_data = data = malloc(sizeof(*data));
 		*data = (struct bitforce_data){
 			.xlink_id = xlink_id,
 			.next_work_ob = ">>>>>>>>|---------- MidState ----------||-DataTail-||Nonces|>>>>>>>>",
@@ -1210,7 +1210,7 @@ static bool bitforce_thread_init(struct thr_info *thr)
 
 static struct api_data *bitforce_drv_stats(struct cgpu_info *cgpu)
 {
-	struct bitforce_data *data = cgpu->cgpu_data;
+	struct bitforce_data *data = cgpu->device_data;
 	struct api_data *root = NULL;
 
 	// Warning, access to these is not locked - but we don't really
@@ -1232,7 +1232,7 @@ static struct api_data *bitforce_drv_stats(struct cgpu_info *cgpu)
 void bitforce_poll(struct thr_info *thr)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	int poll = data->poll_func;
 	thr->tv_poll.tv_sec = -1;
 	data->poll_func = 0;
@@ -1252,7 +1252,7 @@ void bitforce_poll(struct thr_info *thr)
 static
 char *bitforce_set_device(struct cgpu_info *proc, char *option, char *setting, char *replybuf)
 {
-	struct bitforce_data *data = proc->cgpu_data;
+	struct bitforce_data *data = proc->device_data;
 	pthread_mutex_t *mutexp = &proc->device->device_mutex;
 	int fd;
 	
@@ -1315,7 +1315,7 @@ static inline
 void bitforce_set_queue_full(struct thr_info *thr)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	
 	thr->queue_full = (data->queued + data->ready_to_queue >= BITFORCE_MAX_QUEUED) || (data->ready_to_queue >= BITFORCE_MAX_BQUEUE_AT_ONCE);
 }
@@ -1324,7 +1324,7 @@ static
 bool bitforce_send_queue(struct thr_info *thr)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	pthread_mutex_t *mutexp = &bitforce->device->device_mutex;
 	int fd = bitforce->device->device_fd;
 	struct work *work;
@@ -1400,7 +1400,7 @@ static
 bool bitforce_queue_do_results(struct thr_info *thr)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	int fd = bitforce->device->device_fd;
 	int count;
 	char *noncebuf = &data->noncebuf[0], *buf, *end;
@@ -1514,7 +1514,7 @@ static
 bool bitforce_queue_append(struct thr_info *thr, struct work *work)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	bool rv, ndq;
 	
 	bitforce_set_queue_full(thr);
@@ -1548,7 +1548,7 @@ static
 void bitforce_queue_flush(struct thr_info *thr)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	pthread_mutex_t *mutexp = &bitforce->device->device_mutex;
 	int fd = bitforce->device->device_fd;
 	char buf[100];
@@ -1583,7 +1583,7 @@ static
 void bitforce_queue_poll(struct thr_info *thr)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
-	struct bitforce_data *data = bitforce->cgpu_data;
+	struct bitforce_data *data = bitforce->device_data;
 	unsigned long sleep_us;
 	
 	if (data->queued)

+ 5 - 5
driver-cairnsmore.c

@@ -109,7 +109,7 @@ bool cairnsmore_supports_dynclock(int fd)
 static bool cairnsmore_change_clock_func(struct thr_info *thr, int bestM)
 {
 	struct cgpu_info *cm1 = thr->cgpu;
-	struct ICARUS_INFO *info = cm1->cgpu_data;
+	struct ICARUS_INFO *info = cm1->device_data;
 
 	if (unlikely(!cairnsmore_send_cmd(cm1->device_fd, 0, bestM)))
 		return false;
@@ -126,7 +126,7 @@ static bool cairnsmore_change_clock_func(struct thr_info *thr, int bestM)
 static bool cairnsmore_init(struct thr_info *thr)
 {
 	struct cgpu_info *cm1 = thr->cgpu;
-	struct ICARUS_INFO *info = cm1->cgpu_data;
+	struct ICARUS_INFO *info = cm1->device_data;
 	struct icarus_state *state = thr->cgpu_data;
 
 	if (cairnsmore_supports_dynclock(cm1->device_fd)) {
@@ -160,7 +160,7 @@ static bool cairnsmore_init(struct thr_info *thr)
 
 void convert_icarus_to_cairnsmore(struct cgpu_info *cm1)
 {
-	struct ICARUS_INFO *info = cm1->cgpu_data;
+	struct ICARUS_INFO *info = cm1->device_data;
 	info->Hs = CAIRNSMORE1_HASH_TIME;
 	info->fullnonce = info->Hs * (((double)0xffffffff) + 1);
 	info->timing_mode = MODE_LONG;
@@ -172,7 +172,7 @@ void convert_icarus_to_cairnsmore(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->device_data;
 	struct api_data*root = NULL;
 
 	if (info->dclk.freqM) {
@@ -185,7 +185,7 @@ static struct api_data *cairnsmore_drv_extra_device_status(struct cgpu_info *cm1
 
 static bool cairnsmore_identify(struct cgpu_info *cm1)
 {
-	struct ICARUS_INFO *info = cm1->cgpu_data;
+	struct ICARUS_INFO *info = cm1->device_data;
 	if (!info->dclk.freqM)
 		return false;
 	

+ 7 - 7
driver-icarus.c

@@ -319,7 +319,7 @@ static const char *timing_mode_str(enum timing_mode timing_mode)
 
 static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus)
 {
-	struct ICARUS_INFO *info = icarus->cgpu_data;
+	struct ICARUS_INFO *info = icarus->device_data;
 	double Hs;
 	char buf[BUFSIZ+1];
 	char *ptr, *comma, *eq;
@@ -618,7 +618,7 @@ bool icarus_detect_custom(const char *devpath, struct device_drv *api, struct IC
 		icarus->proc_repr,
 		baud, work_division, fpga_count);
 
-	icarus->cgpu_data = info;
+	icarus->device_data = info;
 
 	timersub(&tv_finish, &tv_start, &(info->golden_tv));
 
@@ -653,7 +653,7 @@ static void icarus_detect()
 static bool icarus_prepare(struct thr_info *thr)
 {
 	struct cgpu_info *icarus = thr->cgpu;
-	struct ICARUS_INFO *info = icarus->cgpu_data;
+	struct ICARUS_INFO *info = icarus->device_data;
 
 	struct timeval now;
 
@@ -691,7 +691,7 @@ static bool icarus_prepare(struct thr_info *thr)
 static bool icarus_init(struct thr_info *thr)
 {
 	struct cgpu_info *icarus = thr->cgpu;
-	struct ICARUS_INFO *info = icarus->cgpu_data;
+	struct ICARUS_INFO *info = icarus->device_data;
 	int fd = icarus->device_fd;
 	
 	if (!info->work_division)
@@ -741,7 +741,7 @@ static bool icarus_init(struct thr_info *thr)
 
 static bool icarus_reopen(struct cgpu_info *icarus, struct icarus_state *state, int *fdp)
 {
-	struct ICARUS_INFO *info = icarus->cgpu_data;
+	struct ICARUS_INFO *info = icarus->device_data;
 
 	// Reopen the serial port to workaround a USB-host-chipset-specific issue with the Icarus's buggy USB-UART
 	icarus_close(icarus->device_fd);
@@ -830,7 +830,7 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 
 	// Wait for the previous run's result
 	fd = icarus->device_fd;
-	info = icarus->cgpu_data;
+	info = icarus->device_data;
 
 	if (!state->firstrun) {
 		if (state->changework)
@@ -1094,7 +1094,7 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 static struct api_data *icarus_drv_stats(struct cgpu_info *cgpu)
 {
 	struct api_data *root = NULL;
-	struct ICARUS_INFO *info = cgpu->cgpu_data;
+	struct ICARUS_INFO *info = cgpu->device_data;
 
 	// Warning, access to these is not locked - but we don't really
 	// care since hashing performance is way more important than

+ 2 - 2
driver-opencl.c

@@ -1476,7 +1476,7 @@ static void opencl_detect()
 		
 #ifdef HAVE_SENSORS
 		cn = (c == -1) ? NULL : sensors_get_detected_chips(&cnm, &c);
-		cgpu->cgpu_data = data = malloc(sizeof(*data));
+		cgpu->device_data = data = malloc(sizeof(*data));
 		*data = (struct opencl_device_data){
 			.sensor = cn,
 		};
@@ -1497,7 +1497,7 @@ static void reinit_opencl_device(struct cgpu_info *gpu)
 static void get_opencl_statline_before(char *buf, struct cgpu_info *gpu)
 {
 #ifdef HAVE_SENSORS
-	struct opencl_device_data *data = gpu->cgpu_data;
+	struct opencl_device_data *data = gpu->device_data;
 	if (data->sensor)
 	{
 		const sensors_chip_name *cn = data->sensor;

+ 7 - 7
driver-x6500.c

@@ -134,7 +134,7 @@ static bool x6500_foundusb(libusb_device *dev, const char *product, const char *
 	x6500->procs = 2;
 	x6500->name = strdup(product);
 	x6500->cutofftemp = 85;
-	x6500->cgpu_data = dev;
+	x6500->device_data = dev;
 
 	return add_cgpu(x6500);
 }
@@ -161,7 +161,7 @@ static bool x6500_prepare(struct thr_info *thr)
 	if (x6500->proc_id)
 		return true;
 	
-	struct ft232r_device_handle *ftdi = ft232r_open(x6500->cgpu_data);
+	struct ft232r_device_handle *ftdi = ft232r_open(x6500->device_data);
 	x6500->device_ft232r = NULL;
 	if (!ftdi)
 		return false;
@@ -176,12 +176,12 @@ static bool x6500_prepare(struct thr_info *thr)
 	*pdone = 101;
 	jtag_a = (void*)(pdone + 1);
 	jtag_a->ftdi = ftdi;
-	x6500->cgpu_data = jtag_a;
+	x6500->device_data = jtag_a;
 	
 	for (struct cgpu_info *slave = x6500->next_proc; slave; slave = slave->next_proc)
 	{
 		slave->device_ft232r = x6500->device_ft232r;
-		slave->cgpu_data = x6500->cgpu_data;
+		slave->device_data = x6500->device_data;
 	}
 	
 	return true;
@@ -213,7 +213,7 @@ x6500_fpga_upload_bitstream(struct cgpu_info *x6500, struct jtag_port *jp1)
 {
 	char buf[0x100];
 	unsigned long len, flen;
-	unsigned char *pdone = (unsigned char*)x6500->cgpu_data - 1;
+	unsigned char *pdone = (unsigned char*)x6500->device_data - 1;
 	struct ft232r_device_handle *ftdi = jp1->a->ftdi;
 
 	FILE *f = open_xilinx_bitstream(x6500->drv->dname, x6500->dev_repr, X6500_BITSTREAM_FILENAME, &len);
@@ -357,7 +357,7 @@ static bool x6500_thread_init(struct thr_info *thr)
 	
 	fpga = calloc(1, sizeof(*fpga));
 	jp = &fpga->jtag;
-	jp->a = x6500->cgpu_data;
+	jp->a = x6500->device_data;
 	x6500_jtag_set(jp, pinoffset);
 	thr->cgpu_data = fpga;
 	
@@ -561,7 +561,7 @@ bool get_x6500_upload_percent(char *buf, struct cgpu_info *x6500)
 {
 	char info[18] = "               | ";
 
-	unsigned char pdone = *((unsigned char*)x6500->cgpu_data - 1);
+	unsigned char pdone = *((unsigned char*)x6500->device_data - 1);
 	if (pdone != 101) {
 		sprintf(&info[1], "%3d%%", pdone);
 		info[5] = ' ';

+ 0 - 1
miner.h

@@ -465,7 +465,6 @@ struct cgpu_info {
 #if defined(USE_BITFORCE) || defined(USE_ICARUS)
 	bool flash_led;
 #endif
-	void *cgpu_data;
 	pthread_mutex_t		device_mutex;
 	pthread_cond_t	device_cond;