Ejemplo n.º 1
0
static void vsf_bufmgr_remove_mcb(struct vsf_bufmgr_mcb_t *list, struct vsf_bufmgr_mcb_t *mcb)
{
	struct vsf_bufmgr_mcb_t *active_mcb, *next_mcb, *prev_mcb;

	active_mcb = sllist_get_container(list->list.next, struct vsf_bufmgr_mcb_t, list);
	prev_mcb = list;
	while(active_mcb != NULL)
	{
		if(active_mcb == mcb)
		{
			next_mcb = sllist_get_container(active_mcb->list.next, struct vsf_bufmgr_mcb_t, list);
			if(next_mcb != NULL)
			{
				sllist_insert(prev_mcb->list, next_mcb->list);
			}
			else
			{
				sllist_init_node(prev_mcb->list);
			}
			sllist_init_node(active_mcb->list);
			return;
		}
		prev_mcb = active_mcb;
		active_mcb = sllist_get_container(active_mcb->list.next, struct vsf_bufmgr_mcb_t, list);
	}
Ejemplo n.º 2
0
static struct vsfsm_state_t *vsfusbh_init_evt_handler(struct vsfsm_t *sm,
		vsfsm_evt_t evt)
{
	vsf_err_t err;
	struct vsfusbh_t *usbh = (struct vsfusbh_t *)sm->user_data;

	switch (evt)
	{
	case VSFSM_EVT_ENTER:
		break;
	case VSFSM_EVT_INIT:
		usbh->dev_probe_pt.thread = NULL;
		sllist_init_node(usbh->drv_list);
		usbh->hcd_init_pt.thread = usbh->hcd->init_thread;
		usbh->hcd_init_pt.user_data = usbh;
		usbh->hcd_init_pt.state = 0;
		usbh->hcd_init_pt.sm = sm;
	default:
		err = usbh->hcd_init_pt.thread(&usbh->hcd_init_pt, evt);
		if (VSFERR_NONE == err)
		{
			// alloc probe urb
			usbh->probe_urb = usbh->hcd->alloc_urb();
			if (usbh->probe_urb == NULL)
			{
				// error
				usbh->hcd_init_pt.thread = NULL;
			}

			sm->init_state.evt_handler = vsfusbh_probe_evt_handler;
			usbh->rh_dev = vsfusbh_alloc_device(usbh);
			if (NULL == usbh->rh_dev)
			{
				// error
				usbh->hcd_init_pt.thread = NULL;
			}
			else
			{
				usbh->rh_dev->speed = usbh->hcd_rh_speed;
				if (usbh->rh_dev->speed == USB_SPEED_LOW)
					usbh->rh_dev->slow = 1;
				usbh->new_dev = usbh->rh_dev;
				vsfsm_post_evt_pending(&usbh->sm, VSFSM_EVT_NEW_DEVICE);
			}
		}
		else if (err < 0)
		{
			// error
			usbh->hcd_init_pt.thread = NULL;
		}
		break;
	}
	return NULL;
}