Exemplo n.º 1
0
static int
dektec_detach (device_t dev)
{
	struct dektec_sc *sc = (struct dektec_sc *) device_get_softc (dev);

	if (sc->legacy_plx)
		reset_plx (dev);

	free_buffer (dev, sc, &sc->rx_buffer);
	free_buffer (dev, sc, &sc->tx_buffer);

	destroy_buffer (sc, &sc->tx_buffer);
	destroy_buffer (sc, &sc->rx_buffer);

	bus_dma_tag_destroy (sc->desc_dma_tag);
	bus_dma_tag_destroy (sc->buffer_dma_tag);

	bus_teardown_intr (dev, sc->irq_res, sc->irq_cookie);

	bus_release_resource (dev, SYS_RES_IRQ, sc->irq_id, sc->irq_res);

	if (sc->legacy_plx) {
		bus_release_resource (dev, SYS_RES_MEMORY, sc->dta_base_id, sc->dta_base_res);
		bus_release_resource (dev, SYS_RES_MEMORY, sc->plx_base_id, sc->plx_base_res);
	} else {
		bus_release_resource (dev, SYS_RES_MEMORY, sc->dta_base_id, sc->dta_base_res);
	}

	destroy_dev (sc->cdev);

	mtx_destroy (&sc->dektec_mtx);

	return 0;
}
/**
 * Destroy Buffer
 */
