static void spondoolies_detect_sp50(__maybe_unused bool hotplug)
{
    struct cgpu_info *cgpu = calloc(1, sizeof(struct cgpu_info));
    struct device_drv *drv = &sp50_drv;
    struct spond_adapter *device;
    int i;
    assert(cgpu);
    cgpu->drv = drv;
    cgpu->deven = DEV_ENABLED;
    cgpu->threads = 1;
    cgpu->device_data = calloc(1, sizeof(struct spond_adapter));
    assert(cgpu->device_data);
    device = cgpu->device_data;
    device->cgpu = (void *)cgpu;
    device->current_job_id = 0;;
    pthread_mutex_init(&device->lock, NULL);
    device->socket_fd = init_socket();
    for (i = 0 ; i < MAX_JOBS_IN_MINERGATE; i++) {
        // clean structure
        memset(&device->my_jobs[i], 0, sizeof(spond_driver_work));
        // init our internal lock
        cglock_init(&(device->my_jobs[i].data_lock));
        // init lock for cgminer needs (make sure we are not broken)
        cglock_init(&(device->my_jobs[i].pool.data_lock));
    }
    if (device->socket_fd < 1) {
        quit(1, "Error connecting to minergate server!");
    }
    assert(add_cgpu(cgpu));
    // setup time
	device->last_stats = time(NULL);
    SPONDLOG(LOG_DEBUG, "done");
}
Example #2
0
K_LIST *_k_new_list(const char *name, size_t siz, int allocate, int limit, bool do_tail, KLIST_FFL_ARGS)
{
	K_LIST *list;

	if (allocate < 1)
		quithere(1, "Invalid new list %s with allocate %d must be > 0", name, allocate);

	if (limit < 0)
		quithere(1, "Invalid new list %s with limit %d must be >= 0", name, limit);

	list = calloc(1, sizeof(*list));
	if (!list)
		quithere(1, "Failed to calloc list %s", name);

	list->is_store = false;

	list->lock = calloc(1, sizeof(*(list->lock)));
	if (!(list->lock))
		quithere(1, "Failed to calloc lock for list %s", name);

	cglock_init(list->lock);

	list->name = name;
	list->siz = siz;
	list->allocate = allocate;
	list->limit = limit;
	list->do_tail = do_tail;

	k_alloc_items(list, KLIST_FFL_PASS);

	return list;
}
Example #3
0
static bool hashratio_prepare(struct thr_info *thr)
{
	struct cgpu_info *hashratio = thr->cgpu;
	struct hashratio_info *info = hashratio->device_data;

	cglock_init(&info->pool.data_lock);

	return true;
}
Example #4
0
static bool avalon2_prepare(struct thr_info *thr)
{
	struct cgpu_info *avalon2 = thr->cgpu;
	struct avalon2_info *info = avalon2->device_data;

	free(avalon2->works);
	avalon2->works = calloc(sizeof(struct work *), 2);
	if (!avalon2->works)
		quit(1, "Failed to calloc avalon2 works in avalon2_prepare");

	if (info->fd == -1)
		avalon2_init(avalon2);

	info->first = 0;

	cglock_init(&(pool_stratum.data_lock));

	return true;
}