static void
ARMSOCDRI2DestroyBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer)
{
	struct ARMSOCDRI2BufferRec *buf = ARMSOCBUF(buffer);
	ScreenPtr pScreen;
	ScrnInfoPtr pScrn;
	/* Note: pDraw may already be deleted, so use the pPixmap here
	 * instead (since it is at least refcntd)
	 */
	if (NULL == buf->pPixmaps || NULL == buf->pPixmaps[0]) {
		if (--buf->refcnt == 0)
			free(buf);
		return;
	}

	pScreen = buf->pPixmaps[0]->drawable.pScreen;
	pScrn = xf86ScreenToScrn(pScreen);

	DEBUG_MSG("pDraw=%p, DRIbuffer=%p", pDraw, buffer);

	if (destroy_buffer(pDraw, buf)) {
		free(buf->pPixmaps);
		free(buf);
	}
}
Exemplo n.º 3
0
void trios_buffer_queue_push(
        trios_buffer_queue_t *bq,
        NNTI_buffer_t       *buffer)
{
    NNTI_result_t nnti_rc=NNTI_OK;

    log_debug(bq_debug_level, "enter");

    if (nthread_lock(&bq->mutex)) log_warn(bq_debug_level, "failed to get lock");
    if (bq->queue.size() < bq->max_size) {
        /* when buffers are popped, the size could be reduced to avoid transferring more bytes than necessary */
        log_debug(bq_debug_level, "reset buffer size to bq->buffer_size");
        NNTI_BUFFER_SIZE(buffer)=bq->buffer_size;
        log_debug(bq_debug_level, "returning buffer to queue");
        bq->queue.push_front(buffer);
    } else {
        nnti_rc=destroy_buffer(&buffer);
        if (nnti_rc!=NNTI_OK) {
            log_error(bq_debug_level, "failed destroying on the fly queue buffer: %d", nnti_rc);
        } else {
            log_debug(bq_debug_level, "destroying on the fly queue buffer");
        }
    }
    nthread_unlock(&bq->mutex);

    log_debug(bq_debug_level, "exit");
}
Exemplo n.º 4
0
static void producer_operation(int sfd)
{
	while(status_on)
	{	
		int peer_sfd = accept(sfd,NULL,NULL);                           
		if(peer_sfd<0) 
		{
			print_log(WARNING,"\nACCEPT FAILED MAY BE BECAUSE OF INTERRUPT");
			continue;
		}
		if(pthread_mutex_lock(&buffer_lock_mtx)!=0)
			print_log(WARNING,"\nthere is error in lock prod");
		while(is_buffer_full()) 
		{
			if(pthread_cond_wait(&buffer_not_full_cond,&buffer_lock_mtx)!=0)
				print_log(WARNING,"\nthere is error in wait prod");
		}

		buffer_add(peer_sfd);				

		if(pthread_cond_broadcast(&buffer_not_empty_cond)!=0)
			print_log(WARNING,"\nthere is error in broadcast");
		if(pthread_mutex_unlock(&buffer_lock_mtx)!=0)
			print_log(WARNING,"\nthere is erorr in unlock");
	}
	destroy_buffer();
}
Exemplo n.º 5
0
/**	@fn	bool CBufferLoop::create_buffer(int nsize)
*	@brief 
*	@param[in] nsize 
*	@return	
*/
bool CBufferLoop::create_buffer( int nsize )
{
	destroy_buffer();
	m_pbuffer = (char*)malloc(nsize);
	memset(m_pbuffer, 0, nsize);
	m_nbuffer_size = nsize;
	m_nused_size = 0;
	return true;
}
Exemplo n.º 6
0
static void find_nearest_block(struct group *group, struct ray const *ray, struct nearest *nearest)
{
    struct groupdata *groupdata = group->data;

    struct ray groupspaceray;
    vec3_subtract(&groupspaceray.origin, &ray->origin, &group->position);
    groupspaceray.direction = ray->direction;

    buffer *buffer = create_buffer();
    ptrarray *blocks = groupdata->blocks;
    size_t blockcount = ptrarray_count(blocks);

    for (size_t i = 0; i < blockcount; ++i)
    {
        block *block = get_ptrarray(blocks, i);

        get_block_triangles(block, buffer);

        triangle *tris = buffer_data(buffer);
        size_t tricount = buffer_count(buffer, sizeof(struct triangle));

        for (size_t j = 0; j < tricount; ++j)
        {
            float temp;
            if (ray_intersect_triangle(&temp, &groupspaceray, &tris[j]))
            {
                /*
                 * Use <= for distance comparsion here so that when there are
                 * multiple candidates for selection the last block added will
                 * be selected. It is useful after pasting that the new blocks
                 * can be dragged to a new location.
                 */
                if (temp <= nearest->distance)
                {
                    nearest->distance = temp;
                    nearest->group    = group;
                    nearest->block    = block;
                    nearest->triangle = tris[j];
                }
            }
        }

        clear_buffer(buffer);
    }

    destroy_buffer(buffer);

    struct ptrarray *groups = groupdata->groups;
    size_t groupcount = ptrarray_count(groups);

    for (size_t i = 0; i < groupcount; ++i)
    {
        struct group *childgroup = get_ptrarray(groups, i);
        find_nearest_block(childgroup, ray, nearest);
    }
}
Exemplo n.º 7
0
	bool create_buffer(int nsize)
	{
		destroy_buffer();
        int nrealsize = (nsize / 4 + 1) * 4;
		m_pbuffer = (char*)malloc(nrealsize);
		memset(m_pbuffer, 0, nrealsize);
		m_nbuffer_size = nrealsize;
		m_nused_size = 0;
		return true;
	}
Exemplo n.º 8
0
void insert_blocks(struct group *group, block **blocks, size_t count)
{
    buffer *buffer = create_buffer();

    for (size_t i = 0; i < count; ++i)
    {
        block *block = blocks[i];
        push_ptrarray(group->data->blocks, block);
        get_block_triangles(block, buffer);
        append_triangles(group->data, buffer);
        clear_buffer(buffer);
    }

    destroy_buffer(buffer);
}
Exemplo n.º 9
0
void update_group_vertexarray(struct group *group)
{
    struct groupdata *groupdata = group->data;

    clear_buffer(groupdata->vertices);
    buffer *buffer = create_buffer();
    size_t blockcount = ptrarray_count(groupdata->blocks);

    for (size_t i = 0; i < blockcount; ++i)
    {
        block *block = get_ptrarray(groupdata->blocks, i);
        get_block_triangles(block, buffer);
        append_triangles(groupdata, buffer);
        clear_buffer(buffer);
    }

    destroy_buffer(buffer);
}
Exemplo n.º 10
0
// returns a c string representation for the given LValue
// (be sure to free the string when you're done)
char *l_str(LValue *value) {
  char *str;
  stringbuf *str2;
  switch(value->type) {
    case L_NUM_TYPE:
      str = mpz_get_str(NULL, 10, value->core.num);
      break;
    case L_STR_TYPE:
      str = GC_MALLOC(sizeof(char) * (value->core.str->length + 1));
      strcpy(str, value->core.str->str);
      break;
    case L_LIST_TYPE:
      str2 = make_stringbuf("[");
      char *s;
      int i, len = value->core.list->length;
      for(i=0; i<len; i++) {
        s = l_str(l_list_get(value, i));
        concat_stringbuf(str2, s);
        if(i<len-1) buffer_concat(str2, " ");
      }
      buffer_concat(str2, "]");
      str = GC_MALLOC(sizeof(char) * (str2->length + 1));
      strcpy(str, str2->str);
      destroy_buffer(str2);
      break;
    case L_TRUE_TYPE:
      str = GC_MALLOC(sizeof(char) * 5);
      strcpy(str, "true");
      break;
    case L_FALSE_TYPE:
      str = GC_MALLOC(sizeof(char) * 6);
      strcpy(str, "false");
      break;
    case L_NIL_TYPE:
      str = GC_MALLOC(sizeof(char) * 4);
      strcpy(str, "nil");
      break;
    default:
      str = GC_MALLOC(sizeof(char) * 1);
      strcpy(str, "");
  }
  return str;
}
Exemplo n.º 11
0
void xml_formatter(FILE * f, const struct poem *p, GList * verses)
{
    struct buffer * buf = create_buffer(XML_INITIAL_BUFFER_SIZE);

    append_buffer(buf, "<?xml version=\"1.0\" standalone=\"yes\"?>\n");
    append_buffer(buf, "<poem>\n");
    append_buffer(buf, "  <name>");
    append_buffer(buf, get_poem_name(p));
    append_buffer(buf, "</name>\n");

    if (verses)
        g_list_foreach(verses, (GFunc)xml_format_verse, buf);
    else
        each_verse(p, xml_format_verse, buf);

    append_buffer(buf, "</poem>\n");

    fprintf(f, "%s\n", get_buffer_string(buf));

    destroy_buffer(buf);
}
Exemplo n.º 12
0
int main()
{
  /* Initialize buffer to store ints */
  buffer *buff = init_buffer();

  seed_random_number_generator();

  /* Create/start threads */
  pthread_t producer, consumer;

  pthread_create(&producer, NULL, producer_function, buff);
  pthread_create(&consumer, NULL, consumer_function, buff);

  /* Join threads */
  pthread_join(producer, NULL);
  pthread_join(consumer, NULL);

  /* Free buffer/memory */
  destroy_buffer(buff);

  return 0;
}
Exemplo n.º 13
0
int trios_buffer_queue_fini(
        trios_buffer_queue_t *bq)
{
    NNTI_result_t nnti_rc=NNTI_OK;
    NNTI_buffer_t *buffer=NULL;

    log_debug(bq_debug_level, "enter");

    if (nthread_lock(&bq->mutex)) log_warn(bq_debug_level, "failed to get lock");
    if (bq->queue.size() != bq->current_size) {
        log_warn(bq_debug_level, "buffer queue (%p) has missing entries (bq->queue.size(%llu) != bq->current_size(%llu))",
                bq, (uint64_t)bq->queue.size(), (uint64_t)bq->current_size);
    }
    if (bq->queue.size() < bq->initial_size) {
        log_warn(bq_debug_level, "buffer queue (%p) has missing entries (bq->queue.size(%llu) < bq->initial_size(%llu))",
                bq, (uint64_t)bq->queue.size(), (uint64_t)bq->initial_size);
    }
    if (bq->queue.size() > bq->max_size) {
        log_warn(bq_debug_level, "buffer queue (%p) has extra entries (bq->queue.size(%llu) > bq->max_size(%llu))",
                bq, (uint64_t)bq->queue.size(), (uint64_t)bq->max_size);
    }
    while (!bq->queue.empty()) {
        buffer=bq->queue.front();
        bq->queue.pop_front();
        nnti_rc=destroy_buffer(&buffer);
        if (nnti_rc!=NNTI_OK) {
            log_error(bq_debug_level, "failed destroying queue buffer: %d", nnti_rc);
            break;
        }
    }
    nthread_unlock(&bq->mutex);

    nthread_lock_fini(&bq->mutex);

    log_debug(bq_debug_level, "exit");

    return((int)nnti_rc);
}
Exemplo n.º 14
0
static void release_groupdata(struct groupdata *groupdata)
{
    if (groupdata && --groupdata->refcount == 0)
    {
        size_t blockcount = ptrarray_count(groupdata->blocks);
        for (size_t i = 0; i < blockcount; ++i)
        {
            destroy_block(get_ptrarray(groupdata->blocks, i));
        }

        size_t groupcount = ptrarray_count(groupdata->groups);
        for (size_t i = 0; i < groupcount; ++i)
        {
            destroy_group(get_ptrarray(groupdata->groups, i));
        }

        destroy_ptrarray(groupdata->blocks);
        destroy_ptrarray(groupdata->groups);
        destroy_buffer(groupdata->vertices);

        free(groupdata);
    }
}
Exemplo n.º 15
0
CBufferLoop::~CBufferLoop(void)
{
	destroy_buffer();
}
Exemplo n.º 16
0
void destroy_client(kivi_client* client) {
	destroy_buffer(client -> in_buf);
	destroy_buffer(client -> out_buf);
	free(client);
}
Exemplo n.º 17
0
static char * all_tests() {
int i;
    printf("---------------------------------------------------\n");
    //~ buffer_collection res_buf;
	for (i=0;i<1;i++)
	{
    init_res_buf();
    mu_run_test(test_uvarint1);
    mu_run_test(test_uvarint2);
    mu_run_test(test_svarint1);
    mu_run_test(test_svarint2);
    mu_run_test(test_svarint3);
    mu_run_test(test_svarint4);
    mu_run_test(test_svarint5);
	
	
    mu_run_test(test_geoJSON_point1);
    printf("---------------------------------------------------\n");
    mu_run_test(test_geoJSON_line1);
    printf("---------------------------------------------------\n");
    mu_run_test(test_geoJSON_polygon1);
    printf("---------------------------------------------------\n");
    mu_run_test(test_geoJSON_polygon2);
    printf("---------------------------------------------------\n");
    mu_run_test(test_geoJSON_collection1);
    printf("---------------------------------------------------\n");
    mu_run_test(test_geoJSON_collection2);
    printf("---------------------------------------------------\n");
    mu_run_test(test_geoJSON_collection3);
    printf("---------------------------------------------------\n");
    mu_run_test(test_geoJSON_collection4);
    printf("---------------------------------------------------\n");
    mu_run_test(test_geoJSON_collection5);
    printf("---------------------------------------------------\n");
	destroy_buffer();
	
	
    mu_run_test(test_geoJSON_many_geometries1);
    printf("---------------------------------------------------\n");
    mu_run_test(test_geoJSON_n_decimals);
    printf("---------------------------------------------------\n");
	
    init_res_buf();	
    mu_run_test(test_esrijson_point1);
    printf("---------------------------------------------------\n");
    mu_run_test(test_esrijson_line1);
    printf("---------------------------------------------------\n");
    mu_run_test(test_esrijson_polygon1);
    printf("---------------------------------------------------\n");
    mu_run_test(test_esrijson_polygon2);
    printf("---------------------------------------------------\n");
    mu_run_test(test_esrijson_collection1);
    printf("---------------------------------------------------\n");
    mu_run_test(test_esrijson_collection2);
    printf("---------------------------------------------------\n");
    mu_run_test(test_esrijson_collection3);
    printf("---------------------------------------------------\n");
    mu_run_test(test_esrijson_collection4);
    printf("---------------------------------------------------\n");
    mu_run_test(test_esrijson_collection5);
    printf("---------------------------------------------------\n");
     destroy_buffer();       
    
    mu_run_test(test_esrijson_many_geometries1);
    printf("---------------------------------------------------\n");
    mu_run_test(test_esrijson_n_decimals);
    printf("---------------------------------------------------\n");
    

  mu_run_test(test_filereading2geoJSONindexed);
  mu_run_test(test_filereading2esrijson_indexed);
 //~ mu_run_test(test_filereading2geoJSON,&res_buf);
 //   mu_run_test(test_filereading,&res_buf);

    }
    return 0;
}
Exemplo n.º 18
0
	virtual ~CBufferLoop(void)
	{
		destroy_buffer();
	}
Exemplo n.º 19
0
/**
 * 加载配置文件
 */
void init_conf(){
	buffer_t *rbuf=alloc_buffer(CONF_READ_BUF);
	int fd=open_conf_file();
	enum PARSE_STATE status=RAW;
	config_module_t *current_module;
	command_t *current_command;
	char_t *module_name=init_char();
	char_t *command_key=init_char();
	char_t *command_value=init_char();
	while(1){
		if(has_space(rbuf)){
			intptr_t count=read(fd,rbuf->data+rbuf->limit,rbuf->size-rbuf->limit);
			if(count<=0){
				goto CONFIG_END;
			}
			rbuf->limit+=count;
		}
		while(has_remaining(rbuf)){
    		char c=*(rbuf->data+rbuf->current);
    		rbuf->current+=1;
    		if(status==RAW&&c==brace_start){
    			status=MODULE_START;
    		}else if(status==MODULE_START&&!char_is_special(c)){
    			if(c==brace_start){
    				add_terminal(module_name);
    				current_module=find_config_module(module_name);
    				if(current_module==NULL){
    					my_log(ERROR,"config error,please check\n");
    					goto CONFIG_END;
    				}else{
    					status=FIND_COMMAND_KEY;
    				}
    			}else if(c==brace_end){
    				goto CONFIG_END;
    			}else{
    				add_char(module_name,c);
    			}
    		}else if(status==FIND_COMMAND_KEY&&!char_is_special(c)){
    			if(c==brace_end){
    				current_module=NULL;
    				reset_char(module_name);
    				status=MODULE_START;
    			}else{
    				add_char(command_key,c);
    				status=COMMAND_KEY_START;
    			}
    		}else if(status==COMMAND_KEY_START){
    			if(!char_is_special(c)){
    				add_char(command_key,c);
    			}else{
    				add_terminal(command_key);
    				current_command=find_config_command(command_key,current_module);
    				if(current_command==NULL){
    					my_log(ERROR,"config error,please check\n");
    					goto CONFIG_END;
    				}
    				status=COMMAND_VALUE_START;
    			}
				
    		}else if(status==COMMAND_VALUE_START&&!char_is_special(c)){
    			if(c!=semicolon){
    				add_char(command_value,c);
    			}else{
    				add_terminal(command_value);
    				current_command->set_value(command_value);
    				current_command=NULL;
    				reset_char(command_value);
    				reset_char(command_key);
    				status=FIND_COMMAND_KEY;
    			}
    		}
    	}
	}
CONFIG_END:
	destroy_buffer(rbuf);
}
Exemplo n.º 20
0
static int
dektec_attach (device_t dev)
{
	int error = 0;

	struct dektec_sc *sc = (struct dektec_sc *) device_get_softc (dev);

	sc->dev = dev;

	sc->model = get_device_model (dev);

	TASK_INIT (&sc->task, 0, dektec_task, (void *) sc);

	int unit = device_get_unit (dev);

	if ((sc->cdev = make_dev (&dektec_cdevsw, unit, UID_ROOT, GID_OPERATOR, 0666, "dektec%d", unit)) == NULL)
		goto make_dev;

	sc->cdev->si_drv1 = sc;

	uint32_t vendor_id = pci_get_vendor (dev);

	sc->legacy_plx = vendor_id == PLX_PCI_VENDOR_ID;

	if (sc->legacy_plx) {
		sc->plx_base_id = PCIR_BAR (0);
		sc->plx_base_res = bus_alloc_resource_any (dev, SYS_RES_MEMORY, &sc->plx_base_id, RF_ACTIVE);

		if (sc->plx_base_res == NULL)
			goto bus_alloc_resource_any_plx_reg;

		sc->plx_base_bt = rman_get_bustag (sc->plx_base_res);
		sc->plx_base_bh = rman_get_bushandle (sc->plx_base_res);

		/* FIXME refactor dta_base */
		sc->dta_base_id = PCIR_BAR (2);
		sc->dta_base_res = bus_alloc_resource_any (dev, SYS_RES_MEMORY, &sc->dta_base_id, RF_ACTIVE);

		if (sc->dta_base_res == NULL)
			goto bus_alloc_resource_any_dta_base;

		sc->dta_base_bt = rman_get_bustag (sc->dta_base_res);
		sc->dta_base_bh = rman_get_bushandle (sc->dta_base_res);

		/* DTA-140 */
		sc->gen_base = 0x0000; /* FIXME make constant */
		sc->tx_base = 0x0080;
		sc->rx_base = 0x0100;
		sc->dma_base0 = 0x0000;
		sc->dma_base1 = 0x0000;
	} else {
		/* pCh->m_Dma.m_pRegBase = pBase; */
		/* pCh->m_Dma.m_pRegDmaDesc = pBase + 0x4; */
		/* pCh->m_Dma.m_pRegCmdStat = pBase + 0x8; */

		/* FIXME refactor dta_base */
		sc->dta_base_id = PCIR_BAR (0);
		sc->dta_base_res = bus_alloc_resource_any (dev, SYS_RES_MEMORY, &sc->dta_base_id, RF_ACTIVE);

		if (sc->dta_base_res == NULL)
			goto bus_alloc_resource_any_dta_base;

		sc->dta_base_bt = rman_get_bustag (sc->dta_base_res);
		sc->dta_base_bh = rman_get_bushandle (sc->dta_base_res);

		/* DTA-145 */
		sc->gen_base = 0x0000; /* FIXME make constant */
		/* program configurable channel */
		// sc->tx_base = 0x0180; /* pFdo->m_TsTx[ti]->m_pRegBase = (char*)(pRegBase + 0x180 + (0x200*i)) */
		sc->tx_base = 0x0380; /* pFdo->m_TsTx[ti]->m_pRegBase = (char*)(pRegBase + 0x180 + (0x200*i)) */
		sc->rx_base = 0x0100; /* pFdo->m_TsRx[i]->m_pRegBase = (char*)(pRegBase + 0x100 + (0x200*i)) */
		sc->dma_base0 = 0x0200;
		sc->dma_base1 = 0x0400;
	}

	sc->irq_id = 0x0;
	sc->irq_res = bus_alloc_resource_any (dev, SYS_RES_IRQ, &sc->irq_id, RF_SHAREABLE | RF_ACTIVE);

	if (sc->irq_res == NULL)
		goto bus_alloc_resource_any_irq;

	error = bus_setup_intr (dev, sc->irq_res, INTR_TYPE_MISC, NULL, dektec_intr, sc, &sc->irq_cookie);

	if (error)
		goto bus_setup_intr;

	error = bus_dma_tag_create (NULL, ASI_PLX_SEGMENT_ALIGN, 0,
				    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
				    NULL, NULL,
				    BUFFER_MAX_DMA_SIZE,
				    BUFFER_MAX_DMA_SEGMENTS, BUFFER_MAX_DMA_SEGMENT_SIZE,
				    BUS_DMA_ALLOCNOW,
				    NULL, NULL,
				    &sc->buffer_dma_tag);

	if (error)
		goto bus_dma_tag_create_buffer;

	error = bus_dma_tag_create (NULL, ASI_PLX_DESCRIPTOR_ALIGN, 0,
				    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
				    NULL, NULL,
				    DESC_MAX_DMA_SIZE,
				    DESC_MAX_DMA_SEGMENTS, DESC_MAX_DMA_SEGMENT_SIZE,
				    BUS_DMA_ALLOCNOW,
				    NULL, NULL,
				    &sc->desc_dma_tag);

	if (error)
		goto bus_dma_tag_create_desc;

	init_buffer (sc, &sc->tx_buffer);
	init_buffer (sc, &sc->rx_buffer);

	error = allocate_buffer (dev, sc, &sc->tx_buffer);

	if (error)
		goto allocate_tx_buffer;

	error = allocate_buffer (dev, sc, &sc->rx_buffer);

	if (error)
		goto allocate_rx_buffer;

	if (sc->legacy_plx) {
		reset_plx (dev);
		enable_plx (dev);
	}

	sc->fw_rev_gen = dta1xx_gen_ctrl_reg_get_firmware_rev (sc->dta_base_bt, sc->dta_base_bh, sc->gen_base);
	sc->fw_rev_tx = dta1xx_tx_gen_ctrl_reg_get_firmware_rev (sc->dta_base_bt, sc->dta_base_bh, sc->tx_base);
	sc->fw_rev_rx = dta1xx_rx_gen_ctrl_reg_get_firmware_rev (sc->dta_base_bt, sc->dta_base_bh, sc->rx_base);

	mtx_init (&sc->dektec_mtx, "dektec", NULL, MTX_DEF);

	device_printf (dev, "board model %d, firmware version %d (tx: %d, rx: %d), tx fifo %d MB\n",
		       dta1xx_rx_gen_ctrl_reg_get_type_number (sc->dta_base_bt, sc->dta_base_bh, sc->rx_base),
		       sc->fw_rev_gen, sc->fw_rev_tx, sc->fw_rev_rx,
		       dta1xx_tx_get_fifo_size_reg (sc->dta_base_bt, sc->dta_base_bh, sc->tx_base) / 1024);

	goto done;

allocate_rx_buffer:
	free_buffer (dev, sc, &sc->tx_buffer);

allocate_tx_buffer:
	destroy_buffer (sc, &sc->rx_buffer);
	destroy_buffer (sc, &sc->tx_buffer);

	bus_dma_tag_destroy (sc->desc_dma_tag);

bus_dma_tag_create_desc:
	bus_dma_tag_destroy (sc->buffer_dma_tag);

bus_dma_tag_create_buffer:
	bus_teardown_intr (dev, sc->irq_res, sc->irq_cookie);

bus_setup_intr:
	bus_release_resource (dev, SYS_RES_IRQ, sc->irq_id, sc->irq_res);

bus_alloc_resource_any_irq:
	bus_release_resource (dev, SYS_RES_MEMORY, sc->dta_base_id, sc->dta_base_res);

bus_alloc_resource_any_dta_base:
	bus_release_resource (dev, SYS_RES_MEMORY, sc->plx_base_id, sc->plx_base_res);

bus_alloc_resource_any_plx_reg:
	destroy_dev (sc->cdev);

make_dev:
done:
	return error;
}